This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-phinode.c: Clean up remove_phi_node.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 02 Mar 2005 16:22:18 -0500 (EST)
- Subject: [patch] tree-phinode.c: Clean up remove_phi_node.
Hi,
Attached is a patch to clean up remove_phi_node.
First note that there is some code duplication, namely calls to
release_ssa_name and release_phi_node.
Next note that the first iteration of the "for" loop in
remove_phi_node never has "t == phi" because of the second "if"
statement.
The patch cleans up remove_phi_node while resolving the problems
above. It assumes that bb_for_stmt (phi) == bb.
Looking at the tree dump, I see that remove_phi_node now has 5 basic
blocks instead of 15 basic blocks.
The rdtsc instruction on x86 shows 5% speed-up although its effect is
not measurable on a larger scale.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2005-03-02 Kazu Hirata <kazu@cs.umass.edu>
* tree-phinodes.c (remove_phi_node): Clean up by factoring out
calls to release_ssa_name and release_phi_node.
Index: tree-phinodes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-phinodes.c,v
retrieving revision 2.29
diff -c -d -p -r2.29 tree-phinodes.c
*** tree-phinodes.c 2 Dec 2004 02:49:29 -0000 2.29
--- tree-phinodes.c 1 Mar 2005 04:47:31 -0000
*************** remove_phi_args (edge e)
*** 404,439 ****
void
remove_phi_node (tree phi, tree prev, basic_block bb)
{
! if (prev)
! {
! /* Rewire the list if we are given a PREV pointer. */
! PHI_CHAIN (prev) = PHI_CHAIN (phi);
! /* If we are deleting the PHI node, then we should release the
! SSA_NAME node so that it can be reused. */
! release_ssa_name (PHI_RESULT (phi));
! release_phi_node (phi);
! }
! else if (phi == phi_nodes (bb))
{
! /* Update the list head if removing the first element. */
! bb_ann (bb)->phi_nodes = PHI_CHAIN (phi);
!
! /* If we are deleting the PHI node, then we should release the
! SSA_NAME node so that it can be reused. */
! release_ssa_name (PHI_RESULT (phi));
! release_phi_node (phi);
}
else
{
! /* Traverse the list looking for the node to remove. */
! tree prev, t;
! prev = NULL_TREE;
! for (t = phi_nodes (bb); t && t != phi; t = PHI_CHAIN (t))
! prev = t;
! if (t)
! remove_phi_node (t, prev, bb);
}
}
--- 404,430 ----
void
remove_phi_node (tree phi, tree prev, basic_block bb)
{
! tree *loc;
! if (prev)
{
! loc = &PHI_CHAIN (prev);
}
else
{
! for (loc = &(bb_ann (bb)->phi_nodes);
! *loc != phi;
! loc = &PHI_CHAIN (*loc))
! ;
}
+
+ /* Remove PHI from the chain. */
+ *loc = PHI_CHAIN (phi);
+
+ /* If we are deleting the PHI node, then we should release the
+ SSA_NAME node so that it can be reused. */
+ release_ssa_name (PHI_RESULT (phi));
+ release_phi_node (phi);
}