aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-01-09 13:35:43 +0000
committerRichard Biener <rguenther@suse.de>2018-01-09 13:35:43 +0000
commite0748bdb90921e42718820a69ded43d81e9c3cb4 (patch)
tree87bc765c4b2faf45547a43111b2ab530ff3bfad8
parent01137f2d9a12f20e1427746709510aee42bf694d (diff)
2018-01-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/83668 * graphite.c (canonicalize_loop_closed_ssa): Add edge argument, move prologue... (canonicalize_loop_form): ... here, renamed from ... (canonicalize_loop_closed_ssa_form): ... this and amended to swap successor edges for loop exit blocks to make us use the RPO order we need for initial schedule generation. * gcc.dg/graphite/pr83668.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@256381 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/graphite.c32
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/graphite/pr83668.c34
4 files changed, 73 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 24fd1b4187f..f908b7cc2cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2018-01-09 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/83668
+ * graphite.c (canonicalize_loop_closed_ssa): Add edge argument,
+ move prologue...
+ (canonicalize_loop_form): ... here, renamed from ...
+ (canonicalize_loop_closed_ssa_form): ... this and amended to
+ swap successor edges for loop exit blocks to make us use
+ the RPO order we need for initial schedule generation.
+
2018-01-09 Joseph Myers <joseph@codesourcery.com>
PR tree-optimization/64811
diff --git a/gcc/graphite.c b/gcc/graphite.c
index e5f318d44fd..3b7f46bebd6 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -227,15 +227,11 @@ free_scops (vec<scop_p> scops)
/* Transforms LOOP to the canonical loop closed SSA form. */
static void
-canonicalize_loop_closed_ssa (loop_p loop)
+canonicalize_loop_closed_ssa (loop_p loop, edge e)
{
- edge e = single_exit (loop);
basic_block bb;
gphi_iterator psi;
- if (!e || (e->flags & EDGE_COMPLEX))
- return;
-
bb = e->dest;
/* Make the loop-close PHI node BB contain only PHIs and have a
@@ -314,14 +310,34 @@ canonicalize_loop_closed_ssa (loop_p loop)
other statements.
- there exist only one phi node per definition in the loop.
+
+ In addition to that we also make sure that loop exit edges are
+ first in the successor edge vector. This is to make RPO order
+ as computed by pre_and_rev_post_order_compute be consistent with
+ what initial schedule generation expects.
*/
static void
-canonicalize_loop_closed_ssa_form (void)
+canonicalize_loop_form (void)
{
loop_p loop;
FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
- canonicalize_loop_closed_ssa (loop);
+ {
+ edge e = single_exit (loop);
+ if (!e || (e->flags & EDGE_COMPLEX))
+ continue;
+
+ canonicalize_loop_closed_ssa (loop, e);
+
+ /* If the exit is not first in the edge vector make it so. */
+ if (e != EDGE_SUCC (e->src, 0))
+ {
+ unsigned ei;
+ for (ei = 0; EDGE_SUCC (e->src, ei) != e; ++ei)
+ ;
+ std::swap (EDGE_SUCC (e->src, ei), EDGE_SUCC (e->src, 0));
+ }
+ }
/* We can end up releasing duplicate exit PHIs and also introduce
additional copies so the cached information isn't correct anymore. */
@@ -360,7 +376,7 @@ graphite_transform_loops (void)
the_isl_ctx = ctx;
sort_sibling_loops (cfun);
- canonicalize_loop_closed_ssa_form ();
+ canonicalize_loop_form ();
/* Print the loop structure. */
if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 679b22a68d4..bbf9c760647 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-09 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/83668
+ * gcc.dg/graphite/pr83668.c: New testcase.
+
2018-01-09 Joseph Myers <joseph@codesourcery.com>
PR tree-optimization/64811
diff --git a/gcc/testsuite/gcc.dg/graphite/pr83668.c b/gcc/testsuite/gcc.dg/graphite/pr83668.c
new file mode 100644
index 00000000000..22b01b8c4ae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr83668.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O -fno-tree-dominator-opts -fgraphite-identity" } */
+
+int a, b, c;
+int d[14];
+
+int
+main (void)
+{
+ short e;
+ char f;
+
+ for (; b >= 0; b--)
+ {
+ e = 0;
+ for (; e < 2; e++)
+ {
+ a = 0;
+ for (; a < 7; a++)
+ d[a] = 1;
+ }
+ if (c)
+ {
+ f = 0;
+ for (; f >= 0; f--)
+ ;
+ }
+ }
+
+ if (a != 7)
+ __builtin_abort ();
+
+ return 0;
+}