Bug 27335 - [4.0/4.1 regression] ICE in get_loop_body
Summary: [4.0/4.1 regression] ICE in get_loop_body
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.1
: P3 major
Target Milestone: 4.0.4
Assignee: Zdenek Dvorak
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2006-04-27 08:55 UTC by Jakub Jelinek
Modified: 2006-05-13 22:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 4.2.0
Known to fail: 4.0.0 4.1.0 4.2.0
Last reconfirmed: 2006-05-05 12:16:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2006-04-27 08:55:50 UTC
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.
Comment 1 Richard Biener 2006-04-27 09:38:21 UTC
Confirmed.  Also with -O -funroll-loops (or -fpeel-loops, or -fprofile-use).
Comment 2 Richard Biener 2006-04-27 09:44:21 UTC
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.
Comment 3 Andrew Pinski 2006-04-30 05:55:08 UTC
-O1 -funroll-loops crashes on the mainline (though -O2 -funroll-loops passes).
Comment 4 Zdenek Dvorak 2006-05-08 17:33:05 UTC
Patch: http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00308.html
Comment 5 Zdenek Dvorak 2006-05-09 09:10:35 UTC
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

Comment 6 Andrew Pinski 2006-05-09 15:22:03 UTC
Fixed at least on the mainline.
Comment 7 Zdenek Dvorak 2006-05-13 22:11:20 UTC
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

Comment 8 Zdenek Dvorak 2006-05-13 22:12:21 UTC
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

Comment 9 Andrew Pinski 2006-05-13 22:16:57 UTC
Fixed.