extern void bar () __attribute__ ((noreturn)); inline double baz (double *x, unsigned int y) { if (y >= 6) bar (); return x[y]; } double *a, *b; void foo () { unsigned int r, s, t; for (r = 0; r < 2; r++) for (t = 0; t < 2; t++) { for (s = 0; s < 3; s++) b[r * 2 + t] += baz (a, 3 * s + t); } } ICEs with -O2 -funroll-loops in get_loop_body, loop->num_nodes is 0.
Confirmed. Also with -O -funroll-loops (or -fpeel-loops, or -fprofile-use).
Note that loop information looks corrupt: (gdb) print *loop $2 = {num = 144085752, header = 0xb7fbb178, latch = 0xb7e4c3c0, lpt_decision = {decision = LPT_NONE, times = 0}, ninsns = 0, av_ninsns = 0, num_nodes = 0, depth = -1, pred = 0x0, level = 2, outer = 0x0, inner = 0x0, next = 0x0, copy = 0x0, aux = 0x0, nb_iterations = 0x0, estimated_nb_iterations = 0x69, bounds = 0xb7fbb178, single_exit = 0x8948888, parallel_p = 1 '\001'} (gdb) print *loop->header $3 = {stmt_list = 0x0, preds = 0x0, succs = 0x896ad70, aux = 0x8948888, loop_father = 0x896d608, dom = {0x896d608, 0xb7fbb188}, prev_bb = 0xb7fbb188, next_bb = 0xb7fbb190, il = {rtl = 0xb7fbb190}, phi_nodes = 0x896d750, predictions = 0x8947938, count = -5189358841774755424, index = -1208241752, loop_depth = -1208241752, frequency = -1208241744, flags = -1208241744} The loop walking in peel_loops_completely looks bogus, as we're modifying the loop tree.
-O1 -funroll-loops crashes on the mainline (though -O2 -funroll-loops passes).
Patch: http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00308.html
Subject: Bug 27335 Author: rakdver Date: Tue May 9 09:10:15 2006 New Revision: 113648 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113648 Log: PR rtl-optimization/27335 * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the loops. * gcc.dg/pr27335.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr27335.c Modified: trunk/gcc/ChangeLog trunk/gcc/loop-unroll.c trunk/gcc/testsuite/ChangeLog
Fixed at least on the mainline.
Subject: Bug 27335 Author: rakdver Date: Sat May 13 22:10:56 2006 New Revision: 113746 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113746 Log: PR rtl-optimization/27335 * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the loops. * gcc.dg/pr27335.c: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr27335.c Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/loop-unroll.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Subject: Bug 27335 Author: rakdver Date: Sat May 13 22:12:13 2006 New Revision: 113747 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113747 Log: PR rtl-optimization/27335 * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the loops. * gcc.dg/pr27335.c: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr27335.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/loop-unroll.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed.