[regehr@gamow tmp057]$ current-gcc -v Using built-in specs. COLLECT_GCC=current-gcc COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r181229-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.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-r181229-install --program-prefix=r181229- --enable-languages=c,c++ Thread model: posix gcc version 4.7.0 20111109 (experimental) (GCC) [regehr@gamow tmp057]$ current-gcc -Ofast -c -w small.c small.c: In function 'func_9': small.c:24:1: error: invalid PHI argument .MEM_3 small.c:24:1: error: incompatible types in PHI argument 0 int void g_95_I_lsm.15_29 = PHI <.MEM_3(5)> small.c:24:1: internal compiler error: verify_gimple failed Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [regehr@gamow tmp057]$ cat small.c int func_4 (int si1, int si2) { return si1; } int func_14 (int left, int right) { return 1; } int func_37 (int left, int right) { return left; } int g_92[]; int g_95[]; int g_224; int g_352[]; int func_9 () { for (; g_224; g_224 += 1) { g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0); g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0); } return 0; }
Catched by copyprop, caused by loop distributions memset replacement. Fails in random ways on all branches that have loop distribution. A regression with -O3 (enabled by default) since 4.6.
For <bb 5>: # g_224.0_23 = PHI <g_224.1_10(7), g_224.0_22(4)> # MEM = PHI <MEM, MEM> D.2957_3 = g_92[g_224.0_23]; g_92[g_224.0_23] = 0; g_352[g_224.0_23] = 1; g_224.1_10 = g_224.0_23 + 1; if (g_224.1_10 != 0) goto <bb 7>; else goto <bb 6>; <bb 6>: # g_95_I_lsm.15_29 = PHI <D.2957_3(5)> g_95[0] = g_95_I_lsm.15_29; g_224 = 0; goto <bb 3>; <bb 7>: goto <bb 5>; we generate partitions { 0 1 2 3 5 6 } and { 0 4 5 6 } note that the partition with the zero store also includes the load from g_92[g_224.0_23] which has a use outside of the loop. We cannot generate a memset replacement for this with the current code. I have a patch.
Author: rguenth Date: Thu Nov 10 13:46:27 2011 New Revision: 181255 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181255 Log: 2011-11-10 Richard Guenther <rguenther@suse.de> PR tree-optimization/51070 * tree-loop-distribution.c (generate_builtin): Do not replace the loop with a builtin if the partition contains statements which results are used outside of the loop. (pass_loop_distribution): Verify and collect. * gcc.dg/torture/pr51070.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr51070.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-loop-distribution.c
Fixed for 4.7 for now.
The testcase fails with -O3 -fno-inline or with -O3 when func_37() is declared with __attribute__((noinline)). Compiler output: $ gcc -v Using built-in specs. COLLECT_GCC=/mnt/svn/gcc-trunk/binary-latest/bin/gcc COLLECT_LTO_WRAPPER=/mnt/svn/gcc-trunk/binary-182733-lto-fortran-checking-yes-rtl-df/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /mnt/svn/gcc-trunk//configure --enable-checking=yes,rtl,df --enable-languages=c,c++,lto,fortran --prefix=/mnt/svn/gcc-trunk/binary-182733-lto-fortran-checking-yes-rtl-df/ --with-cloog --with-ppl --with-cloog-include=/usr/include/cloog-ppl/ --disable-ppl-version-check Thread model: posix gcc version 4.7.0 20111229 (experimental) (GCC) $ gcc -O3 -fno-inline gcc.dg/torture/pr51070.c gcc.dg/torture/pr51070.c: In function 'func_9': gcc.dg/torture/pr51070.c:26:1: error: invalid PHI argument .MEM_5 gcc.dg/torture/pr51070.c:26:1: error: incompatible types in PHI argument 0 int void g_95_I_lsm.22_32 = PHI <.MEM_5(5)> gcc.dg/torture/pr51070.c:26:1: internal compiler error: verify_gimple failed Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. I didn't open a new PR because the ICE message is the same and the conditions under which it happens are very similiar. Of course, I will open a new PR if you tell me so.
Confirmed.
Author: rguenth Date: Tue Jan 3 12:07:18 2012 New Revision: 182839 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182839 Log: 2012-01-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/51070 * tree-loop-distribution.c (stmt_has_scalar_dependences_outside_loop): Properly handle calls. * gcc.dg/torture/pr51070-2.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr51070-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-loop-distribution.c
Author: rguenth Date: Tue Jan 3 12:11:41 2012 New Revision: 182840 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182840 Log: 2012-01-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/51070 * tree-loop-distribution.c (generate_builtin): Do not replace the loop with a builtin if the partition contains statements which results are used outside of the loop. (stmt_has_scalar_dependences_outside_loop): Properly handle calls. * gcc.dg/torture/pr51070.c: New testcase. * gcc.dg/torture/pr51070-2.c: Likewise. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070-2.c branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-loop-distribution.c
Fixed.
Author: liujiangning Date: Tue Jun 12 09:44:24 2012 New Revision: 188432 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188432 Log: 2011-06-12 Jiangning Liu <jiangning.liu@arm.com> Backport r182839 from mainline 2012-01-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/51070 * tree-loop-distribution.c (generate_builtin): Do not replace the loop with a builtin if the partition contains statements which results are used outside of the loop. (stmt_has_scalar_dependences_outside_loop): Properly handle calls. 2011-06-12 Jiangning Liu <jiangning.liu@arm.com> Backport r182839 from mainline 2012-01-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/51070 * gcc.dg/torture/pr51070.c: New testcase. * gcc.dg/torture/pr51070-2.c: Likewise. Added: branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070-2.c branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070.c Modified: branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm branches/ARM/embedded-4_6-branch/gcc/tree-loop-distribution.c