re PR rtl-optimization/27335 (ICE in get_loop_body)
authorZdenek Dvorak <dvorakz@suse.cz>
Tue, 9 May 2006 09:10:15 +0000 (11:10 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Tue, 9 May 2006 09:10:15 +0000 (09:10 +0000)
PR rtl-optimization/27335
* loop-unroll.c (peel_loops_completely): Use loops->parray to walk the
loops.

* gcc.dg/pr27335.c: New test.

From-SVN: r113648

gcc/ChangeLog
gcc/loop-unroll.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr27335.c [new file with mode: 0644]

index d245c389e7cd0f3a33c052b8071083cd523c8dfd..c1896d9d9b1b9f740900e1173e577ae0527df412 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-09  Zdenek Dvorak <dvorakz@suse.cz>
+
+       PR rtl-optimization/27335
+       * loop-unroll.c (peel_loops_completely): Use loops->parray to walk the
+       loops.
+
 2006-05-08  Chao-ying Fu  <fu@mips.com>
            Richard Sandiford  <richard@codesourcery.com>
 
index 5c28eaf2f19a93687f25a39061ef67659db5be31..156f688651e4184f789d89476ab5b424bc2d78ff 100644 (file)
@@ -233,22 +233,15 @@ loop_exit_at_end_p (struct loop *loop)
 static void
 peel_loops_completely (struct loops *loops, int flags)
 {
-  struct loop *loop, *next;
-
-  loop = loops->tree_root;
-  while (loop->inner)
-    loop = loop->inner;
+  struct loop *loop;
+  unsigned i;
 
-  while (loop != loops->tree_root)
+  /* Scan the loops, the inner ones first.  */
+  for (i = loops->num - 1; i > 0; i--)
     {
-      if (loop->next)
-       {
-         next = loop->next;
-         while (next->inner)
-           next = next->inner;
-       }
-      else
-       next = loop->outer;
+      loop = loops->parray[i];
+      if (!loop)
+       continue;
 
       loop->lpt_decision.decision = LPT_NONE;
 
@@ -271,7 +264,6 @@ peel_loops_completely (struct loops *loops, int flags)
          verify_loop_structure (loops);
 #endif
        }
-      loop = next;
     }
 }
 
index 32927ff4edb53957d09d2af14127db80b1ee23a9..a3f49f7974c3f1717aa04c528d9b3e8143e198bc 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-09  Zdenek Dvorak <dvorakz@suse.cz>
+
+       PR rtl-optimization/27335
+       * gcc.dg/pr27335.c: New test.
+
 2006-05-06  Richard Sandiford  <richard@codesourcery.com>
 
        * gcc.target/mips/mips-ps-5.c: New file.
diff --git a/gcc/testsuite/gcc.dg/pr27335.c b/gcc/testsuite/gcc.dg/pr27335.c
new file mode 100644 (file)
index 0000000..d08db30
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops" } */
+
+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);
+      }
+}