Patchwork [2/5] Do not translate out-of-SSA close phi nodes that can be analyzed with scev.

login
register
mail settings
Submitter Sebastian Pop
Date July 20, 2010, 8:23 p.m.
Message ID <1279657422-17300-2-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/59365/
State New
Headers show

Comments

Sebastian Pop - July 20, 2010, 8:23 p.m.
2010-07-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Add an
	extra parameter for the region.  Call scev_analyzable_p.
	(rewrite_reductions_out_of_ssa): Update call to
	rewrite_close_phi_out_of_ssa.
	(rewrite_cross_bb_phi_deps): Same.
	(rewrite_commutative_reductions_out_of_ssa_loop): Add an extra
	parameter for the region.  Call scev_analyzable_p.
	(rewrite_commutative_reductions_out_of_ssa): Update call to
	rewrite_commutative_reductions_out_of_ssa_loop.
---
 gcc/ChangeLog.graphite      |   12 ++++++++++++
 gcc/graphite-sese-to-poly.c |   24 +++++++++++++++++-------
 2 files changed, 29 insertions(+), 7 deletions(-)

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 6f2ea96..f6e077a 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,17 @@ 
 2010-07-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Add an
+	extra parameter for the region.  Call scev_analyzable_p.
+	(rewrite_reductions_out_of_ssa): Update call to
+	rewrite_close_phi_out_of_ssa.
+	(rewrite_cross_bb_phi_deps): Same.
+	(rewrite_commutative_reductions_out_of_ssa_loop): Add an extra
+	parameter for the region.  Call scev_analyzable_p.
+	(rewrite_commutative_reductions_out_of_ssa): Update call to
+	rewrite_commutative_reductions_out_of_ssa_loop.
+
+2010-07-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* gcc.dg/tree-ssa/pr20742.c: New.
 
 2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index c08a4f2..2c85515 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2185,7 +2185,7 @@  scalar_close_phi_node_p (gimple phi)
    dimension array for it.  */
 
 static void
-rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi)
+rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi, sese region)
 {
   gimple phi = gsi_stmt (*psi);
   tree res = gimple_phi_result (phi);
@@ -2200,6 +2200,14 @@  rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi)
      before Graphite: see canonicalize_loop_closed_ssa_form.  */
   gcc_assert (gimple_phi_num_args (phi) == 1);
 
+  /* If res is scev analyzable, it is safe to ignore the close phi
+     node: it will be code generated in the out of Graphite pass.  */
+  if (scev_analyzable_p (res, region))
+    {
+      gsi_next (psi);
+      return;
+    }
+
   /* The phi node can be a non close phi node, when its argument is
      invariant, or when it is defined in the same loop as the phi node.  */
   if (is_gimple_min_invariant (arg)
@@ -2320,7 +2328,7 @@  rewrite_reductions_out_of_ssa (scop_p scop)
 	    rewrite_degenerate_phi (&psi);
 
 	  else if (scalar_close_phi_node_p (phi))
-	    rewrite_close_phi_out_of_ssa (&psi);
+	    rewrite_close_phi_out_of_ssa (&psi, region);
 
 	  else if (reduction_phi_p (region, &psi))
 	    rewrite_phi_out_of_ssa (&psi);
@@ -2385,7 +2393,7 @@  rewrite_cross_bb_phi_deps (sese region, gimple_stmt_iterator gsi)
 	gimple_stmt_iterator psi = gsi_for_stmt (use_stmt);
 
 	if (scalar_close_phi_node_p (gsi_stmt (psi)))
-	  rewrite_close_phi_out_of_ssa (&psi);
+	  rewrite_close_phi_out_of_ssa (&psi, region);
 	else
 	  rewrite_phi_out_of_ssa (&psi);
       }
@@ -2870,7 +2878,8 @@  rewrite_commutative_reductions_out_of_ssa_close_phi (gimple close_phi,
 
 static void
 rewrite_commutative_reductions_out_of_ssa_loop (loop_p loop,
-						sbitmap reductions)
+						sbitmap reductions,
+						sese region)
 {
   gimple_stmt_iterator gsi;
   edge exit = single_exit (loop);
@@ -2879,8 +2888,9 @@  rewrite_commutative_reductions_out_of_ssa_loop (loop_p loop,
     return;
 
   for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    rewrite_commutative_reductions_out_of_ssa_close_phi (gsi_stmt (gsi),
-							 reductions);
+    if (!scev_analyzable_p (gimple_phi_result (gsi_stmt (gsi)), region))
+      rewrite_commutative_reductions_out_of_ssa_close_phi (gsi_stmt (gsi),
+							   reductions);
 }
 
 /* Rewrites all the commutative reductions from SCOP out of SSA.  */
@@ -2896,7 +2906,7 @@  rewrite_commutative_reductions_out_of_ssa (sese region, sbitmap reductions)
 
   FOR_EACH_LOOP (li, loop, 0)
     if (loop_in_sese_p (loop, region))
-      rewrite_commutative_reductions_out_of_ssa_loop (loop, reductions);
+      rewrite_commutative_reductions_out_of_ssa_loop (loop, reductions, region);
 
   gsi_commit_edge_inserts ();
   update_ssa (TODO_update_ssa);