Patchwork [01/12] Remove insert_loop_close_phis.

login
register
mail settings
Submitter Sebastian Pop
Date July 16, 2010, 7:03 a.m.
Message ID <1279263843-9149-2-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/59070/
State New
Headers show

Comments

Sebastian Pop - July 16, 2010, 7:03 a.m.
2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-clast-to-gimple.c (translate_clast_for_loop): Do not call
	insert_loop_close_phis.
	* sese.c (name_defined_in_loop_p): Removed.
	(expr_defined_in_loop_p): Removed.
	(alive_after_loop): Removed.
	(close_phi_not_yet_inserted_p): Removed.
	(struct alep): Removed.
	(add_loop_exit_phis): Removed.
	(insert_loop_close_phis): Removed.
---
 gcc/ChangeLog.graphite         |   19 ++++-
 gcc/graphite-clast-to-gimple.c |    4 -
 gcc/sese.c                     |  167 ----------------------------------------
 3 files changed, 15 insertions(+), 175 deletions(-)

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 6d915a7..3774b46 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,9 +1,20 @@ 
+2010-07-15  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* graphite-clast-to-gimple.c (translate_clast_for_loop): Do not call
+	insert_loop_close_phis.
+	* sese.c (name_defined_in_loop_p): Removed.
+	(expr_defined_in_loop_p): Removed.
+	(alive_after_loop): Removed.
+	(close_phi_not_yet_inserted_p): Removed.
+	(struct alep): Removed.
+	(add_loop_exit_phis): Removed.
+	(insert_loop_close_phis): Removed.
+
 2010-07-15  Andreas Simbuerger  <simbuerg@fim.uni-passau.de>
 
-	* graphite-cloog-util.c
-	(cloog_matrix_to_ppl_constraint): Fix flipped condition.
-	* graphite-poly.c
-	(psct_scattering_dim_for_loop_depth): Same.
+	* graphite-cloog-util.c	(cloog_matrix_to_ppl_constraint): Fix flipped
+	condition.
+	* graphite-poly.c (psct_scattering_dim_for_loop_depth): Same.
 
 2010-07-07  Sebastian Pop  <sebastian.pop@amd.com>
 
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index d12f177..042857f 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -1046,10 +1046,6 @@  translate_clast_for_loop (sese region, loop_p context_loop,
   redirect_edge_succ_nodup (next_e, after);
   set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
 
-   /* Remove from rename_map all the tuples containing variables
-      defined in loop's body.  */
-  insert_loop_close_phis (rename_map, loop);
-
   if (flag_loop_parallelize_all
       && !dependency_in_loop_p (loop, bb_pbb_mapping,
  				get_scattering_level (level)))
diff --git a/gcc/sese.c b/gcc/sese.c
index 6883073..e0c06da 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -888,173 +888,6 @@  get_false_edge_from_guard_bb (basic_block bb)
   return NULL;
 }
 
