new file mode 100644
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+int a, *b = &a, c, d;
+int main() {
+ *b;
+ if (a) {
+ L1:
+ a = 0;
+ L2:
+ if (d) {
+ while (b)
+ ;
+ goto L1;
+ }
+ }
+ if (c)
+ goto L2;
+ return 0;
+}
@@ -398,7 +398,14 @@ statement_sink_location (gimple *stmt, basic_block frombb,
&& dominated_by_p (CDI_POST_DOMINATORS, commondom, bb)
/* If the blocks are possibly within the same irreducible
cycle the above check breaks down. */
- && !(bb->flags & commondom->flags & BB_IRREDUCIBLE_LOOP))
+ && !((bb->flags & commondom->flags & BB_IRREDUCIBLE_LOOP)
+ && bb->loop_father == commondom->loop_father)
+ && !((commondom->flags & BB_IRREDUCIBLE_LOOP)
+ && flow_loop_nested_p (commondom->loop_father,
+ bb->loop_father))
+ && !((bb->flags & BB_IRREDUCIBLE_LOOP)
+ && flow_loop_nested_p (bb->loop_father,
+ commondom->loop_father)))
continue;
bb = EDGE_PRED (bb, PHI_ARG_INDEX_FROM_USE (use_p))->src;
}