[PATCH] Fix PR87169
Richard Biener
rguenther@suse.de
Mon Sep 3 13:26:00 GMT 2018
Bootstrapped and tested on x86_64-unkown-linux-gnu, applied.
Richard.
2018-09-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/87169
* tree-ssa-sccvn.c (do_rpo_vn): When marking loops for not
iterating make sure there's no extra backedges from irreducible
regions feeding the header. Mark the destination block
executable.
* gcc.dg/torture/pr87169.c: New testcase.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 264052)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -6360,12 +6360,28 @@ do_rpo_vn (function *fn, edge entry, bit
i < loop_depth (loop) - max_depth; ++i)
{
basic_block header = superloop_at_depth (loop, i)->header;
- rpo_state[bb_to_rpo[header->index]].iterate = false;
+ bool non_latch_backedge = false;
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, header->preds)
if (e->flags & EDGE_DFS_BACK)
- e->flags |= EDGE_EXECUTABLE;
+ {
+ e->flags |= EDGE_EXECUTABLE;
+ e->dest->flags |= BB_EXECUTABLE;
+ /* There can be a non-latch backedge into the header
+ which is part of an outer irreducible region. We
+ cannot avoid iterating this block then. */
+ if (!dominated_by_p (CDI_DOMINATORS,
+ e->src, e->dest))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "non-latch backedge %d -> %d "
+ "forces iteration of loop %d\n",
+ e->src->index, e->dest->index, loop->num);
+ non_latch_backedge = true;
+ }
+ }
+ rpo_state[bb_to_rpo[header->index]].iterate = non_latch_backedge;
}
}
Index: gcc/testsuite/gcc.dg/torture/pr87169.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr87169.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr87169.c (working copy)
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-additional-options "--param rpo-vn-max-loop-depth=7" } */
+
+int a, b, c;
+
+int main ()
+{
+ int d;
+ b = 1;
+L1:
+ for (; b > 1;)
+ goto L2;
+ {
+ int e[1];
+L3:;
+ }
+L2:
+ while (a)
+ {
+ d--;
+ goto L1;
+ }
+ while (c)
+ {
+ if (a)
+ goto L3;
+ if (a)
+ break;
+ if (a)
+ goto L2;
+ while (c)
+ while (c)
+ while (c)
+ while (c)
+ while (c)
+ while (c)
+ while (c)
+ ;
+ }
+ return 0;
+}
More information about the Gcc-patches
mailing list