This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] insert before and out-of-ssa patchlets
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: 02 Jun 2003 10:57:44 -0400
- Subject: [tree-ssa] insert before and out-of-ssa patchlets
I've commited the following patch. Its fixes 2 bugs in insert_before and
a bug in the out-of-ssa algorithm which was causing too many copies to
be inserted.
Andrew
* tree-cfg.c (bsi_insert_before): Update end of block pointer if we
inserted before the last stmt in a block. (The container changed).
* tree-ssa.c (elim_backward): Inserting copy should be within
conditional check.
(elim_create): Only select one bit instead of the all.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.96
diff -c -p -r1.1.4.96 tree-cfg.c
*** tree-cfg.c 24 May 2003 13:08:50 -0000 1.1.4.96
--- tree-cfg.c 2 Jun 2003 13:43:23 -0000
*************** bsi_insert_before (curr_bsi, t, mode)
*** 3553,3564 ****
tsi_link_before (&inserted_tsi, t, TSI_NEW_STMT);
add_stmt_to_bb (tsi_container (inserted_tsi), curr_bb, parent);
- same_tsi = inserted_tsi;
- tsi_next (&same_tsi);
-
if (curr_container == curr_bb->head_tree_p)
{
! curr_bb->head_tree_p = tsi_container (same_tsi);
/* If the parent block is a COND_EXPR or LOOP_EXPR, check if this
is the block which they point to and update if necessary. */
if (parent)
--- 3553,3561 ----
tsi_link_before (&inserted_tsi, t, TSI_NEW_STMT);
add_stmt_to_bb (tsi_container (inserted_tsi), curr_bb, parent);
if (curr_container == curr_bb->head_tree_p)
{
! curr_bb->head_tree_p = tsi_container (inserted_tsi);
/* If the parent block is a COND_EXPR or LOOP_EXPR, check if this
is the block which they point to and update if necessary. */
if (parent)
*************** bsi_insert_before (curr_bsi, t, mode)
*** 3584,3589 ****
--- 3581,3596 ----
}
}
}
+
+ same_tsi = inserted_tsi;
+ tsi_next (&same_tsi);
+
+ /* The end block pointer can be modified when we insert before the last stmt
+ in a block. This occurs because we insert a new container for the last
+ stmt. */
+
+ if (curr_container == curr_bb->end_tree_p)
+ curr_bb->end_tree_p = tsi_container (same_tsi);
if (mode == BSI_SAME_STMT)
bsi_update_from_tsi (curr_bsi, same_tsi);
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.83
diff -c -p -r1.1.4.83 tree-ssa.c
*** tree-ssa.c 29 May 2003 23:10:59 -0000 1.1.4.83
--- tree-ssa.c 2 Jun 2003 13:43:24 -0000
*************** elim_backward (g, T)
*** 1071,1080 ****
EXECUTE_IF_SET_IN_BITMAP (g->pred[T], 0, P,
{
if (!TEST_BIT (g->visited, P))
! elim_backward (g, P);
! insert_copy_on_edge (g->e,
! partition_to_var (g->map, P),
! partition_to_var (g->map, T));
});
}
--- 1071,1082 ----
EXECUTE_IF_SET_IN_BITMAP (g->pred[T], 0, P,
{
if (!TEST_BIT (g->visited, P))
! {
! elim_backward (g, P);
! insert_copy_on_edge (g->e,
! partition_to_var (g->map, P),
! partition_to_var (g->map, T));
! }
});
}
*************** elim_create (g, T)
*** 1105,1118 ****
}
else
{
! EXECUTE_IF_SET_IN_BITMAP (g->succ[T], 0, S,
{
SET_BIT (g->visited, T);
insert_copy_on_edge (g->e,
partition_to_var (g->map, T),
partition_to_var (g->map, S));
! });
! bitmap_clear (g->succ[T]);
}
}
--- 1107,1121 ----
}
else
{
! S = bitmap_first_set_bit (g->succ[T]);
! if (S != -1)
{
SET_BIT (g->visited, T);
+ bitmap_clear_bit (g->succ[T], S);
insert_copy_on_edge (g->e,
partition_to_var (g->map, T),
partition_to_var (g->map, S));
! }
}
}