static void compute_global_livein (bitmap, bitmap);
static void set_def_block (tree, basic_block);
static void set_livein_block (tree, basic_block);
-static bool prepare_operand_for_rename (tree *op_p, size_t *uid_p);
+static bool prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool);
static void insert_phi_nodes (bitmap *);
static void rewrite_stmt (struct dom_walk_data *, basic_block,
block_stmt_iterator);
{
tree *use_p = USE_OP_PTR (uses, i);
- if (prepare_operand_for_rename (use_p, &uid)
+ if (prepare_operand_for_rename (use_p, &uid, true)
&& !TEST_BIT (kills, uid))
set_livein_block (*use_p, bb);
}
{
tree *use_p = VUSE_OP_PTR (vuses, i);
- if (prepare_operand_for_rename (use_p, &uid))
+ if (prepare_operand_for_rename (use_p, &uid, true))
set_livein_block (*use_p, bb);
}
vdefs = VDEF_OPS (ann);
for (i = 0; i < NUM_VDEFS (vdefs); i++)
{
- size_t dummy;
-
- if (prepare_operand_for_rename (VDEF_OP_PTR (vdefs, i), &uid)
- && prepare_operand_for_rename (VDEF_RESULT_PTR (vdefs, i), &dummy))
+ if (prepare_operand_for_rename (VDEF_OP_PTR (vdefs, i), &uid, true))
{
- VDEF_RESULT (vdefs, i) = VDEF_OP (vdefs, i);
+ /* If we do not already have an SSA_NAME for our destination,
+ then set the destination to the source. */
+ if (TREE_CODE (VDEF_RESULT (vdefs, i)) != SSA_NAME)
+ VDEF_RESULT (vdefs, i) = VDEF_OP (vdefs, i);
set_livein_block (VDEF_OP (vdefs, i), bb);
set_def_block (VDEF_RESULT (vdefs, i), bb);
{
tree *def_p = DEF_OP_PTR (defs, i);
- if (prepare_operand_for_rename (def_p, &uid))
+ if (prepare_operand_for_rename (def_p, &uid, false))
{
set_def_block (*def_p, bb);
SET_BIT (kills, uid);
set_def_block (tree var, basic_block bb)
{
struct def_blocks_d *db_p;
- enum need_phi_state state = var_ann (var)->need_phi_state;
+ enum need_phi_state state;
+
+ if (TREE_CODE (var) == SSA_NAME)
+ var = SSA_NAME_VAR (var);
+ state = var_ann (var)->need_phi_state;
db_p = get_def_blocks_for (var);
/* Set the bit corresponding to the block where VAR is defined. */
}
-/* If the operand pointed by OP_P needs to be renamed, strip away SSA_NAME
- wrappers (if needed) and return true. The unique ID for the operand's
- variable will be stored in *UID_P. */
+/* If the operand pointed to by OP_P needs to be renamed, then
+
+ 1. If OP_P is used (rather than set), then strip away any SSA_NAME
+ wrapping the operand.
+
+ 2. Set *UID_P to the underlying variable's uid.
+
+ 3. Return true.
+
+ Otherwise return false. */
static bool
-prepare_operand_for_rename (tree *op_p, size_t *uid_p)
+prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool is_use)
{
tree var = (TREE_CODE (*op_p) != SSA_NAME) ? *op_p : SSA_NAME_VAR (*op_p);
*uid_p = var_ann (var)->uid;
if (vars_to_rename && !bitmap_bit_p (vars_to_rename, *uid_p))
return false;
- /* The variable needs to be renamed. If it already had an
- SSA_NAME, strip it off. This way, the SSA rename pass
- doesn't need to deal with existing SSA names. */
- if (TREE_CODE (*op_p) == SSA_NAME)
- {
- if (default_def (SSA_NAME_VAR (*op_p)) != *op_p)
- release_ssa_name (*op_p);
- *op_p = var;
- }
+ /* The variable needs to be renamed. If this is a use which already
+ has an SSA_NAME, then strip it off.
+
+ By not throwing away SSA_NAMEs on assignments, we avoid a lot of
+ useless churn of SSA_NAMEs without having to overly complicate the
+ renamer. */
+ if (TREE_CODE (*op_p) == SSA_NAME && is_use)
+ *op_p = var;
return true;
}