+++ This bug was initially created as a clone of Bug #46755 +++ PR46755#c8 is unrelated bug to the original one, so creating a separate PR for it: Not sure if this is still useful, but here's a fairly small failure-inducing testcase for this bug for today's GCC. [regehr@gamow tmp437]$ current-gcc -O2 -c small.c small.c: In function 'func': small.c:32:1: internal compiler error: in calc_dfs_tree, at dominance.c:395 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [regehr@gamow tmp437]$ current-gcc -v Using built-in specs. COLLECT_GCC=current-gcc COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r168402-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.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-r168402-install --program-prefix=r168402- --enable-languages=c,c++ Thread model: posix gcc version 4.6.0 20110102 (experimental) (GCC) [regehr@gamow tmp437]$ cat small.c static int foo (int si1, short si2) { return ((si1 ^ si2) & ((si1 ^ (si1 ^ si2) & ~2147483647) - si2 ^ si2)) < 0 ? si1 : si1 - si2; } struct S0 { const unsigned f3:1; const unsigned f8:1; }; struct S0 g_111 = { 1 }; struct S0 g_139 = { 1 }; unsigned long int g_22; void safe (int); int func_42 (void); void func (void) { safe (foo (func_42 () != (g_139.f3 | g_111.f8), -1L)); for (g_22 = 0; g_22; g_22 = 1) { } } This is caused by revision 164431: http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00727.html
Created attachment 22885 [details] gcc46-pr47157.patch Untested fix.
Author: jakub Date: Mon Jan 3 20:59:20 2011 New Revision: 168439 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168439 Log: PR rtl-optimization/47157 * combine.c (try_combine): If undobuf.other_insn becomes (set (pc) (pc)) jump, call update_cfg_for_uncondjump on it and set *new_direct_jump_p too. * gcc.c-torture/compile/pr47157.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr47157.c Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c trunk/gcc/testsuite/ChangeLog
Fixed.