https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61438
Bug ID: 61438 Summary: ICE on valid code at -O3 on x86_64-linux-gnu in in loop_preheader_edge, at cfgloop.c:1668 Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The following code causes an ICE when compiled with the current gcc trunk at -O3 on x86_64-linux-gnu in both 32-bit and 64-bit modes. It is a regression from 4.9.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.10.0 20140606 (experimental) [trunk revision 211322] (GCC) $ $ gcc-trunk -O2 small.c; a.out $ gcc-4.9.0 -O3 small.c; a.out $ $ gcc-trunk -O3 small.c small.c: In function ‘foo’: small.c:12:1: internal compiler error: in loop_preheader_edge, at cfgloop.c:1668 foo () ^ 0x62e9ce loop_preheader_edge(loop const*) ../../gcc-trunk/gcc/cfgloop.c:1668 0xa3a6e0 block_before_loop ../../gcc-trunk/gcc/tree-scalar-evolution.h:48 0xa3a6e0 analyze_scalar_evolution(loop*, tree_node*) ../../gcc-trunk/gcc/tree-scalar-evolution.c:2042 0xa3b9ea analyze_scalar_evolution_in_loop ../../gcc-trunk/gcc/tree-scalar-evolution.c:2139 0xa3bb4f simple_iv(loop*, loop*, tree_node*, affine_iv*, bool) ../../gcc-trunk/gcc/tree-scalar-evolution.c:3244 0xae08a9 eliminate_dom_walker::before_dom_children(basic_block_def*) ../../gcc-trunk/gcc/tree-ssa-pre.c:4217 0xe94927 dom_walker::walk(basic_block_def*) ../../gcc-trunk/gcc/domwalk.c:177 0xadd372 eliminate ../../gcc-trunk/gcc/tree-ssa-pre.c:4451 0xadd7c3 execute ../../gcc-trunk/gcc/tree-ssa-pre.c:4867 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ --------------------------------- #include <assert.h> int a, c, **d, e, g; static int b = 1; struct { int f0; } f; void foo () { int h, *i = &a; for (; e;) { for (c = 0; c < 1; c++) for (; b;) ; for (;;) { if (a) { for (; f.f0; f.f0++) ; if (g) break; } for (h = 0; h < 2; h++) { i = *d; assert (i); } } } assert (i); } int main () { foo (); return 0; }