Commit 7d5f9cc6 by Diego Novillo Committed by Diego Novillo

tree-into-ssa.c (REWRITE_THIS_STMT): Define.


	* tree-into-ssa.c (REWRITE_THIS_STMT): Define.
	(mark_def_sites): Clear REWRITE_THIS_STMT for statements that
	don't need any operands rewritten.
	(rewrite_stmt): Ignore statements that don't need to be
	rewritten.
	(rewrite_operand): Validate that an existing SSA_NAME is
	identical to the current reaching definition of the operand.


	* tree-dfa.c (mark_call_clobbered_vars_to_rename): New function.
	* tree-vectorizer.c (vectorizable_load): Call it.
	* tree-flow.h (mark_call_clobbered_vars_to_rename): Declare.
	* tree-sra.c (mark_all_v_defs): Also mark VUSEs for renaming.

From-SVN: r92010
parent d49d0907
2004-12-10 Diego Novillo <dnovillo@redhat.com>
* tree-into-ssa.c (REWRITE_THIS_STMT): Define.
(mark_def_sites): Clear REWRITE_THIS_STMT for statements that
don't need any operands rewritten.
(rewrite_stmt): Ignore statements that don't need to be
rewritten.
(rewrite_operand): Validate that an existing SSA_NAME is
identical to the current reaching definition of the operand.
2004-12-10 Diego Novillo <dnovillo@redhat.com>
* tree-dfa.c (mark_call_clobbered_vars_to_rename): New function.
* tree-vectorizer.c (vectorizable_load): Call it.
* tree-flow.h (mark_call_clobbered_vars_to_rename): Declare.
* tree-sra.c (mark_all_v_defs): Also mark VUSEs for renaming.
2004-12-10 Kazu Hirata <kazu@cs.umass.edu> 2004-12-10 Kazu Hirata <kazu@cs.umass.edu>
* regmove.c (combine_stack_adjustments_for_block): Free * regmove.c (combine_stack_adjustments_for_block): Free
......
...@@ -1032,3 +1032,18 @@ find_new_referenced_vars (tree *stmt_p) ...@@ -1032,3 +1032,18 @@ find_new_referenced_vars (tree *stmt_p)
{ {
walk_tree (stmt_p, find_new_referenced_vars_1, NULL, NULL); walk_tree (stmt_p, find_new_referenced_vars_1, NULL, NULL);
} }
/* Mark all call-clobbered variables for renaming. */
void
mark_call_clobbered_vars_to_rename (void)
{
unsigned i;
bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
{
tree var = referenced_var (i);
bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
}
...@@ -536,6 +536,7 @@ extern tree get_virtual_var (tree); ...@@ -536,6 +536,7 @@ extern tree get_virtual_var (tree);
extern void add_referenced_tmp_var (tree); extern void add_referenced_tmp_var (tree);
extern void mark_new_vars_to_rename (tree, bitmap); extern void mark_new_vars_to_rename (tree, bitmap);
extern void find_new_referenced_vars (tree *); extern void find_new_referenced_vars (tree *);
void mark_call_clobbered_vars_to_rename (void);
extern void redirect_immediate_uses (tree, tree); extern void redirect_immediate_uses (tree, tree);
extern tree make_rename_temp (tree, const char *); extern tree make_rename_temp (tree, const char *);
......
...@@ -166,6 +166,12 @@ static inline struct def_blocks_d *get_def_blocks_for (tree); ...@@ -166,6 +166,12 @@ static inline struct def_blocks_d *get_def_blocks_for (tree);
static inline struct def_blocks_d *find_def_blocks_for (tree); static inline struct def_blocks_d *find_def_blocks_for (tree);
static void htab_statistics (FILE *, htab_t); static void htab_statistics (FILE *, htab_t);
/* Use TREE_VISITED to keep track of which statements we want to
rename. When renaming a subset of the variables, not all
statements will be processed. This is decided in mark_def_sites. */
#define REWRITE_THIS_STMT(T) TREE_VISITED (T)
/* Get the information associated with NAME. */ /* Get the information associated with NAME. */
static inline struct ssa_name_info * static inline struct ssa_name_info *
...@@ -379,14 +385,20 @@ mark_def_sites (struct dom_walk_data *walk_data, ...@@ -379,14 +385,20 @@ mark_def_sites (struct dom_walk_data *walk_data,
stmt = bsi_stmt (bsi); stmt = bsi_stmt (bsi);
get_stmt_operands (stmt); get_stmt_operands (stmt);
REWRITE_THIS_STMT (stmt) = 0;
/* If a variable is used before being set, then the variable is live /* If a variable is used before being set, then the variable is live
across a block boundary, so mark it live-on-entry to BB. */ across a block boundary, so mark it live-on-entry to BB. */
FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE | SSA_OP_VUSE | SSA_OP_VMUSTDEFKILL) FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
SSA_OP_USE | SSA_OP_VUSE | SSA_OP_VMUSTDEFKILL)
{ {
if (prepare_use_operand_for_rename (use_p, &uid) if (prepare_use_operand_for_rename (use_p, &uid))
&& !TEST_BIT (kills, uid)) {
set_livein_block (USE_FROM_PTR (use_p), bb); REWRITE_THIS_STMT (stmt) = 1;
if (!TEST_BIT (kills, uid))
set_livein_block (USE_FROM_PTR (use_p), bb);
}
} }
/* Note that virtual definitions are irrelevant for computing KILLS /* Note that virtual definitions are irrelevant for computing KILLS
...@@ -394,7 +406,6 @@ mark_def_sites (struct dom_walk_data *walk_data, ...@@ -394,7 +406,6 @@ mark_def_sites (struct dom_walk_data *walk_data,
variable. However, the operand of a virtual definitions is a use variable. However, the operand of a virtual definitions is a use
of the variable, so it may cause the variable to be considered of the variable, so it may cause the variable to be considered
live-on-entry. */ live-on-entry. */
FOR_EACH_SSA_MAYDEF_OPERAND (def_p, use_p, stmt, iter) FOR_EACH_SSA_MAYDEF_OPERAND (def_p, use_p, stmt, iter)
{ {
if (prepare_use_operand_for_rename (use_p, &uid)) if (prepare_use_operand_for_rename (use_p, &uid))
...@@ -406,22 +417,24 @@ mark_def_sites (struct dom_walk_data *walk_data, ...@@ -406,22 +417,24 @@ mark_def_sites (struct dom_walk_data *walk_data,
set_livein_block (USE_FROM_PTR (use_p), bb); set_livein_block (USE_FROM_PTR (use_p), bb);
set_def_block (DEF_FROM_PTR (def_p), bb, false, false); set_def_block (DEF_FROM_PTR (def_p), bb, false, false);
REWRITE_THIS_STMT (stmt) = 1;
} }
} }
/* Now process the virtual must-defs made by this statement. */ /* Now process the defs and must-defs made by this statement. */
FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF | SSA_OP_VMUSTDEF) FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF | SSA_OP_VMUSTDEF)
{ {
if (prepare_def_operand_for_rename (def, &uid)) if (prepare_def_operand_for_rename (def, &uid))
{ {
set_def_block (def, bb, false, false); set_def_block (def, bb, false, false);
SET_BIT (kills, uid); SET_BIT (kills, uid);
REWRITE_THIS_STMT (stmt) = 1;
} }
} }
} }
/* Ditto, but works over ssa names. */
/* Same as mark_def_sites, but works over SSA names. */
static void static void
ssa_mark_def_sites (struct dom_walk_data *walk_data, ssa_mark_def_sites (struct dom_walk_data *walk_data,
...@@ -807,7 +820,7 @@ rewrite_add_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -807,7 +820,7 @@ rewrite_add_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
phi nodes we want to add arguments for. */ phi nodes we want to add arguments for. */
static void static void
rewrite_virtual_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, rewrite_virtual_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb) basic_block bb)
{ {
edge e; edge e;
...@@ -1099,6 +1112,11 @@ rewrite_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -1099,6 +1112,11 @@ rewrite_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
stmt = bsi_stmt (si); stmt = bsi_stmt (si);
ann = stmt_ann (stmt); ann = stmt_ann (stmt);
/* If mark_def_sites decided that we don't need to rewrite this
statement, ignore it. */
if (!REWRITE_THIS_STMT (stmt))
return;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "Renaming statement "); fprintf (dump_file, "Renaming statement ");
...@@ -1126,7 +1144,8 @@ rewrite_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -1126,7 +1144,8 @@ rewrite_stmt (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
} }
} }
/* Ditto, for rewriting ssa names. */
/* Same as rewrite_stmt, for rewriting ssa names. */
static void static void
ssa_rewrite_stmt (struct dom_walk_data *walk_data, ssa_rewrite_stmt (struct dom_walk_data *walk_data,
...@@ -1180,8 +1199,21 @@ ssa_rewrite_stmt (struct dom_walk_data *walk_data, ...@@ -1180,8 +1199,21 @@ ssa_rewrite_stmt (struct dom_walk_data *walk_data,
static inline void static inline void
rewrite_operand (use_operand_p op_p) rewrite_operand (use_operand_p op_p)
{ {
if (TREE_CODE (USE_FROM_PTR (op_p)) != SSA_NAME) tree var = USE_FROM_PTR (op_p);
SET_USE (op_p, get_reaching_def (USE_FROM_PTR (op_p))); if (TREE_CODE (var) != SSA_NAME)
SET_USE (op_p, get_reaching_def (var));
else
{
#if defined ENABLE_CHECKING
/* If we get to this point, VAR is an SSA_NAME. If VAR's symbol
was marked for renaming, make sure that its reaching
definition is VAR itself. Otherwise, something has gone
wrong. */
tree sym = SSA_NAME_VAR (var);
if (bitmap_bit_p (vars_to_rename, var_ann (sym)->uid))
gcc_assert (var == get_reaching_def (SSA_NAME_VAR (var)));
#endif
}
} }
/* Register DEF (an SSA_NAME) to be a new definition for its underlying /* Register DEF (an SSA_NAME) to be a new definition for its underlying
...@@ -1509,8 +1541,9 @@ mark_def_site_blocks (void) ...@@ -1509,8 +1541,9 @@ mark_def_site_blocks (void)
/* We no longer need this bitmap, clear and free it. */ /* We no longer need this bitmap, clear and free it. */
sbitmap_free (mark_def_sites_global_data.kills); sbitmap_free (mark_def_sites_global_data.kills);
} }
/* Main entry point into the SSA builder. The renaming process /* Main entry point into the SSA builder. The renaming process
proceeds in five main phases: proceeds in five main phases:
......
...@@ -1417,7 +1417,7 @@ mark_all_v_defs (tree stmt) ...@@ -1417,7 +1417,7 @@ mark_all_v_defs (tree stmt)
get_stmt_operands (stmt); get_stmt_operands (stmt);
FOR_EACH_SSA_TREE_OPERAND (sym, stmt, iter, SSA_OP_VIRTUAL_DEFS) FOR_EACH_SSA_TREE_OPERAND (sym, stmt, iter, SSA_OP_ALL_VIRTUALS)
{ {
if (TREE_CODE (sym) == SSA_NAME) if (TREE_CODE (sym) == SSA_NAME)
sym = SSA_NAME_VAR (sym); sym = SSA_NAME_VAR (sym);
......
...@@ -2643,6 +2643,10 @@ vectorizable_load (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt) ...@@ -2643,6 +2643,10 @@ vectorizable_load (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
new_bb = bsi_insert_on_edge_immediate (pe, new_stmt); new_bb = bsi_insert_on_edge_immediate (pe, new_stmt);
gcc_assert (!new_bb); gcc_assert (!new_bb);
magic = TREE_OPERAND (new_stmt, 0); magic = TREE_OPERAND (new_stmt, 0);
/* Since we have just created a CALL_EXPR, we may need to
rename call-clobbered variables. */
mark_call_clobbered_vars_to_rename ();
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment