re PR tree-optimization/57122 (ICE in verify_loop_structure, at cfgloop.c:1647 (loop...
authorRichard Biener <rguenther@suse.de>
Tue, 30 Apr 2013 15:03:58 +0000 (15:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 30 Apr 2013 15:03:58 +0000 (15:03 +0000)
2013-04-30  Richard Biener  <rguenther@suse.de>

PR middle-end/57122
* cfghooks.c (split_edge): Properly check for the loop
latch edge.

* gcc.dg/torture/pr57122.c: New testcase.

From-SVN: r198456

gcc/ChangeLog
gcc/cfghooks.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr57122.c [new file with mode: 0644]

index bb86d6e8e303b446602e9011402fbe216a06271b..02b77f9c612a931b98db24a27a3a5a09c952582c 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-30  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/57122
+       * cfghooks.c (split_edge): Properly check for the loop
+       latch edge.
+
 2013-04-30  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/57107
index f583b2fcc39ac163e0a55b3ebfeeaa05c90f94f3..22b962b52b1fec196b2f1ad72224dd26808d4cbd 100644 (file)
@@ -662,7 +662,9 @@ split_edge (edge e)
       loop = find_common_loop (src->loop_father, dest->loop_father);
       add_bb_to_loop (ret, loop);
 
-      if (loop->latch == src)
+      /* If we split the latch edge of loop adjust the latch block.  */
+      if (loop->latch == src
+         && loop->header == dest)
        loop->latch = ret;
     }
 
index 0d5705a60ed28eaf4acb06645fa0d82ce760dfbc..ae111b265c888489e5403318d7fbbb66c952360a 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-30  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/57122
+       * gcc.dg/torture/pr57122.c: New testcase.
+
 2013-04-30  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/57107
diff --git a/gcc/testsuite/gcc.dg/torture/pr57122.c b/gcc/testsuite/gcc.dg/torture/pr57122.c
new file mode 100644 (file)
index 0000000..f1b99c8
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+
+unsigned a;
+int b, c;
+
+void f(void)
+{
+  if(a)
+    {
+      for(a = 0; a < 2; a++)
+       a /= 7;
+
+      for(;; a++)
+       {
+         if(a)
+           lbl1:
+               b++;
+
+         if(c)
+           goto lbl1;
+lbl2:
+         ;
+       }
+    }
+
+  goto lbl2;
+}