[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2021-10-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

Andrew Pinski  changed:

   What|Removed |Added

 CC||thomas at monjalon dot net

--- Comment #34 from Andrew Pinski  ---
*** Bug 88096 has been marked as a duplicate of this bug. ***

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-27 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #33 from janus at gcc dot gnu.org ---
(In reply to janus from comment #30)
> I have verified that the problem goes away when using the following as
> version:
> GNU assembler (GNU Binutils) 2.31.51.20181124

Same ǵoes for the 2.30 branch as of today. (I hope there will be a 2.30.1
release in the near future.)

According to comment 22, binutils 2.29 also seems to work well.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-26 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #32 from H.J. Lu  ---
*** Bug 86831 has been marked as a duplicate of this bug. ***

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-25 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #31 from H.J. Lu  ---
*** Bug 86828 has been marked as a duplicate of this bug. ***

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-25 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #30 from janus at gcc dot gnu.org ---
I have verified that the problem goes away when using the following as version:
GNU assembler (GNU Binutils) 2.31.51.20181124

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
   See Also||https://sourceware.org/bugz
   ||illa/show_bug.cgi?id=23465
 Resolution|--- |MOVED

--- Comment #29 from H.J. Lu  ---
This is a binutils bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=23465

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread amonakov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #28 from Alexander Monakov  ---
It seems like object file is not correctly assembled, note wrong offset to the
last instruction (movdqu):

.s:

vpgatherqd  (%rax,%ymm3,4), %xmm4{%k4}
vpgatherqd  (%rax,%ymm1,4), %xmm0{%k1}
vshufi32x4  $0, %ymm0, %ymm4, %ymm0
vmovdqu32   %ymm0, 32(,%rsi,4)

.o:
 52a:   62 f2 7d 2c 91 24 98vpgatherqd (%rax,%ymm3,4),%xmm4{%k4}
 531:   62 f2 7d 29 91 04 88vpgatherqd (%rax,%ymm1,4),%xmm0{%k1}
 538:   62 f3 5d 28 43 c0 00vshufi32x4 $0x0,%ymm0,%ymm4,%ymm0
 53f:   62 f1 7e 28 7f 04 b5vmovdqu32 %ymm0,0x1(,%rsi,4)
 546:   01 00 00 00 

On older Binutils I get vmovdqu32 %ymm0,0x20(,%rsi,4) as expected.

Probably relevant Binutils bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=23465
https://sourceware.org/bugzilla/show_bug.cgi?id=23314

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #27 from janus at gcc dot gnu.org ---
Created attachment 45086
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45086=edit
object file

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #26 from janus at gcc dot gnu.org ---
(In reply to janus from comment #25)
> Created attachment 45085 [details]
> assembler output

In fact this seems to be identical to Jakub's assembly (except for filenames
and versions strings), but while it works for him, it fails for me.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #25 from janus at gcc dot gnu.org ---
Created attachment 45085
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45085=edit
assembler output

assembler output obtained from comment 0 via "gfortran-9 c0.f90
-march=skylake-avx512 -Ofast -S", exhibiting wrong results

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread amonakov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #24 from Alexander Monakov  ---
Janus, can you attach your .s and .o files please?

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #23 from Jakub Jelinek  ---
Created attachment 45083
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45083=edit
pr86735.s

Assembly I get which works for me.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #22 from Jakub Jelinek  ---
Fedora 27, kernel 4.16.4-200
Intel(R) Core(TM) i9-7960X CPU
glibc 2.26-30, binutils, 2.29-13

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-24 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #21 from janus at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #20)
> Tried again, this time on real hw (i9-7960X) and still can't reproduce,

Thanks for the data point, Jakub. Could you please share your kernel and glibc
version? H.J.'s comment 15 sounds like the kernel version might make a
difference. (Unfortunately I am stuck with kernel 4.15 right now and cannot
verify this.)

In any case, I still see the problem with current trunk and this config:
* Ubuntu 18.04, kernel 4.15.0
* Intel(R) Core(TM) i9-7980XE CPU
* glibc 2.27, binutils 2.30

My trunk build has been configured with:
configure --program-suffix=-9 --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --with-arch=skylake-avx512 --prefix=/
--enable-languages=c,c++,fortran --disable-multilib

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-11-23 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #20 from Jakub Jelinek  ---
Tried again, this time on real hw (i9-7960X) and still can't reproduce, tried
current trunk, current 8 branch and r263070 (i.e. trunk from the time this PR
has been filed), none of this reproduces it.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-04 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #19 from janus at gcc dot gnu.org ---
(In reply to janus from comment #17)
> Huh, sounds possible. However, I see the buggy behavior also with sde64 (on
> the same machine where I also see it in real HW, see comment 16).

Another machine (Haswell CPU, Ubuntu 18.04) also shows the bug with sde64.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-04 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #18 from janus at gcc dot gnu.org ---
(In reply to janus from comment #17)
> However, I see the buggy behavior also with sde64 (on
> the same machine where I also see it in real HW, see comment 16).

But then again, I don't see it with sde64 on a different machine:
* Ubuntu 16.04
* kernel 4.15.0
* glibc 2.23
* binutils 2.26

Kernel version (and gcc trunk version) is the same. So what could it be that
makes the difference? glibc? binutils? Something else?

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-04 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #17 from janus at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #14)
> /usr/src/sde/sde64 -- ./pr86735
>1   2   3   4   5   6
> 7   8   9  10  11  12  13   
> 14  15  16
>1   2   3   4   5   6
> 7   8   9  10  11  12  13   
> 14  15  16
> Perhaps sde64 behaves differently from real HW?

Huh, sounds possible. However, I see the buggy behavior also with sde64 (on the
same machine where I also see it in real HW, see comment 16).

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-04 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #16 from janus at gcc dot gnu.org ---
(In reply to H.J. Lu from comment #15)
> I can no longer reproduce it under kernel 4.17.11.

But five days ago you could, right? What changed in the meantime?

I still see the problem with 8.2.0 and today's trunk, in the following setup:
* Ubuntu 18.04, kernel 4.15.0
* Intel(R) Core(TM) i9-7980XE CPU
* glibc 2.27, binutils 2.30

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-03 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #15 from H.J. Lu  ---
I can no longer reproduce it under kernel 4.17.11.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #14 from Jakub Jelinek  ---
Can't reproduce, either with gcc 8.2.0, or current 8.2.1, or latest trunk:
/d/gcc-8.2.0/objdir/gcc/gfortran -B /d/gcc-8.2.0/objdir/gcc/
-march=skylake-avx512 -Ofast -o pr86735{,.f90} -B
/d/gcc-8.2.0/objdir/x86_64-pc-linux-gnu/libgfortran/.libs/ -B
/d/gcc-8.2.0/objdir/x86_64-pc-linux-gnu/libgfortran/ -B
/d/gcc-8.2.0/objdir/x86_64-pc-linux-gnu/libquadmath/.libs/
-Wl,-rpath,../x86_64-pc-linux-gnu/libgfortran/.libs/; /usr/src/sde/sde64 --
./pr86735
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16
Perhaps sde64 behaves differently from real HW?  Tried also -O3 -fstack-arrays,
-mprefer-vector-width={128,256,512}, but everything works.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-08-02 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #13 from janus at gcc dot gnu.org ---
gfortran.fortran-torture/execute/in-pack.f90 in the testsuite exhibits the same
problem as comment 0, I think. It also contains Fortran array operations and
fails with "-march=skylake-avx512 -Ofast". See PR 86831 comment 5.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-31 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #12 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #11)
> Thanks for the explanation. Note that
> 
> % gfcp pr86735.f90 -Ofast -march=skylake -Wall -Wextra -fcheck=all

That probably just means that -fcheck prevents the optimization passes from
applying AVX512 instructions. Please cut the noise!

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-31 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #11 from Dominique d'Humieres  ---
> If you build for haswell or skylake architecture, that executable will
> not run on ivybridge, of course.

Thanks for the explanation. Note that

% gfcp pr86735.f90 -Ofast -march=skylake -Wall -Wextra -fcheck=all
% ./a.out
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-31 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #10 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #8)
> On x86_64-apple-darwin17 without access to avx512, I see
> 
>[..]
> 
> Is this the same bug or should I file a new one?

That is not a bug at all. You apparently have an ivybridge processor, so with
that flag you get the expected output.

If you build for haswell or skylake architecture, that executable will not run
on ivybridge, of course.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-31 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #9 from H.J. Lu  ---
(In reply to Dominique d'Humieres from comment #8)
> On x86_64-apple-darwin17 without access to avx512, I see
> 
> Is this the same bug or should I file a new one?

Please file a new one.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-31 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #8 from Dominique d'Humieres  ---
On x86_64-apple-darwin17 without access to avx512, I see

% gfcp pr86735.f90 -Ofast -march=skylake
% ./a.out
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16

Program received signal SIGILL: Illegal instruction.

and

% gfcp pr86735.f90 -Ofast -march=haswell
% ./a.out
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16

Program received signal SIGILL: Illegal instruction.

but

% gfcp pr86735.f90 -Ofast -march=ivybridge
% ./a.out
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16
   1   2   3   4   5   6   
   7   8   9  10  11  12  13   
  14  15  16

Is this the same bug or should I file a new one?

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-30 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #7 from H.J. Lu  ---
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fc3d6f0aebc..a8709972e9c 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -40402,6 +40402,10 @@ ix86_multiplication_cost (const struct processor_costs 
*cost,
   ? cost->mulsd : cost->mulss, true);
   else if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
 {
+  /* vpmullq is used in this case. No emulation is needed.  */
+  if (TARGET_AVX512DQ)
+   return ix86_vec_cost (mode, cost->mulss, true);
+
   /* V*QImode is emulated with 7-13 insns.  */
   if (mode == V16QImode || mode == V32QImode)
{

triggered gather coedgen, which may lead to a latent bug.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-30 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

H.J. Lu  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-30
 CC||hjl.tools at gmail dot com
 Ever confirmed|0   |1

--- Comment #6 from H.J. Lu  ---
This is caused by r257505.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-30 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to Alexander Monakov from comment #3)
> An observation in case it might help to narrow down the problem: gcc-8
> changed to prefer 256-bit-wide vectors on skylake-avx512, so adding
> -mprefer-vector-width=512 option for gcc-8/trunk should make vectorization
> behave a bit closer to gcc-7.

Indeed adding the flag "-mprefer-vector-width=512" makes the problem disappear.
Thanks for the comment.

[Bug target/86735] [8/9 Regression] Bad wrong-code bug with "-march=skylake-avx512 -Ofast"

2018-07-30 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86735

Richard Biener  changed:

   What|Removed |Added

 Target||x86_64-*-*
 CC||kyukhin at gcc dot gnu.org
  Component|tree-optimization   |target
   Target Milestone|--- |8.3

--- Comment #4 from Richard Biener  ---
Looks more like a target issue to me.  AVX2 uses very similar gather stuff.