[lto] Stop using TREE_LIST in functions dealing with PENDING_STMT.
Kazu Hirata
kazu@codesourcery.com
Fri Jun 2 10:13:00 GMT 2006
Hi,
Attached is a patch to stop using TREE_LIST in functions dealing with
PENDING_STMT.
One of the things we'd like to do on the LTO branch is to eliminate
TREE_LIST.
All ssa_redirect_edge does is to queue PHI arguments and results on a
given edge. We can store them in a more compact fashion using
TREE_VEC instead of TREE_LIST.
The only caveat is that we have to count the number of PHI nodes first
to figure out the size of TREE_VEC, but the cost of counting the PHI
is probably still cheaper than the overhead associated with allocating
multiple chunks of memory.
Tested on x86_64-pc-linux-gnu. OK to apply?
Kazu Hirata
2006-06-02 Kazu Hirata <kazu@codesourcery.com>
* tree-ssa.c (ssa_redirect_edge): Store TREE_VEC in
PENDING_STMT.
(reinstall_phi_args): Blah.
* tree-cfgcleanup.c (remove_forwarder_block_with_phi): Blah.
Index: tree-cfgcleanup.c
===================================================================
*** tree-cfgcleanup.c (revision 114291)
--- tree-cfgcleanup.c (working copy)
*************** remove_forwarder_block_with_phi (basic_b
*** 649,663 ****
if (TREE_CODE (def) == SSA_NAME)
{
! tree var;
/* If DEF is one of the results of PHI nodes removed during
redirection, replace it with the PHI argument that used
to be on E. */
! for (var = PENDING_STMT (e); var; var = TREE_CHAIN (var))
{
! tree old_arg = TREE_PURPOSE (var);
! tree new_arg = TREE_VALUE (var);
if (def == old_arg)
{
--- 649,664 ----
if (TREE_CODE (def) == SSA_NAME)
{
! tree pending = PENDING_STMT (e);
! int i = 0;
/* If DEF is one of the results of PHI nodes removed during
redirection, replace it with the PHI argument that used
to be on E. */
! for (i = 0; i < TREE_VEC_LENGTH (pending); i += 2)
{
! tree old_arg = TREE_VEC_ELT (pending, i);
! tree new_arg = TREE_VEC_ELT (pending, i + 1);
if (def == old_arg)
{
Index: tree-ssa.c
===================================================================
*** tree-ssa.c (revision 114291)
--- tree-ssa.c (working copy)
*************** Boston, MA 02110-1301, USA. */
*** 48,77 ****
/* Remove the corresponding arguments from the PHI nodes in E's
destination block and redirect it to DEST. Return redirected edge.
! The list of removed arguments is stored in PENDING_STMT (e). */
edge
ssa_redirect_edge (edge e, basic_block dest)
{
! tree phi;
! tree list = NULL, *last = &list;
! tree src, dst, node;
- /* Remove the appropriate PHI arguments in E's destination block. */
for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
{
! if (PHI_ARG_DEF (phi, e->dest_idx) == NULL_TREE)
! continue;
! src = PHI_ARG_DEF (phi, e->dest_idx);
! dst = PHI_RESULT (phi);
! node = build_tree_list (dst, src);
! *last = node;
! last = &TREE_CHAIN (node);
}
e = redirect_edge_succ_nodup (e, dest);
! PENDING_STMT (e) = list;
return e;
}
--- 48,91 ----
/* Remove the corresponding arguments from the PHI nodes in E's
destination block and redirect it to DEST. Return redirected edge.
! The list of removed arguments is stored in PENDING_STMT (e) as a
! TREE_VEC with PHI_RESULT in the even-th elements and PHI_ARG_DEF in
! the odd-th elements. */
edge
ssa_redirect_edge (edge e, basic_block dest)
{
! tree phi, pending = NULL_TREE;
! unsigned int num_phis = 0;
! unsigned int i;
! bool empty = true;
for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
{
! if (PHI_ARG_DEF (phi, e->dest_idx))
! empty = false;
! num_phis++;
! }
!
! if (!empty)
! {
! pending = make_tree_vec (num_phis * 2);
! /* Remove the appropriate PHI arguments in E's destination block. */
! for (phi = phi_nodes (e->dest), i = 0;
! phi;
! phi = PHI_CHAIN (phi), i += 2)
! {
! if (PHI_ARG_DEF (phi, e->dest_idx) == NULL_TREE)
! continue;
!
! TREE_VEC_ELT (pending, i) = PHI_RESULT (phi);
! TREE_VEC_ELT (pending, i + 1) = PHI_ARG_DEF (phi, e->dest_idx);
! }
}
e = redirect_edge_succ_nodup (e, dest);
! PENDING_STMT (e) = pending;
return e;
}
*************** ssa_redirect_edge (edge e, basic_block d
*** 81,96 ****
void
reinstall_phi_args (edge new_edge, edge old_edge)
{
! tree var, phi;
! if (!PENDING_STMT (old_edge))
return;
! for (var = PENDING_STMT (old_edge), phi = phi_nodes (new_edge->dest);
! var && phi;
! var = TREE_CHAIN (var), phi = PHI_CHAIN (phi))
{
! tree arg = TREE_VALUE (var);
add_phi_arg (phi, arg, new_edge);
}
--- 95,111 ----
void
reinstall_phi_args (edge new_edge, edge old_edge)
{
! tree pending = PENDING_STMT (old_edge), phi;
! unsigned int i;
! if (!pending)
return;
! for (phi = phi_nodes (new_edge->dest), i = 0;
! phi;
! phi = PHI_CHAIN (phi), i += 2)
{
! tree arg = TREE_VEC_ELT (pending, i + 1);
add_phi_arg (phi, arg, new_edge);
}
More information about the Gcc-patches
mailing list