Patchwork [22/65] Run rewrite_cross_bb_phi_deps before rewrite_cross_bb_scalar_deps.

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

Comments

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

2010-06-23  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Moved up.
	(rewrite_cross_bb_phi_deps): Split out of rewrite_cross_bb_scalar_deps.
	(rewrite_cross_bb_scalar_deps_out_of_ssa): Run rewrite_cross_bb_phi_deps
	before rewrite_cross_bb_scalar_deps.

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

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6f1a9c6..f12de88 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@ 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Moved up.
+	(rewrite_cross_bb_phi_deps): Split out of rewrite_cross_bb_scalar_deps.
+	(rewrite_cross_bb_scalar_deps_out_of_ssa): Run rewrite_cross_bb_phi_deps
+	before rewrite_cross_bb_scalar_deps.
+
+2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (rewrite_commutative_reductions_out_of_ssa):
 	Early return in when flag_associative_math is not set.
 
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 53c7344..d736895 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,12 @@ 
 2010-06-23  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Moved up.
+	(rewrite_cross_bb_phi_deps): Split out of rewrite_cross_bb_scalar_deps.
+	(rewrite_cross_bb_scalar_deps_out_of_ssa): Run rewrite_cross_bb_phi_deps
+	before rewrite_cross_bb_scalar_deps.
+
+2010-06-23  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (rewrite_commutative_reductions_out_of_ssa):
 	Early return in when flag_associative_math is not set.
 
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 9aa4070..5f99f65 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2272,6 +2272,31 @@  rewrite_phi_out_of_ssa (gimple_stmt_iterator *psi)
   gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT);
 }
 
+/* Rewrite out of SSA all the reduction phi nodes of SCOP.  */
+
+void
+rewrite_reductions_out_of_ssa (scop_p scop)
+{
+  basic_block bb;
+  gimple_stmt_iterator psi;
+  sese region = SCOP_REGION (scop);
+
+  FOR_EACH_BB (bb)
+    if (bb_in_sese_p (bb, region))
+      for (psi = gsi_start_phis (bb); !gsi_end_p (psi);)
+	{
+	  if (scalar_close_phi_node_p (gsi_stmt (psi)))
+	    rewrite_close_phi_out_of_ssa (&psi);
+	  else if (reduction_phi_p (region, &psi))
+	    rewrite_phi_out_of_ssa (&psi);
+	}
+
+  update_ssa (TODO_update_ssa);
+#ifdef ENABLE_CHECKING
+  verify_loop_closed_ssa (true);
+#endif
+}
+
 /* Return true when DEF can be analyzed in REGION by the scalar
    evolution analyzer.  */
 
@@ -2314,16 +2339,16 @@  rewrite_cross_bb_scalar_dependence (tree zero_dim_array, tree def, gimple use_st
 }
 
 /* Rewrite the scalar dependences crossing the boundary of the BB
-   containing STMT with an array.  */
+   containing STMT with an array.  GSI points to a definition that is
+   used in a PHI node.  */
 
 static void
-rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
+rewrite_cross_bb_phi_deps (sese region, gimple_stmt_iterator gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple stmt = gsi_stmt (gsi);
   imm_use_iterator imm_iter;
   tree def;
   basic_block def_bb;
-  tree zero_dim_array = NULL_TREE;
   gimple use_stmt;
 
   if (gimple_code (stmt) != GIMPLE_ASSIGN)
@@ -2342,9 +2367,37 @@  rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
 	gimple_stmt_iterator si = gsi_for_stmt (use_stmt);
 	rewrite_phi_out_of_ssa (&si);
       }
-    else if (def_bb != gimple_bb (use_stmt)
-	     && !is_gimple_debug (use_stmt))
+}
+
+/* Rewrite the scalar dependences crossing the boundary of the BB
+   containing STMT with an array.  */
+
+static void
+rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
+{
+  gimple stmt = gsi_stmt (*gsi);
+  imm_use_iterator imm_iter;
+  tree def;
+  basic_block def_bb;
+  tree zero_dim_array = NULL_TREE;
+  gimple use_stmt;
+
+  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+    return;
+
+  def = gimple_assign_lhs (stmt);
+  if (!is_gimple_reg (def)
+      || scev_analyzable_p (def, region))
+    return;
+
+  def_bb = gimple_bb (stmt);
+
+  FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
+    if (def_bb != gimple_bb (use_stmt)
+	&& !is_gimple_debug (use_stmt))
       {
+	gcc_assert (gimple_code (use_stmt) != GIMPLE_PHI);
+
 	if (!zero_dim_array)
 	  {
 	    zero_dim_array = create_zero_dim_array
@@ -2361,32 +2414,6 @@  rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
 /* Rewrite out of SSA all the reduction phi nodes of SCOP.  */
 
 void
-rewrite_reductions_out_of_ssa (scop_p scop)
-{
-  basic_block bb;
-  gimple_stmt_iterator psi;
-  sese region = SCOP_REGION (scop);
-
-  FOR_EACH_BB (bb)
-    if (bb_in_sese_p (bb, region))
-      for (psi = gsi_start_phis (bb); !gsi_end_p (psi);)
-	{
-	  if (scalar_close_phi_node_p (gsi_stmt (psi)))
-	    rewrite_close_phi_out_of_ssa (&psi);
-	  else if (reduction_phi_p (region, &psi))
-	    rewrite_phi_out_of_ssa (&psi);
-	}
-
-  update_ssa (TODO_update_ssa);
-#ifdef ENABLE_CHECKING
-  verify_loop_closed_ssa (true);
-#endif
-}
-
-
-/* Rewrite out of SSA all the reduction phi nodes of SCOP.  */
-
-void
 rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
 {
   basic_block bb;
@@ -2396,7 +2423,10 @@  rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
   FOR_EACH_BB (bb)
     if (bb_in_sese_p (bb, region))
       for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
-	rewrite_cross_bb_scalar_deps (region, &psi);
+	{
+	  rewrite_cross_bb_phi_deps (region, psi);
+	  rewrite_cross_bb_scalar_deps (region, &psi);
+	}
 
   update_ssa (TODO_update_ssa);
 #ifdef ENABLE_CHECKING