Patchwork [55/65] Fix tonto: call propagate_expr_outside_region.

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

Comments

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

2010-07-26  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-sese-to-poly.c (propagate_expr_outside_region): Also
	handle the case when def is in the sese region.
	(rewrite_close_phi_out_of_ssa): Call propagate_expr_outside_region
	for invariant expressions.
	(rewrite_cross_bb_phi_deps): Removed.
	(rewrite_cross_bb_scalar_deps): Also handle GIMPLE_PHI nodes.
	(rewrite_cross_bb_scalar_deps_out_of_ssa): Do not call
	rewrite_cross_bb_phi_deps.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@162556 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog               |   11 +++++++
 gcc/ChangeLog.graphite      |   11 +++++++
 gcc/graphite-sese-to-poly.c |   64 ++++++++++++++-----------------------------
 3 files changed, 43 insertions(+), 43 deletions(-)
H.J. Lu - Oct. 26, 2010, 6:20 p.m.
On Mon, Aug 2, 2010 at 1:20 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> From: spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
>
> 2010-07-26  Sebastian Pop  <sebastian.pop@amd.com>
>
>        * graphite-sese-to-poly.c (propagate_expr_outside_region): Also
>        handle the case when def is in the sese region.
>        (rewrite_close_phi_out_of_ssa): Call propagate_expr_outside_region
>        for invariant expressions.
>        (rewrite_cross_bb_phi_deps): Removed.
>        (rewrite_cross_bb_scalar_deps): Also handle GIMPLE_PHI nodes.
>        (rewrite_cross_bb_scalar_deps_out_of_ssa): Do not call
>        rewrite_cross_bb_phi_deps.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46185

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0f07a8b..976ccf2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,16 @@ 
 2010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (propagate_expr_outside_region): Also
+	handle the case when def is in the sese region.
+	(rewrite_close_phi_out_of_ssa): Call propagate_expr_outside_region
+	for invariant expressions.
+	(rewrite_cross_bb_phi_deps): Removed.
+	(rewrite_cross_bb_scalar_deps): Also handle GIMPLE_PHI nodes.
+	(rewrite_cross_bb_scalar_deps_out_of_ssa): Do not call
+	rewrite_cross_bb_phi_deps.2
+
+010-08-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c
 	(rewrite_commutative_reductions_out_of_ssa_loop): Call
 	scev_analyzable_p only on is_gimple_reg
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 65607ec..cf0bd6b 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,16 @@ 
 2010-07-26  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (propagate_expr_outside_region): Also
+	handle the case when def is in the sese region.
+	(rewrite_close_phi_out_of_ssa): Call propagate_expr_outside_region
+	for invariant expressions.
+	(rewrite_cross_bb_phi_deps): Removed.
+	(rewrite_cross_bb_scalar_deps): Also handle GIMPLE_PHI nodes.
+	(rewrite_cross_bb_scalar_deps_out_of_ssa): Do not call
+	rewrite_cross_bb_phi_deps.
+
+2010-07-26  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c
 	(rewrite_commutative_reductions_out_of_ssa_loop): Call
 	scev_analyzable_p only on is_gimple_reg
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index ae8518f..f92c97e 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2193,8 +2193,7 @@  propagate_expr_outside_region (tree def, tree expr, sese region)
   gimple_seq stmts;
   bool replaced_once = false;
 
-  gcc_assert (TREE_CODE (def) == SSA_NAME
-	      && bb_in_sese_p (gimple_bb (SSA_NAME_DEF_STMT (def)), region));
+  gcc_assert (TREE_CODE (def) == SSA_NAME);
 
   expr = force_gimple_operand (unshare_expr (expr), &stmts, true,
 			       NULL_TREE);
@@ -2245,7 +2244,11 @@  rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi, sese region)
   if (is_gimple_min_invariant (arg)
       || SSA_NAME_IS_DEFAULT_DEF (arg)
       || gimple_bb (SSA_NAME_DEF_STMT (arg))->loop_father == bb->loop_father)
-    stmt = gimple_build_assign (res, arg);
+    {
+      propagate_expr_outside_region (res, arg, region);
+      gsi_next (psi);
+      return;
+    }
 
   /* If res is scev analyzable and is not a scalar value, it is safe
      to ignore the close phi node: it will be code generated in the
@@ -2262,7 +2265,7 @@  rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi, sese region)
 	  scev = compute_overall_effect_of_inner_loop (loop, scev);
 	}
       else
-	  scev = scalar_evolution_in_region (region, loop, res);
+	scev = scalar_evolution_in_region (region, loop, res);
 
       if (tree_does_not_contain_chrecs (scev))
 	propagate_expr_outside_region (res, scev, region);
@@ -2425,38 +2428,6 @@  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.  GSI points to a definition that is
-   used in a PHI node.  */
-
-static void
-rewrite_cross_bb_phi_deps (sese region, gimple_stmt_iterator gsi)
-{
-  gimple stmt = gsi_stmt (gsi);
-  imm_use_iterator imm_iter;
-  tree def;
-  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;
-
-  FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
-    if (gimple_code (use_stmt) == GIMPLE_PHI)
-      {
-	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, region);
-	else
-	  rewrite_phi_out_of_ssa (&psi);
-      }
-}
-
-/* Rewrite the scalar dependences crossing the boundary of the BB
    containing STMT with an array.  */
 
 static void
@@ -2500,11 +2471,21 @@  rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
   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))
+    if (gimple_code (use_stmt) == GIMPLE_PHI)
       {
-	gcc_assert (gimple_code (use_stmt) != GIMPLE_PHI);
+	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, region);
+	else
+	  rewrite_phi_out_of_ssa (&psi);
+      }
+
+  FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
+    if (gimple_code (use_stmt) != GIMPLE_PHI
+	&& def_bb != gimple_bb (use_stmt)
+	&& !is_gimple_debug (use_stmt))
+      {
 	if (!zero_dim_array)
 	  {
 	    zero_dim_array = create_zero_dim_array
@@ -2530,10 +2511,7 @@  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_phi_deps (region, psi);
-	  rewrite_cross_bb_scalar_deps (region, &psi);
-	}
+	rewrite_cross_bb_scalar_deps (region, &psi);
 
   update_ssa (TODO_update_ssa);
 #ifdef ENABLE_CHECKING