Valgrind wasn't too helpful in narrowing this down, just says something generic about a stack overflow. [regehr@gamow tmp052]$ current-gcc -Ofast -w small.c current-gcc: internal compiler error: Segmentation fault (program cc1) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [regehr@gamow tmp052]$ current-gcc -v Using built-in specs. COLLECT_GCC=current-gcc COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r181147-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-r181147-install --program-prefix=r181147- --enable-languages=c,c++ Thread model: posix gcc version 4.7.0 20111108 (experimental) (GCC) [regehr@gamow tmp052]$ cat small.c int g_10; int g_97; int g_144; int g_237; int g_264[2][2]; int func_22 (p_25) { for (; p_25;) { for (g_237 = 0; g_237 <= 1; g_237 = 1) if (g_264[g_144][g_10]) break; for (g_97 = 0; g_97 <= 0; g_97 = 1) { g_264[g_144][g_10] = g_10; if (g_10) break; } } return 0; }
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155360 int a, b, c, d, e[2][2]; void foo (int x) { while (x) { for (d = 0; d <= 1; d = 1) if (e[c][a]) break; for (b = 0; b <= 0; b = 1) { e[c][a] = a; if (a) break; } } }
Mine.
Even shorter testcase: int a, b; void foo (int x) { int e[2]; int d; while (x) { for (d = 0; d <= 1; d = 1) if (e[a]) break; for (b = 0; b <= 0; b = 1) { e[a] = a; if (a) break; } } }
The clean () code does not work properly for memory references it seems. We fail to prune expressions that are not available (the tricks we play with dominance tests for virtual operands are not effective once we translate them).
Of course in principle the issue is that an SSA name can have an expression leader that references the SSA name itself.
Author: rguenth Date: Thu Nov 10 15:28:57 2011 New Revision: 181256 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181256 Log: 2011-11-10 Richard Guenther <rguenther@suse.de> PR tree-optimization/51042 * tree-ssa-pre.c (phi_translate_1): Avoid recursing on self-referential expressions. Refactor code to avoid duplication. * gcc.dg/torture/pr51042.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr51042.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-pre.c
Fixed on trunk sofar.
Author: rguenth Date: Tue Jan 3 14:46:03 2012 New Revision: 182848 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182848 Log: 2012-01-03 Richard Guenther <rguenther@suse.de> Backport from mainline 2011-11-10 Richard Guenther <rguenther@suse.de> PR tree-optimization/51042 * tree-ssa-pre.c (phi_translate_1): Avoid recursing on self-referential expressions. Refactor code to avoid duplication. * gcc.dg/torture/pr51042.c: New testcase. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51042.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-ssa-pre.c
Author: liujiangning Date: Tue Jun 12 09:53:53 2012 New Revision: 188433 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188433 Log: 2011-06-12 Jiangning Liu <jiangning.liu@arm.com> Backport r181256 from mainline 2011-11-10 Richard Guenther <rguenther@suse.de> PR tree-optimization/51042 * tree-ssa-pre.c (phi_translate_1): Avoid recursing on self-referential expressions. Refactor code to avoid duplication. 2011-06-12 Jiangning Liu <jiangning.liu@arm.com> Backport r181256 from mainline 2011-11-10 Richard Guenther <rguenther@suse.de> Added: branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51042.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-ssa-pre.c
Fixed in 4.6.3.