I seem to have triggered a bug in the tree vectorizer of GCC as of 20120404. $ cat file.c struct S1 { int intfield; struct { unsigned ufield:10; } sfield; }; int func2(short param1, short param2) { int **intptr; if((param1 && param2) + **intptr) while(1); } void func1(void) { struct S1 foo; func2(foo.intfield, foo.sfield.ufield); } $ ~/gcc/dist/bin/gcc --version gcc (GCC) 4.8.0 20120404 (experimental) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ ~/gcc/dist/bin/gcc -O2 -ftree-vectorize file.c Using built-in specs. COLLECT_GCC=/home/merkil/gcc/dist/bin/gcc COLLECT_LTO_WRAPPER=/home/merkil/gcc/dist/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../srcdir/configure --prefix=/home/merkil/gcc/dist CFLAGS=' -O2 -pipe' CXXFLAGS=' -O2 -pipe' --enable-languages=c,c++,lto Thread model: posix gcc version 4.8.0 20120404 (experimental) (GCC) COLLECT_GCC_OPTIONS='-O2' '-ftree-vectorize' '-v' '-mtune=generic' '-march=x86-64' /home/merkil/gcc/dist/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1 -quiet -v file.c -quiet -dumpbase file.c -mtune=generic -march=x86-64 -auxbase file -O2 -version -ftree-vectorize -o /tmp/ccuzSuSy.s GNU C (GCC) version 4.8.0 20120404 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20120404 (experimental), GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ignoring nonexistent directory "/home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include /usr/local/include /home/merkil/gcc/dist/include /home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include-fixed /usr/include End of search list. GNU C (GCC) version 4.8.0 20120404 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20120404 (experimental), GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 77c744b2fbaa15d9025679f4b671f18a file.c: In function 'func1': file.c:19:6: internal compiler error: in adjust_bool_pattern, at tree-vect-patterns.c:2301 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Hope that is useful to you :-)
Confirmed.
Another small testcase, if that's helpful. [regehr@dyson r18]$ cat small.c #pragma pack(1) struct S2 { unsigned f0:22; }; struct { struct S2 f0; } c; int a, b, d; void fn1 () { if (1 ? (!c.f0.f0 & d < 0) < a : 0) b = 0; } [regehr@dyson r18]$ current-gcc -O3 -c small.c small.c: In function 'fn1': small.c:12:1: internal compiler error: in adjust_bool_pattern, at tree-vect-patterns.c:2301 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [regehr@dyson r18]$ current-gcc -v Using built-in specs. COLLECT_GCC=current-gcc COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r186257-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --with-libelf=/usr/local --enable-lto --prefix=/home/regehr/z/compiler-install/gcc-r186257-install --program-prefix=r186257- --enable-languages=c,c++ Thread model: posix gcc version 4.8.0 20120410 (experimental) (GCC)
Created attachment 27202 [details] gcc48-pr52891.patch Untested fix. Sorry for the delay.
Author: jakub Date: Mon Apr 23 10:13:39 2012 New Revision: 186694 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186694 Log: PR tree-optimizations/52891 * tree-vect-patterns.c (adjust_bool_pattern): Use build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE, but with non-standard precision. * gcc.c-torture/compile/pr52891-1.c: New test. * gcc.c-torture/compile/pr52891-2.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-patterns.c
Author: jakub Date: Mon Apr 23 10:16:57 2012 New Revision: 186695 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186695 Log: PR tree-optimizations/52891 * tree-vect-patterns.c (adjust_bool_pattern): Use build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE, but with non-standard precision. * gcc.c-torture/compile/pr52891-1.c: New test. * gcc.c-torture/compile/pr52891-2.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree-vect-patterns.c
Fixed.
Author: gjl Date: Tue Apr 24 17:08:20 2012 New Revision: 186775 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186775 Log: PR testsuite/52641 PR tree-optimizations/52891 * gcc.c-torture/compile/pr52891-2.c: Fix test for 16-bit int. Modified: branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c
Author: gjl Date: Tue Apr 24 17:18:54 2012 New Revision: 186776 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186776 Log: PR testsuite/52641 PR tree-optimizations/52891 * gcc.c-torture/compile/pr52891-2.c: Fix test for 16-bit int. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c