Created attachment 38552 [details] Reproducer GCC trunk generates wrong code with -O3/Ofast on 'ivybridge' target (not sure about other targets though) crash.cpp is attached. Run: > g++ -static-libgcc -static-libstdc++ -std=c++11 -O2 -march=ivybridge -o out0 crash.cpp > g++ -static-libgcc -static-libstdc++ -std=c++11 -O3 -march=ivybridge -o out1 crash.cpp Output: > ./out0: -5105075050047261684 > ./out1: -5105075050047261682 > gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/export/users/amitrokh/gcc_trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /export/users/gnutester/stability/svn/trunk/configure --with-arch=corei7 --with-cpu=corei7 --enable-clocale=gnu --with-system-zlib --enable-shared --with-demangler-in-ld --enable-cloog-backend=isl --with-fpmath=sse --with-pkgversion=Revision=236614/svn-rev:236614/ --prefix=/export/users/gnutester/stability/work/trunk/64/install --enable-languages=c,c++,fortran,java,lto Thread model: posix gcc version 7.0.0 20160523 (experimental) (Revision=236614/svn-rev:236614/)
Confirmed also with GCC 6 with -msse4.2, -fno-tree-vectorize fixes it. GCC 5 works fine.
Simplified testcase: long a, b[1][44][2]; long long c[44][17][2]; int main () { int i, j, k; asm volatile ("" : : : "memory"); for (i = 0; i < 44; i++) for (j = 0; j < 17; j++) for (k = 0; k < 2; k++) c[i][j][k] = (30995740 >= *(k + *(j + *b)) != (a != 8)) - 5105075050047261684; asm volatile ("" : : : "memory"); for (i = 0; i < 44; i++) for (j = 0; j < 17; j++) for (k = 0; k < 2; k++) if (c[i][j][k] != -5105075050047261684) __builtin_abort (); return 0; }
Started to ICE with r230098, before that it worked properly. ICE got fixed with r232153, but it is miscompiled already then, so it is unclear when this wrong-code has been introduced.
Created attachment 38639 [details] gcc7-pr71259.patch Untested fix.
Author: jakub Date: Mon Jun 6 18:35:03 2016 New Revision: 237147 URL: https://gcc.gnu.org/viewcvs?rev=237147&root=gcc&view=rev Log: PR tree-optimization/71259 * tree-vect-slp.c (vect_get_constant_vectors): For VECTOR_BOOLEAN_TYPE_P, return all ones constant instead of one for constant op, and use COND_EXPR for non-constant. * gcc.dg/vect/pr71259.c: New test. Added: trunk/gcc/testsuite/gcc.dg/vect/pr71259.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-slp.c
Author: jakub Date: Mon Jun 6 18:47:33 2016 New Revision: 237148 URL: https://gcc.gnu.org/viewcvs?rev=237148&root=gcc&view=rev Log: PR tree-optimization/71259 * tree-vect-slp.c (vect_get_constant_vectors): For VECTOR_BOOLEAN_TYPE_P, return all ones constant instead of one for constant op, and use COND_EXPR for non-constant. * gcc.dg/vect/pr71259.c: New test. Added: branches/gcc-6-branch/gcc/testsuite/gcc.dg/vect/pr71259.c Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/testsuite/ChangeLog branches/gcc-6-branch/gcc/tree-vect-slp.c
Fixed.