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

login
register
mail settings
Submitter Sebastian Pop
Date Aug. 2, 2010, 8:20 p.m.
Message ID <1280780438-17543-48-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/60646/
State New
Headers show

Comments

Sebastian Pop - Aug. 2, 2010, 8:20 p.m.
From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>

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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@162351 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog               |   12 ++++++++++++
 gcc/ChangeLog.graphite      |   12 ++++++++++++
 gcc/graphite-sese-to-poly.c |   24 +++++++++++++++++-------
 3 files changed, 41 insertions(+), 7 deletions(-)

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 29efa29..1fa3f50 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,17 @@ 
 2010-08-02  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-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* sese.c (rename_uses): Call unshare_expr before force_gimple_operand.
 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 5e36bc3..24c88d5 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 7244ba9..81b2dc2 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2186,7 +2186,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);
@@ -2201,6 +2201,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)
@@ -2321,7 +2329,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);
@@ -2386,7 +2394,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);
       }
@@ -2871,7 +2879,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);
@@ -2880,8 +2889,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.  */
@@ -2897,7 +2907,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);