This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lno] Readd patch missing in merge
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 30 May 2004 20:58:05 +0200
- Subject: Re: [lno] Readd patch missing in merge
- References: <20040530165511.GA24054@atrey.karlin.mff.cuni.cz> <m3r7t1pz9c.fsf@gromit.moeb>
Hello,
> > this adds the patch
> > (http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01231.html) that was
> > ommited in merge due to conflicts.
>
> There's no patch appended. Is this desired?
oops, sorry.
> > This patch also makes copy_loop_headers use rewrite_ssa_into_ssa,
> > which was necessary since with the above change it would be complicated
> > to use rewrite_out_of_ssa & rewrite_into_ssa together with lno-branch
> > tree_duplicate_block (that preserves the virtual operands).
Zdenek
Index: ChangeLog.lno
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ChangeLog.lno,v
retrieving revision 1.1.2.172
diff -c -3 -p -r1.1.2.172 ChangeLog.lno
*** ChangeLog.lno 30 May 2004 09:37:18 -0000 1.1.2.172
--- ChangeLog.lno 30 May 2004 16:50:34 -0000
***************
*** 1,4 ****
--- 1,21 ----
2004-05-30 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+ Jeff Law <law@redhat.com>
+
+ * 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.
+ (ssa_mark_def_sites): Prevent set_def_block from doing so.
+
+ * tree-ssa-loop.c (mark_defs_for_rewrite): Record defined ssa names.
+ (duplicate_blocks): Use rewrite_ssa_into_ssa.
+ (pass_ch): Remove TODO_rename_vars.
+
+ 2004-05-30 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* opts.c (decode_options): Enable flag_scalar_evolutions by default.
Index: tree-into-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-into-ssa.c,v
retrieving revision 1.1.4.8
diff -c -3 -p -r1.1.4.8 tree-into-ssa.c
*** tree-into-ssa.c 27 May 2004 14:33:04 -0000 1.1.4.8
--- tree-into-ssa.c 30 May 2004 16:50:34 -0000
*************** static void mark_def_sites (struct dom_w
*** 114,122 ****
basic_block bb, block_stmt_iterator);
static void mark_def_sites_initialize_block (struct dom_walk_data *walk_data,
basic_block bb);
! static void set_def_block (tree, basic_block, bool);
static void set_livein_block (tree, basic_block);
! static bool prepare_operand_for_rename (tree *op_p, size_t *uid_p);
static void insert_phi_nodes (bitmap *, bitmap, tree *);
static void rewrite_stmt (struct dom_walk_data *, basic_block,
block_stmt_iterator);
--- 114,122 ----
basic_block bb, block_stmt_iterator);
static void mark_def_sites_initialize_block (struct dom_walk_data *walk_data,
basic_block bb);
! static void set_def_block (tree, basic_block, bool, bool);
static void set_livein_block (tree, basic_block);
! static bool prepare_operand_for_rename (tree *op_p, size_t *uid_p, bool);
static void insert_phi_nodes (bitmap *, bitmap, tree *);
static void rewrite_stmt (struct dom_walk_data *, basic_block,
block_stmt_iterator);
*************** ssa_mark_def_sites_initialize_block (str
*** 262,268 ****
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, true);
SET_BIT (kills, def_uid);
}
}
--- 262,268 ----
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, true, true);
SET_BIT (kills, def_uid);
}
}
*************** mark_def_sites (struct dom_walk_data *wa
*** 341,347 ****
{
tree *use_p = USE_OP_PTR (uses, i);
! if (prepare_operand_for_rename (use_p, &uid)
&& !TEST_BIT (kills, uid))
set_livein_block (*use_p, bb);
}
--- 341,347 ----
{
tree *use_p = USE_OP_PTR (uses, i);
! if (prepare_operand_for_rename (use_p, &uid, true)
&& !TEST_BIT (kills, uid))
set_livein_block (*use_p, bb);
}
*************** mark_def_sites (struct dom_walk_data *wa
*** 352,358 ****
{
tree *use_p = VUSE_OP_PTR (vuses, i);
! if (prepare_operand_for_rename (use_p, &uid)
&& !TEST_BIT (kills, uid))
set_livein_block (*use_p, bb);
}
--- 352,358 ----
{
tree *use_p = VUSE_OP_PTR (vuses, i);
! if (prepare_operand_for_rename (use_p, &uid, true)
&& !TEST_BIT (kills, uid))
set_livein_block (*use_p, bb);
}
*************** mark_def_sites (struct dom_walk_data *wa
*** 365,380 ****
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))
{
! VDEF_RESULT (vdefs, i) = VDEF_OP (vdefs, i);
! if (!TEST_BIT (kills, uid))
! set_livein_block (VDEF_OP (vdefs, i), bb);
! set_def_block (VDEF_RESULT (vdefs, i), bb, false);
}
}
--- 365,379 ----
vdefs = VDEF_OPS (ann);
for (i = 0; i < NUM_VDEFS (vdefs); i++)
{
! if (prepare_operand_for_rename (VDEF_OP_PTR (vdefs, i), &uid, true))
{
! /* 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, false, false);
}
}
*************** mark_def_sites (struct dom_walk_data *wa
*** 385,393 ****
{
tree *def_p = DEF_OP_PTR (defs, i);
! if (prepare_operand_for_rename (def_p, &uid))
{
! set_def_block (*def_p, bb, false);
SET_BIT (kills, uid);
}
}
--- 384,392 ----
{
tree *def_p = DEF_OP_PTR (defs, i);
! if (prepare_operand_for_rename (def_p, &uid, false))
{
! set_def_block (*def_p, bb, false, false);
SET_BIT (kills, uid);
}
}
*************** ssa_mark_def_sites (struct dom_walk_data
*** 457,463 ****
if (TEST_BIT (gd->names_to_rename, def_uid))
{
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, false);
SET_BIT (kills, def_uid);
}
}
--- 456,462 ----
if (TEST_BIT (gd->names_to_rename, def_uid))
{
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, false, true);
SET_BIT (kills, def_uid);
}
}
*************** ssa_mark_def_sites (struct dom_walk_data
*** 473,493 ****
if (TEST_BIT (gd->names_to_rename, def_uid))
{
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, false);
SET_BIT (kills, def_uid);
}
}
}
/* Mark block BB as the definition site for variable VAR. PHI_P is true if
! VAR is defined by a phi node. */
static void
! set_def_block (tree var, basic_block bb, bool phi_p)
{
struct def_blocks_d *db_p;
! enum need_phi_state state = get_phi_state (var);
db_p = get_def_blocks_for (var);
/* Set the bit corresponding to the block where VAR is defined. */
--- 472,498 ----
if (TEST_BIT (gd->names_to_rename, def_uid))
{
gd->ssa_names[def_uid] = def;
! set_def_block (def, bb, false, true);
SET_BIT (kills, def_uid);
}
}
}
/* Mark block BB as the definition site for variable VAR. PHI_P is true if
! VAR is defined by a phi node. SSA_P is true if we are called from
! rewrite_ssa_into_ssa. */
static void
! set_def_block (tree var, basic_block bb, bool phi_p, bool ssa_p)
{
struct def_blocks_d *db_p;
! enum need_phi_state state;
!
! if (!ssa_p
! && TREE_CODE (var) == SSA_NAME)
! var = SSA_NAME_VAR (var);
+ state = get_phi_state (var);
db_p = get_def_blocks_for (var);
/* Set the bit corresponding to the block where VAR is defined. */
*************** set_livein_block (tree var, basic_block
*** 547,558 ****
}
! /* 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. */
static bool
! prepare_operand_for_rename (tree *op_p, size_t *uid_p)
{
tree var = (TREE_CODE (*op_p) != SSA_NAME) ? *op_p : SSA_NAME_VAR (*op_p);
*uid_p = var_ann (var)->uid;
--- 552,570 ----
}
! /* 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, bool is_use)
{
tree var = (TREE_CODE (*op_p) != SSA_NAME) ? *op_p : SSA_NAME_VAR (*op_p);
*uid_p = var_ann (var)->uid;
*************** prepare_operand_for_rename (tree *op_p,
*** 561,575 ****
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;
! }
return true;
}
--- 573,586 ----
if (vars_to_rename && !bitmap_bit_p (vars_to_rename, *uid_p))
return false;
! /* 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;
}
Index: tree-ssa-loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop.c,v
retrieving revision 1.1.2.3.2.20
diff -c -3 -p -r1.1.2.3.2.20 tree-ssa-loop.c
*** tree-ssa-loop.c 29 May 2004 22:09:03 -0000 1.1.2.3.2.20
--- tree-ssa-loop.c 30 May 2004 16:50:34 -0000
*************** mark_defs_for_rewrite (basic_block bb)
*** 197,216 ****
stmt_ann_t ann;
def_optype defs;
vdef_optype vdefs;
- vuse_optype vuses;
unsigned i;
for (stmt = phi_nodes (bb); stmt; stmt = TREE_CHAIN (stmt))
{
! var = SSA_NAME_VAR (PHI_RESULT (stmt));
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
!
! /* If we have a type_mem_tag, add it as well. Due to rewriting the
! variable out of ssa, we lose its name tag, so we use type_mem_tag
! instead. */
! var = var_ann (var)->type_mem_tag;
! if (var)
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
--- 197,208 ----
stmt_ann_t ann;
def_optype defs;
vdef_optype vdefs;
unsigned i;
for (stmt = phi_nodes (bb); stmt; stmt = TREE_CHAIN (stmt))
{
! var = PHI_RESULT (stmt);
! bitmap_set_bit (vars_to_rename, SSA_NAME_VERSION (var));
}
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
*************** mark_defs_for_rewrite (basic_block bb)
*** 222,254 ****
defs = DEF_OPS (ann);
for (i = 0; i < NUM_DEFS (defs); i++)
{
! var = SSA_NAME_VAR (DEF_OP (defs, i));
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
!
! /* If we have a type_mem_tag, add it as well. Due to rewriting the
! variable out of ssa, we lose its name tag, so we use type_mem_tag
! instead. */
! var = var_ann (var)->type_mem_tag;
! if (var)
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
vdefs = VDEF_OPS (ann);
for (i = 0; i < NUM_VDEFS (vdefs); i++)
{
! var = SSA_NAME_VAR (VDEF_RESULT (vdefs, i));
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
! }
!
! /* We also need to rewrite vuses, since we will copy the statements
! and the ssa versions could not be recovered in the copy. We do
! not have to do this for operands of VDEFS explicitly, since
! they have the same underlying variable as the results. */
! vuses = VUSE_OPS (ann);
! for (i = 0; i < NUM_VUSES (vuses); i++)
! {
! var = SSA_NAME_VAR (VUSE_OP (vuses, i));
! bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
}
}
--- 214,228 ----
defs = DEF_OPS (ann);
for (i = 0; i < NUM_DEFS (defs); i++)
{
! var = DEF_OP (defs, i);
! bitmap_set_bit (vars_to_rename, SSA_NAME_VERSION (var));
}
vdefs = VDEF_OPS (ann);
for (i = 0; i < NUM_VDEFS (vdefs); i++)
{
! var = VDEF_RESULT (vdefs, i);
! bitmap_set_bit (vars_to_rename, SSA_NAME_VERSION (var));
}
}
}
*************** duplicate_blocks (varray_type bbs_to_dup
*** 261,268 ****
unsigned i;
edge preheader_edge, e, e1;
basic_block header, new_header;
! tree phi;
! size_t old_num_referenced_vars = num_referenced_vars;
for (i = 0; i < VARRAY_ACTIVE_SIZE (bbs_to_duplicate); i++)
{
--- 235,245 ----
unsigned i;
edge preheader_edge, e, e1;
basic_block header, new_header;
! tree phi, new_phi, var;
!
! /* TODO: It should be quite easy to keep the dominance information
! up-to-date. */
! free_dominance_info (CDI_DOMINATORS);
for (i = 0; i < VARRAY_ACTIVE_SIZE (bbs_to_duplicate); i++)
{
*************** duplicate_blocks (varray_type bbs_to_dup
*** 276,306 ****
mark_defs_for_rewrite (header);
}
- rewrite_vars_out_of_ssa (vars_to_rename);
-
- for (i = old_num_referenced_vars; i < num_referenced_vars; i++)
- {
- bitmap_set_bit (vars_to_rename, i);
- var_ann (referenced_var (i))->out_of_ssa_tag = 0;
- }
-
for (i = 0; i < VARRAY_ACTIVE_SIZE (bbs_to_duplicate); i++)
{
preheader_edge = VARRAY_GENERIC_PTR_NOGC (bbs_to_duplicate, i);
header = preheader_edge->dest;
! /* We might have split the edge into the loop header when we have
! eliminated the phi nodes, so find the edge to that we want to
! copy the header. */
! while (!header->aux)
! {
! preheader_edge = header->succ;
! header = preheader_edge->dest;
! }
header->aux = NULL;
new_header = duplicate_block (header, preheader_edge);
/* Add the phi arguments to the outgoing edges. */
for (e = header->succ; e; e = e->succ_next)
{
--- 253,279 ----
mark_defs_for_rewrite (header);
}
for (i = 0; i < VARRAY_ACTIVE_SIZE (bbs_to_duplicate); i++)
{
preheader_edge = VARRAY_GENERIC_PTR_NOGC (bbs_to_duplicate, i);
header = preheader_edge->dest;
! if (!header->aux)
! abort ();
header->aux = NULL;
new_header = duplicate_block (header, preheader_edge);
+ /* Create the phi nodes on on entry to new_header. */
+ for (phi = phi_nodes (header), var = PENDING_STMT (preheader_edge);
+ phi;
+ phi = TREE_CHAIN (phi), var = TREE_CHAIN (var))
+ {
+ new_phi = create_phi_node (PHI_RESULT (phi), new_header);
+ add_phi_arg (&new_phi, TREE_VALUE (var), preheader_edge);
+ }
+ PENDING_STMT (preheader_edge) = NULL;
+
/* Add the phi arguments to the outgoing edges. */
for (e = header->succ; e; e = e->succ_next)
{
*************** duplicate_blocks (varray_type bbs_to_dup
*** 314,319 ****
--- 287,297 ----
}
}
}
+
+ calculate_dominance_info (CDI_DOMINATORS);
+
+ rewrite_ssa_into_ssa (vars_to_rename);
+ bitmap_clear (vars_to_rename);
}
/* Checks whether LOOP is a do-while style loop. */
*************** copy_loop_headers (void)
*** 355,363 ****
if (!loops)
return;
- /* We are not going to need or update dominators. */
- free_dominance_info (CDI_DOMINATORS);
-
/* We do not try to keep the information about irreducible regions
up-to-date. */
loops->state &= ~LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS;
--- 333,338 ----
*************** struct tree_opt_pass pass_ch =
*** 449,455 ****
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
! (TODO_rename_vars
! | TODO_dump_func
| TODO_verify_ssa) /* todo_flags_finish */
};
--- 424,429 ----
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
! (TODO_dump_func
| TODO_verify_ssa) /* todo_flags_finish */
};