From: Jeff Law Date: Wed, 19 May 2004 20:44:32 +0000 (-0600) Subject: tree-into-ssa.c (prepare_operand_for_rename): New argument is_use. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=34eb8991ffc7d23522a2764821e03e0a774a2979;p=gcc.git tree-into-ssa.c (prepare_operand_for_rename): New argument is_use. * tree-into-ssa.c (prepare_operand_for_rename): New argument is_use. If the operand is for a use, then strip away the SSA_NAME, do not strip away the SSA_NAME for a set. Never call release_ssa_name. (mark_def_sites): Appropriately pass additional argument to prepare_operand_for_rename. If a VDEF_RESULT is not an SSA_NAME, then set the VDEF_RESULT to the VDEF_OP. (set_def_block): Strip away any SSA_NAME to get to the real underlying variable. From-SVN: r82035 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 50337db634b..ae3bc3b8cfa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -5,6 +5,15 @@ 2004-05-19 Jeff Law + * tree-into-ssa.c (prepare_operand_for_rename): New argument is_use. + If the operand is for a use, then strip away the SSA_NAME, do not + strip away the SSA_NAME for a set. Never call release_ssa_name. + (mark_def_sites): Appropriately pass additional argument to + prepare_operand_for_rename. If a VDEF_RESULT is not an SSA_NAME, + then set the VDEF_RESULT to the VDEF_OP. + (set_def_block): Strip away any SSA_NAME to get to the real + underlying variable. + * tree-ssa-phiopt.c (value_replacement): Handle the case where the desired edge out of COND_BLOCK reaches OTHER_BLOCK rather than BB directly. diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 368ffdf82c0..91c73b2ec9f 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -109,7 +109,7 @@ static void mark_def_sites_initialize_block (struct dom_walk_data *walk_data, 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); @@ -232,7 +232,7 @@ mark_def_sites (struct dom_walk_data *walk_data, { 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); } @@ -243,7 +243,7 @@ mark_def_sites (struct dom_walk_data *walk_data, { 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); } @@ -255,12 +255,12 @@ mark_def_sites (struct dom_walk_data *walk_data, 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); @@ -274,7 +274,7 @@ mark_def_sites (struct dom_walk_data *walk_data, { 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); @@ -289,8 +289,12 @@ static void 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. */ @@ -348,12 +352,19 @@ set_livein_block (tree var, basic_block bb) } -/* 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; @@ -362,15 +373,14 @@ prepare_operand_for_rename (tree *op_p, size_t *uid_p) 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; }