-/* Returns true when NAME is defined in LOOP.  */
-
-static bool
-name_defined_in_loop_p (tree name, loop_p loop)
-{
-  return !SSA_NAME_IS_DEFAULT_DEF (name)
-    && gimple_bb (SSA_NAME_DEF_STMT (name))->loop_father == loop;
-}
-
-/* Returns true when EXPR contains SSA_NAMEs defined in LOOP.  */
-
-static bool
-expr_defined_in_loop_p (tree expr, loop_p loop)
-{
-  switch (TREE_CODE_LENGTH (TREE_CODE (expr)))
-    {
-    case 3:
-      return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop)
-	|| expr_defined_in_loop_p (TREE_OPERAND (expr, 1), loop)
-	|| expr_defined_in_loop_p (TREE_OPERAND (expr, 2), loop);
-
-    case 2:
-      return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop)
-	|| expr_defined_in_loop_p (TREE_OPERAND (expr, 1), loop);
-
-    case 1:
-      return expr_defined_in_loop_p (TREE_OPERAND (expr, 0), loop);
-
-    case 0:
-      return TREE_CODE (expr) == SSA_NAME
-	&& name_defined_in_loop_p (expr, loop);
-
-    default:
-      return false;
-    }
-}
-
-/* Returns the gimple statement that uses NAME outside the loop it is
-   defined in, returns NULL if there is no such loop close phi node.
-   An invariant of the loop closed SSA form is that the only use of a
-   variable, outside the loop it is defined in, is in the loop close
-   phi node that just follows the loop.  */
-
-static gimple
-alive_after_loop (tree name)
-{
-  use_operand_p use_p;
-  imm_use_iterator imm_iter;
-  loop_p loop = gimple_bb (SSA_NAME_DEF_STMT (name))->loop_father;
-
-  FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
-    {
-      gimple stmt = USE_STMT (use_p);
-
-      if (gimple_code (stmt) == GIMPLE_PHI
-	  && gimple_bb (stmt)->loop_father != loop)
-	return stmt;
-    }
-
-  return NULL;
-}
-
-/* Return true if a close phi has not yet been inserted for the use of
-   variable NAME on the single exit of LOOP.  */
-
-static bool
-close_phi_not_yet_inserted_p (loop_p loop, tree name)
-{
-  gimple_stmt_iterator psi;
-  basic_block bb = single_exit (loop)->dest;
-
-  for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
-    if (gimple_phi_arg_def (gsi_stmt (psi), 0) == name)
-      return false;
-
-  return true;
-}
-
-/* A structure for passing parameters to add_loop_exit_phis.  */
-
-typedef struct alep {
-  loop_p loop;
-  VEC (rename_map_elt, heap) *new_renames;
-} *alep_p;
-
-/* Helper function for htab_traverse in insert_loop_close_phis.  */
-
-static int
-add_loop_exit_phis (void **slot, void *data)
-{
-  struct rename_map_elt_s *entry;
-  alep_p a;
-  loop_p loop;
-  tree expr, new_name, old_name;
-  bool def_in_loop_p, used_outside_p, need_close_phi_p;
-  gimple old_close_phi;
-
-  if (!slot || !*slot || !data)
-    return 1;
-
-  entry = (struct rename_map_elt_s *) *slot;
-  a = (alep_p) data;
-  loop = a->loop;
-  new_name = expr = entry->expr;
-  old_name = entry->old_name;
-
-  def_in_loop_p = expr_defined_in_loop_p (expr, loop);
-  if (!def_in_loop_p)
-    return 1;
-
-  /* Remove the old rename from the map when the expression is defined
-     in the loop that we're closing.  */
-  free (*slot);
-  *slot = NULL;
-
-  if (TREE_CODE (expr) != SSA_NAME)
-    return 1;
-
-  old_close_phi = alive_after_loop (old_name);
-  used_outside_p = (old_close_phi != NULL);
-  need_close_phi_p = (used_outside_p
-		      && close_phi_not_yet_inserted_p (loop, new_name));
-
-  /* Insert a loop close phi node.  */
-  if (need_close_phi_p)
-    {
-      basic_block bb = single_exit (loop)->dest;
-      gimple phi = create_phi_node (new_name, bb);
-      tree new_res = create_new_def_for (gimple_phi_result (phi), phi,
-					 gimple_phi_result_ptr (phi));
-
-      add_phi_arg (phi, new_name, single_pred_edge (bb), UNKNOWN_LOCATION);
-      VEC_safe_push (rename_map_elt, heap, a->new_renames,
-		     new_rename_map_elt (gimple_phi_result (old_close_phi),
-					 new_res));
-    }
-
-  return 1;
-}
-
-/* Traverses MAP and removes from it all the tuples (OLD, NEW) where
-   NEW is defined in LOOP.  Inserts on the exit of LOOP the close phi
-   node "RES = phi (NEW)" corresponding to "OLD_RES = phi (OLD)" in
-   the original code.  Inserts in MAP the tuple (OLD_RES, RES).  */
-
-void
-insert_loop_close_phis (htab_t map, loop_p loop)
-{
-  int i;
-  struct alep a;
-  rename_map_elt elt;
-
-  a.loop = loop;
-  a.new_renames = VEC_alloc (rename_map_elt, heap, 3);
-  update_ssa (TODO_update_ssa);
-  htab_traverse (map, add_loop_exit_phis, &a);
-  update_ssa (TODO_update_ssa);
-
-  for (i = 0; VEC_iterate (rename_map_elt, a.new_renames, i, elt); i++)
-    {
-      set_rename (map, elt->old_name, elt->expr);
-      free (elt);
-    }
-
-  VEC_free (rename_map_elt, heap, a.new_renames);
-}
-
 /* Helper structure for htab_traverse in insert_guard_phis.  */
 
 struct igp {