public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch][graphite] Remove sese_adjust_liveout_phis
@ 2010-06-12  8:17 Sebastian Pop
  2010-06-12 12:03 ` Sebastian Pop
  2010-06-14 18:20 ` Sebastian Pop
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Pop @ 2010-06-12  8:17 UTC (permalink / raw)
  To: GCC Patches, gcc-graphite

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

Hi,

with the attached patches we no longer need to use the rename_map to
substitute the arguments of the phi nodes created after the code
generated by Graphite.  I committed these patches to the graphite
branch, and I will commit them to trunk once they pass the usual
graphite branch tests.

The aim is to replace the rename_map with the map that CLooG exposes
for each user statement: associating to a loop level an expression.
The expand_* functions will be replaced by the code generation from a
chrec that is obtained from the original scev by chrec_applying the
loop level -> expression map on each varying loop.  This will then
allow us to remove the call to the IV canonicalization from Graphite.

Sebastian

[-- Attachment #2: 0001-Launch-dotty-in-background.patch --]
[-- Type: text/x-diff, Size: 2068 bytes --]

From e747edcf6bd61fe4eae201b70181cba5ce43edbf Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 11 Jun 2010 18:42:21 -0500
Subject: [PATCH 1/4] Launch dotty in background.

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

	* graphite-dependences.c (dot_deps): Make system call to dotty run
	in background.
	(dot_deps_stmt): Same.
	* graphite-poly.c (dot_lst): Same.
---
 gcc/ChangeLog.graphite     |    7 +++++++
 gcc/graphite-dependences.c |    4 ++--
 gcc/graphite-poly.c        |    2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 6df816b..72bb7f5 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,10 @@
+2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* graphite-dependences.c (dot_deps): Make system call to dotty run
+	in background.
+	(dot_deps_stmt): Same.
+	* graphite-poly.c (dot_lst): Same.
+
 2010-06-11  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* graphite-clast-to-gimple.c (gcc_type_for_interval): Do not pass
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 41824e4..91743f1 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -963,7 +963,7 @@ dot_deps (scop_p scop)
   dot_deps_1 (stream, scop);
   fclose (stream);
 
-  system ("dotty /tmp/scopdeps.dot");
+  system ("dotty /tmp/scopdeps.dot &");
 #else
   dot_deps_1 (stderr, scop);
 #endif
@@ -983,7 +983,7 @@ dot_deps_stmt (scop_p scop)
   dot_deps_stmt_1 (stream, scop);
   fclose (stream);
 
-  system ("dotty /tmp/scopdeps.dot");
+  system ("dotty /tmp/scopdeps.dot &");
 #else
   dot_deps_stmt_1 (stderr, scop);
 #endif
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 24a47f0..28430ed 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1320,7 +1320,7 @@ dot_lst (lst_p lst)
   fputs ("}\n\n", stream);
   fclose (stream);
 
-  system ("dotty /tmp/lst.dot");
+  system ("dotty /tmp/lst.dot &");
 #else
   fputs ("digraph all {\n", stderr);
   dot_lst_1 (stderr, lst);
-- 
1.7.0.4


[-- Attachment #3: 0002-Detect-commutative-reductions-in-all-the-scops-befor.patch --]
[-- Type: text/x-diff, Size: 5719 bytes --]

From 9c6db20feae3d4cb96966f0877c19d96ff4c5c66 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 11 Jun 2010 19:37:07 -0500
Subject: [PATCH 2/4] Detect commutative reductions in all the scops before rewriting out of SSA all the other scalar dependences.

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

	* graphite-sese-to-poly.c (build_scop_bbs): Not static anymore.
	(rewrite_reductions_out_of_ssa): Same.
	(rewrite_commutative_reductions_out_of_ssa): Same.
	(build_poly_scop): Do not call these functions.
	* graphite-sese-to-poly.h (build_poly_scop): Declared.
	(rewrite_reductions_out_of_ssa): Declared.
	(rewrite_commutative_reductions_out_of_ssa): Declared.
	* graphite.c (graphite_transform_loops): Call on every scop
	rewrite_commutative_reductions_out_of_ssa before calling
	rewrite_reductions_out_of_ssa and build_scop_bbs.
---
 gcc/ChangeLog.graphite      |   13 +++++++++++++
 gcc/graphite-sese-to-poly.c |   16 +++++-----------
 gcc/graphite-sese-to-poly.h |    3 +++
 gcc/graphite.c              |   14 ++++++++++++++
 4 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 72bb7f5..a87c69d 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,18 @@
 2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (build_scop_bbs): Not static anymore.
+	(rewrite_reductions_out_of_ssa): Same.
+	(rewrite_commutative_reductions_out_of_ssa): Same.
+	(build_poly_scop): Do not call these functions.
+	* graphite-sese-to-poly.h (build_poly_scop): Declared.
+	(rewrite_reductions_out_of_ssa): Declared.
+	(rewrite_commutative_reductions_out_of_ssa): Declared.
+	* graphite.c (graphite_transform_loops): Call on every scop
+	rewrite_commutative_reductions_out_of_ssa before calling
+	rewrite_reductions_out_of_ssa and build_scop_bbs.
+
+2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (dot_deps): Make system call to dotty run
 	in background.
 	(dot_deps_stmt): Same.
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 41e2c9f..66c0282 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -462,7 +462,7 @@ build_scop_bbs_1 (scop_p scop, sbitmap visited, basic_block bb, sbitmap reductio
 
 /* Gather the basic blocks belonging to the SCOP.  */
 
-static void
+void
 build_scop_bbs (scop_p scop, sbitmap reductions)
 {
   sbitmap visited = sbitmap_alloc (last_basic_block);
@@ -2398,7 +2398,7 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
 
 /* Rewrite out of SSA all the reduction phi nodes of SCOP.  */
 
-static void
+void
 rewrite_reductions_out_of_ssa (scop_p scop)
 {
   basic_block bb;
@@ -2577,7 +2577,7 @@ detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg,
 }
 
 /* Detect commutative and associative scalar reductions starting at
-   the STMT.  Return the phi node of the reduction cycle, or NULL.  */
+   STMT.  Return the phi node of the reduction cycle, or NULL.  */
 
 static gimple
 detect_commutative_reduction_assign (gimple stmt, VEC (gimple, heap) **in,
@@ -2665,7 +2665,7 @@ initial_value_for_loop_phi (gimple phi)
 }
 
 /* Detect commutative and associative scalar reductions starting at
-   the loop closed phi node CLOSE_PHI.  Return the phi node of the
+   the loop closed phi node STMT.  Return the phi node of the
    reduction cycle, or NULL.  */
 
 static gimple
@@ -2873,7 +2873,7 @@ rewrite_commutative_reductions_out_of_ssa_loop (loop_p loop,
 
 /* Rewrites all the commutative reductions from SCOP out of SSA.  */
 
-static void
+void
 rewrite_commutative_reductions_out_of_ssa (sese region, sbitmap reductions)
 {
   loop_iterator li;
@@ -2972,14 +2972,8 @@ void
 build_poly_scop (scop_p scop)
 {
   sese region = SCOP_REGION (scop);
-  sbitmap reductions = sbitmap_alloc (last_basic_block * 2);
   graphite_dim_t max_dim;
 
-  sbitmap_zero (reductions);
-  rewrite_commutative_reductions_out_of_ssa (region, reductions);
-  rewrite_reductions_out_of_ssa (scop);
-  build_scop_bbs (scop, reductions);
-  sbitmap_free (reductions);
 
   /* FIXME: This restriction is needed to avoid a problem in CLooG.
      Once CLooG is fixed, remove this guard.  Anyways, it makes no
diff --git a/gcc/graphite-sese-to-poly.h b/gcc/graphite-sese-to-poly.h
index ccf36dd..2e0cc08 100644
--- a/gcc/graphite-sese-to-poly.h
+++ b/gcc/graphite-sese-to-poly.h
@@ -30,5 +30,8 @@ struct base_alias_pair
 
 void build_poly_scop (scop_p);
 void check_poly_representation (scop_p);
+void rewrite_commutative_reductions_out_of_ssa (sese, sbitmap);
+void rewrite_reductions_out_of_ssa (scop_p);
+void build_scop_bbs (scop_p, sbitmap);
 
 #endif
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 347ebc8..5f28aeb 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -254,6 +254,7 @@ graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
+  sbitmap reductions;
 
   if (!graphite_initialize ())
     return;
@@ -267,6 +268,19 @@ graphite_transform_loops (void)
     }
 
   bb_pbb_mapping = htab_create (10, bb_pbb_map_hash, eq_bb_pbb_map, free);
+  reductions = sbitmap_alloc (last_basic_block * 2);
+  sbitmap_zero (reductions);
+
+  for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
+    rewrite_commutative_reductions_out_of_ssa (SCOP_REGION (scop), reductions);
+
+  for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
+    {
+      rewrite_reductions_out_of_ssa (scop);
+      build_scop_bbs (scop, reductions);
+    }
+
+  sbitmap_free (reductions);
 
   for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
     if (dbg_cnt (graphite_scop))
-- 
1.7.0.4


[-- Attachment #4: 0003-Remove-insert_copyout-and-insert_copyin.patch --]
[-- Type: text/x-diff, Size: 6148 bytes --]

From d36ba67360a736e061133c52e84aeaef7b1347eb Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 11 Jun 2010 19:43:13 -0500
Subject: [PATCH 3/4] Remove insert_copyout and insert_copyin.

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

	* graphite-sese-to-poly.c (insert_out_of_ssa_copy): Pass an extra
	argument for the place after which to insert the out of SSA copy.
	(rewrite_close_phi_out_of_ssa): Update calls to insert_out_of_ssa_copy.
	(rewrite_phi_out_of_ssa): Same.
	(rewrite_cross_bb_scalar_deps): Same.
	(insert_copyout): Removed.
	(insert_copyin): Removed.
	(translate_scalar_reduction_to_array): Call insert_out_of_ssa_copy and
	insert_out_of_ssa_copy_on_edge instead of insert_copyout and
	insert_copyin.
---
 gcc/ChangeLog.graphite      |   13 ++++++++++
 gcc/graphite-sese-to-poly.c |   53 ++++++++++++------------------------------
 2 files changed, 28 insertions(+), 38 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index a87c69d..888a77d 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,18 @@
 2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (insert_out_of_ssa_copy): Pass an extra
+	argument for the place after which to insert the out of SSA copy.
+	(rewrite_close_phi_out_of_ssa): Update calls to insert_out_of_ssa_copy.
+	(rewrite_phi_out_of_ssa): Same.
+	(rewrite_cross_bb_scalar_deps): Same.
+	(insert_copyout): Removed.
+	(insert_copyin): Removed.
+	(translate_scalar_reduction_to_array): Call insert_out_of_ssa_copy and
+	insert_out_of_ssa_copy_on_edge instead of insert_copyout and
+	insert_copyin.
+
+2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (build_scop_bbs): Not static anymore.
 	(rewrite_reductions_out_of_ssa): Same.
 	(rewrite_commutative_reductions_out_of_ssa): Same.
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 66c0282..7bb7bb8 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2116,10 +2116,10 @@ gsi_for_phi_node (gimple stmt)
   return psi;
 }
 
-/* Insert the assignment "RES := VAR" just after the definition of VAR.  */
+/* Insert the assignment "RES := VAR" just after AFTER_STMT.  */
 
 static void
-insert_out_of_ssa_copy (tree res, tree var)
+insert_out_of_ssa_copy (tree res, tree var, gimple after_stmt)
 {
   gimple stmt;
   gimple_seq stmts;
@@ -2133,15 +2133,14 @@ insert_out_of_ssa_copy (tree res, tree var)
   si = gsi_last (stmts);
   gsi_insert_after (&si, stmt, GSI_NEW_STMT);
 
-  stmt = SSA_NAME_DEF_STMT (var);
-  if (gimple_code (stmt) == GIMPLE_PHI)
+  if (gimple_code (after_stmt) == GIMPLE_PHI)
     {
-      gsi = gsi_after_labels (gimple_bb (stmt));
+      gsi = gsi_after_labels (gimple_bb (after_stmt));
       gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT);
     }
   else
     {
-      gsi = gsi_for_stmt (stmt);
+      gsi = gsi_for_stmt (after_stmt);
       gsi_insert_seq_after (&gsi, stmts, GSI_NEW_STMT);
     }
 }
@@ -2217,7 +2216,7 @@ rewrite_close_phi_out_of_ssa (gimple_stmt_iterator *psi)
 
   if (TREE_CODE (arg) == SSA_NAME
       && !SSA_NAME_IS_DEFAULT_DEF (arg))
-    insert_out_of_ssa_copy (zero_dim_array, arg);
+    insert_out_of_ssa_copy (zero_dim_array, arg, SSA_NAME_DEF_STMT (arg));
   else
     insert_out_of_ssa_copy_on_edge (single_pred_edge (gimple_bb (phi)),
 				    zero_dim_array, arg);
@@ -2238,7 +2237,7 @@ rewrite_phi_out_of_ssa (gimple_stmt_iterator *psi)
   basic_block bb = gimple_bb (phi);
   tree res = gimple_phi_result (phi);
   tree var = SSA_NAME_VAR (res);
-  tree zero_dim_array = create_zero_dim_array (var, "General_Reduction");
+  tree zero_dim_array = create_zero_dim_array (var, "phi_out_of_ssa");
   gimple_stmt_iterator gsi;
   gimple stmt;
   gimple_seq stmts;
@@ -2294,7 +2293,7 @@ rewrite_phi_out_of_ssa (gimple_stmt_iterator *psi)
 				     gimple_bb (SSA_NAME_DEF_STMT (arg)))
 	      || flow_bb_inside_loop_p (loop_outer (bb->loop_father),
 					gimple_bb (SSA_NAME_DEF_STMT (arg)))))
-	insert_out_of_ssa_copy (zero_dim_array, arg);
+	insert_out_of_ssa_copy (zero_dim_array, arg, SSA_NAME_DEF_STMT (arg));
       else
 	insert_out_of_ssa_copy_on_edge (gimple_phi_arg_edge (phi, i),
 					zero_dim_array, arg);
@@ -2388,7 +2387,8 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
 	  {
 	    zero_dim_array = create_zero_dim_array
 	      (SSA_NAME_VAR (def), "Cross_BB_scalar_dependence");
-	    insert_out_of_ssa_copy (zero_dim_array, def);
+	    insert_out_of_ssa_copy (zero_dim_array, def,
+				    SSA_NAME_DEF_STMT (def));
 	    gsi_next (gsi);
 	  }
 
@@ -2727,32 +2727,6 @@ translate_scalar_reduction_to_array_for_stmt (tree red, gimple stmt,
   gsi_insert_after (&insert_gsi, assign, GSI_SAME_STMT);
 }
 
-/* Insert the assignment "result (CLOSE_PHI) = RED".  */
-
-static void
-insert_copyout (tree red, gimple close_phi)
-{
-  tree res = gimple_phi_result (close_phi);
-  basic_block bb = gimple_bb (close_phi);
-  gimple_stmt_iterator insert_gsi = gsi_after_labels (bb);
-  gimple assign = gimple_build_assign (res, red);
-
-  gsi_insert_before (&insert_gsi, assign, GSI_SAME_STMT);
-}
-
-/* Insert the assignment "RED = initial_value (LOOP_PHI)".  */
-
-static void
-insert_copyin (tree red, gimple loop_phi)
-{
-  gimple_seq stmts;
-  tree init = initial_value_for_loop_phi (loop_phi);
-  tree expr = build2 (MODIFY_EXPR, TREE_TYPE (init), red, init);
-
-  force_gimple_operand (expr, &stmts, true, NULL);
-  gsi_insert_seq_on_edge (edge_initial_value_for_loop_phi (loop_phi), stmts);
-}
-
 /* Removes the PHI node and resets all the debug stmts that are using
    the PHI_RESULT.  */
 
@@ -2828,8 +2802,11 @@ translate_scalar_reduction_to_array (VEC (gimple, heap) *in,
 
       if (i == VEC_length (gimple, in) - 1)
 	{
-	  insert_copyout (red, close_phi);
-	  insert_copyin (red, loop_phi);
+	  insert_out_of_ssa_copy (gimple_phi_result (close_phi), red,
+				  close_phi);
+	  insert_out_of_ssa_copy_on_edge
+	    (edge_initial_value_for_loop_phi (loop_phi),
+	     red, initial_value_for_loop_phi (loop_phi));
 	}
 
       remove_phi (loop_phi);
-- 
1.7.0.4


[-- Attachment #5: 0004-Also-rewrite-out-of-SSA-scalar-dependences-going-out.patch --]
[-- Type: text/x-diff, Size: 8911 bytes --]

From e1e77ccc827024af17e5afc9baf5d8f044815052 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Fri, 11 Jun 2010 19:58:39 -0500
Subject: [PATCH 4/4] Also rewrite out of SSA scalar dependences going outside the SCoP region.

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

	* graphite-clast-to-gimple.c (gloog): Remove call to
	sese_adjust_liveout_phis.
	* graphite-sese-to-poly.c (scev_analyzable_p): When scev returns an
	SSA_NAME, allow it to be handled by rewrite_cross_bb_scalar_deps.
	(rewrite_cross_bb_scalar_deps): Handle GIMPLE_PHI nodes: call
	rewrite_phi_out_of_ssa.
	* sese.c (get_vdef_before_sese): Removed.
	(sese_adjust_vphi): Removed.
	(sese_adjust_liveout_phis): Removed.
	* sese.h (sese_adjust_liveout_phis): Removed.
---
 gcc/ChangeLog.graphite         |   13 +++
 gcc/graphite-clast-to-gimple.c |    4 -
 gcc/graphite-sese-to-poly.c    |   13 ++-
 gcc/sese.c                     |  159 ----------------------------------------
 gcc/sese.h                     |    1 -
 5 files changed, 22 insertions(+), 168 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 888a77d..d703048 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,18 @@
 2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-clast-to-gimple.c (gloog): Remove call to
+	sese_adjust_liveout_phis.
+	* graphite-sese-to-poly.c (scev_analyzable_p): When scev returns an
+	SSA_NAME, allow it to be handled by rewrite_cross_bb_scalar_deps.
+	(rewrite_cross_bb_scalar_deps): Handle GIMPLE_PHI nodes: call
+	rewrite_phi_out_of_ssa.
+	* sese.c (get_vdef_before_sese): Removed.
+	(sese_adjust_vphi): Removed.
+	(sese_adjust_liveout_phis): Removed.
+	* sese.h (sese_adjust_liveout_phis): Removed.
+
+2010-06-12  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (insert_out_of_ssa_copy): Pass an extra
 	argument for the place after which to insert the out of SSA copy.
 	(rewrite_close_phi_out_of_ssa): Update calls to insert_out_of_ssa_copy.
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a363f5d..01adba0 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -1578,10 +1578,6 @@ gloog (scop_p scop, VEC (scop_p, heap) *scops, htab_t bb_pbb_mapping)
 		   rename_map, &newivs, newivs_index,
 		   bb_pbb_mapping, 1, params_index);
   graphite_verify ();
-  sese_adjust_liveout_phis (region, rename_map,
-			    if_region->region->exit->src,
-			    if_region->false_region->exit,
-			    if_region->true_region->exit);
   scev_reset_htab ();
   rename_nb_iterations (rename_map);
 
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 7bb7bb8..57967e5 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2325,7 +2325,8 @@ scev_analyzable_p (tree def, sese region)
   loop_p loop = loop_containing_stmt (stmt);
   tree scev = scalar_evolution_in_region (region, loop, def);
 
-  return !chrec_contains_undetermined (scev);
+  return !chrec_contains_undetermined (scev)
+    && TREE_CODE (scev) != SSA_NAME;
 }
 
 /* Rewrite the scalar dependence of DEF used in USE_STMT with a memory
@@ -2379,9 +2380,13 @@ 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)
-	&& gimple_code (use_stmt) != GIMPLE_PHI
-	&& !is_gimple_debug (use_stmt))
+    if (gimple_code (use_stmt) == GIMPLE_PHI)
+      {
+	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))
       {
 	if (!zero_dim_array)
 	  {
diff --git a/gcc/sese.c b/gcc/sese.c
index 7e9bd91..051599e 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -394,100 +394,6 @@ sese_insert_phis_for_liveouts (sese region, basic_block bb,
   update_ssa (TODO_update_ssa);
 }
 
-/* Get the definition of NAME before the SESE.  Keep track of the
-   basic blocks that have been VISITED in a bitmap.  */
-
-static tree
-get_vdef_before_sese (sese region, tree name, sbitmap visited)
-{
-  unsigned i;
-  gimple stmt = SSA_NAME_DEF_STMT (name);
-  basic_block def_bb = gimple_bb (stmt);
-
-  if (!def_bb || !bb_in_sese_p (def_bb, region))
-    return name;
-
-  if (TEST_BIT (visited, def_bb->index))
-    return NULL_TREE;
-
-  SET_BIT (visited, def_bb->index);
-
-  switch (gimple_code (stmt))
-    {
-    case GIMPLE_PHI:
-      for (i = 0; i < gimple_phi_num_args (stmt); i++)
-	{
-	  tree arg = gimple_phi_arg_def (stmt, i);
-	  tree res;
-
-	  if (gimple_bb (SSA_NAME_DEF_STMT (arg))
-	      && def_bb->index == gimple_bb (SSA_NAME_DEF_STMT (arg))->index)
-	    continue;
-
-	  res = get_vdef_before_sese (region, arg, visited);
-	  if (res)
-	    return res;
-	}
-      return NULL_TREE;
-
-    case GIMPLE_ASSIGN:
-    case GIMPLE_CALL:
-      {
-	use_operand_p use_p = gimple_vuse_op (stmt);
-	tree use = USE_FROM_PTR (use_p);
-
-	if (def_bb->index == gimple_bb (SSA_NAME_DEF_STMT (use))->index)
-	  RESET_BIT (visited, def_bb->index);
-
-	return get_vdef_before_sese (region, use, visited);
-      }
-
-    default:
-      return NULL_TREE;
-    }
-}
-
-/* Adjust a virtual phi node PHI that is placed at the end of the
-   generated code for SCOP:
-
-   | if (1)
-   |   generated code from REGION;
-   | else
-   |   REGION;
-
-   The FALSE_E edge comes from the original code, TRUE_E edge comes
-   from the code generated for the SCOP.  */
-
-static void
-sese_adjust_vphi (sese region, gimple phi, edge true_e)
-{
-  unsigned i;
-
-  gcc_assert (gimple_phi_num_args (phi) == 2);
-
-  for (i = 0; i < gimple_phi_num_args (phi); i++)
-    if (gimple_phi_arg_edge (phi, i) == true_e)
-      {
-	tree true_arg, false_arg, before_scop_arg;
-	sbitmap visited;
-
-	true_arg = gimple_phi_arg_def (phi, i);
-	if (!SSA_NAME_IS_DEFAULT_DEF (true_arg))
-	  return;
-
-	false_arg = gimple_phi_arg_def (phi, i == 0 ? 1 : 0);
-	if (SSA_NAME_IS_DEFAULT_DEF (false_arg))
-	  return;
-
-	visited = sbitmap_alloc (last_basic_block);
-	sbitmap_zero (visited);
-	before_scop_arg = get_vdef_before_sese (region, false_arg, visited);
-	gcc_assert (before_scop_arg != NULL_TREE);
-	SET_PHI_ARG_DEF (phi, i, before_scop_arg);
-	sbitmap_free (visited);
-      }
-}
-
 /* Returns the expression associated to OLD_NAME in MAP.  */
 
 static tree
@@ -585,71 +491,6 @@ rename_sese_parameters (htab_t rename_map, sese region)
 		 rename_variables_in_expr (rename_map, p));
 }
 
-/* Adjusts the phi nodes in the block BB for variables defined in
-   SCOP_REGION and used outside the SCOP_REGION.  The code generation
-   moves SCOP_REGION in the else clause of an "if (1)" and generates
-   code in the then clause:
-
-   | if (1)
-   |   generated code from REGION;
-   | else
-   |   REGION;
-
-   To adjust the phi nodes after the condition, the RENAME_MAP is
-   used.  */
-
-void
-sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb,
-			  edge false_e, edge true_e)
-{
-  gimple_stmt_iterator si;
-
-  for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
-    {
-      unsigned i;
-      unsigned false_i = 0;
-      gimple phi = gsi_stmt (si);
-      tree res = gimple_phi_result (phi);
-
-      if (!is_gimple_reg (res))
-	{
-	  sese_adjust_vphi (region, phi, true_e);
-	  continue;
-	}
-
-      for (i = 0; i < gimple_phi_num_args (phi); i++)
-	if (gimple_phi_arg_edge (phi, i) == false_e)
-	  {
-	    false_i = i;
-	    break;
-	  }
-
-      for (i = 0; i < gimple_phi_num_args (phi); i++)
-	if (gimple_phi_arg_edge (phi, i) == true_e)
-	  {
-	    tree old_name = gimple_phi_arg_def (phi, false_i);
-	    tree expr = get_rename (rename_map, old_name);
-	    gimple_seq stmts;
-
-	    gcc_assert (old_name != expr);
-
-	    if (TREE_CODE (expr) != SSA_NAME
-		&& is_gimple_reg (old_name))
-	      {
-		tree type = TREE_TYPE (old_name);
-		tree var = create_tmp_var (type, "var");
-
-		expr = build2 (MODIFY_EXPR, type, var, expr);
-		expr = force_gimple_operand (expr, &stmts, true, NULL);
-		gsi_insert_seq_on_edge_immediate (true_e, stmts);
-	      }
-
-	    SET_PHI_ARG_DEF (phi, i, expr);
-	    set_rename (rename_map, old_name, res);
-	  }
-    }
-}
-
 /* Rename the SSA_NAMEs used in STMT and that appear in MAP.  */
 
 static void
diff --git a/gcc/sese.h b/gcc/sese.h
index 2b05ca8..4b2e5c2 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -55,7 +55,6 @@ typedef struct sese_s
 extern sese new_sese (edge, edge);
 extern void free_sese (sese);
 extern void sese_insert_phis_for_liveouts (sese, basic_block, edge, edge);
-extern void sese_adjust_liveout_phis (sese, htab_t, basic_block, edge, edge);
 extern void build_sese_loop_nests (sese);
 extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge, htab_t);
 extern struct loop *outermost_loop_in_sese (sese, basic_block);
-- 
1.7.0.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-15 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-12  8:17 [patch][graphite] Remove sese_adjust_liveout_phis Sebastian Pop
2010-06-12 12:03 ` Sebastian Pop
2010-06-14 18:20 ` Sebastian Pop
2010-06-15  9:31   ` Richard Guenther
2010-06-15 15:53     ` Sebastian Pop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).