===================================================================
@@ -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;
}
===================================================================
@@ -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;
+}