re PR rtl-optimization/56466 (ICE in verify_loop_structure, at cfgloop.c:1629 (loop...
authorMarek Polacek <polacek@redhat.com>
Thu, 28 Feb 2013 10:13:48 +0000 (10:13 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 28 Feb 2013 10:13:48 +0000 (10:13 +0000)
        PR rtl-optimization/56466
        * loop-unroll.c (unroll_and_peel_loops): Call fix_loop_structure
        if we're changing a loop.
        (peel_loops_completely): Likewise.

From-SVN: r196335

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

index 7bda77ed87d4968c624d3c5cc5a796641af4a6af..5ecbe51f4c2798729332df4b527ad2580da9a1d6 100644 (file)
@@ -1,3 +1,10 @@
+2013-02-28  Marek Polacek  <polacek@redhat.com>
+
+       PR rtl-optimization/56466
+       * loop-unroll.c (unroll_and_peel_loops): Call fix_loop_structure
+       if we're changing a loop.
+       (peel_loops_completely): Likewise.
+
 2013-02-28  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/55813
index 42512b8d9786e1cfbf7daede49b0b24c72eb1efc..1eb904b5061aeb11327c12d9d05c7da525d4b2ef 100644 (file)
@@ -207,7 +207,7 @@ void
 unroll_and_peel_loops (int flags)
 {
   struct loop *loop;
-  bool check;
+  bool changed = false;
   loop_iterator li;
 
   /* First perform complete loop peeling (it is almost surely a win,
@@ -220,7 +220,6 @@ unroll_and_peel_loops (int flags)
   /* Scan the loops, inner ones first.  */
   FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
     {
-      check = true;
       /* And perform the appropriate transformations.  */
       switch (loop->lpt_decision.decision)
        {
@@ -229,30 +228,33 @@ unroll_and_peel_loops (int flags)
          gcc_unreachable ();
        case LPT_PEEL_SIMPLE:
          peel_loop_simple (loop);
+         changed = true;
          break;
        case LPT_UNROLL_CONSTANT:
          unroll_loop_constant_iterations (loop);
+         changed = true;
          break;
        case LPT_UNROLL_RUNTIME:
          unroll_loop_runtime_iterations (loop);
+         changed = true;
          break;
        case LPT_UNROLL_STUPID:
          unroll_loop_stupid (loop);
+         changed = true;
          break;
        case LPT_NONE:
-         check = false;
          break;
        default:
          gcc_unreachable ();
        }
-      if (check)
-       {
-#ifdef ENABLE_CHECKING
-         verify_loop_structure ();
-#endif
-       }
     }
 
+    if (changed)
+      {
+       calculate_dominance_info (CDI_DOMINATORS);
+       fix_loop_structure (NULL);
+      }
+
   iv_analysis_done ();
 }
 
@@ -283,6 +285,7 @@ peel_loops_completely (int flags)
 {
   struct loop *loop;
   loop_iterator li;
+  bool changed = false;
 
   /* Scan the loops, the inner ones first.  */
   FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
@@ -306,11 +309,15 @@ peel_loops_completely (int flags)
        {
          report_unroll_peel (loop, locus);
          peel_loop_completely (loop);
-#ifdef ENABLE_CHECKING
-         verify_loop_structure ();
-#endif
+         changed = true;
        }
     }
+
+    if (changed)
+      {
+       calculate_dominance_info (CDI_DOMINATORS);
+       fix_loop_structure (NULL);
+      }
 }
 
 /* Decide whether unroll or peel loops (depending on FLAGS) and how much.  */
index cfc7156569f2067eb325b66a883668dd68a611e7..40d6a80fa8d6c5563e4c2b1b92baa6da8566b3cc 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-27  Marek Polacek  <polacek@redhat.com>
+
+       PR rtl-optimization/56466
+       * gcc.dg/pr56466.c: New test.
+
 2013-02-28  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
        * gcc.dg/tree-ssa/slsr-1.c: Allow widening multiplications.
diff --git a/gcc/testsuite/gcc.dg/pr56466.c b/gcc/testsuite/gcc.dg/pr56466.c
new file mode 100644 (file)
index 0000000..9d9e273
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/56466 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -w -funroll-loops" } */
+
+int a, b, c;
+
+void
+f (void)
+{
+  for (; b; b++)
+    {
+      if (0)
+       for (; b < 0; b++)
+         if (1 % 0)
+           {
+             while (1)
+               {
+                 a = 0;
+               lbl1:
+                 c++;
+               }
+           lbl2:
+             ;
+           }
+
+      goto lbl1;
+    }
+
+  a = 0;
+  goto lbl2;
+}