This is the mail archive of the
mailing list for the GCC project.
[patch] tree-phinode.c: Speed up remove_all_phi_nodes_for.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 06 Nov 2004 08:33:16 -0500 (EST)
- Subject: [patch] tree-phinode.c: Speed up remove_all_phi_nodes_for.
Attached is a patch to speed up remove_all_phi_nodes_for by using a
pointer to another pointer.
remove_all_phi_nodes_for removes PHI nodes whose results are in a
given bitmap. This is done by traversing each PHI chain while
building another PHI chain aside.
It turns out that we can simplify the construction of the new PHI
chain if we use a pointer to the pointer to the last PHI node in the
new chain. We can remove two "if" statements as a result.
Tested on i686-pc-linux-gnu. OK to apply?
2004-11-06 Kazu Hirata <firstname.lastname@example.org>
* tree-phinodes.c (remove_all_phi_nodes_for): Speed up using a
pointer to the last PHI node in the new PHI chain.
RCS file: /cvs/gcc/gcc/gcc/tree-phinodes.c,v
retrieving revision 2.19
diff -u -d -p -r2.19 tree-phinodes.c
--- tree-phinodes.c 4 Nov 2004 23:30:16 -0000 2.19
+++ tree-phinodes.c 5 Nov 2004 15:09:32 -0000
@@ -449,10 +449,10 @@ remove_all_phi_nodes_for (bitmap vars)
/* Build a new PHI list for BB without variables in VARS. */
- tree phi, new_phi_list, last_phi, next;
+ tree phi, new_phi_list, next;
+ tree *lastp = &new_phi_list;
- last_phi = new_phi_list = NULL_TREE;
- for (phi = phi_nodes (bb), next = NULL; phi; phi = next)
+ for (phi = phi_nodes (bb); phi; phi = next)
tree var = SSA_NAME_VAR (PHI_RESULT (phi));
@@ -465,13 +465,8 @@ remove_all_phi_nodes_for (bitmap vars)
Note that fact in PHI_REWRITTEN. */
PHI_REWRITTEN (phi) = 1;
- if (new_phi_list == NULL_TREE)
- new_phi_list = last_phi = phi;
- PHI_CHAIN (last_phi) = phi;
- last_phi = phi;
+ *lastp = phi;
+ lastp = &PHI_CHAIN (phi);
@@ -483,8 +478,7 @@ remove_all_phi_nodes_for (bitmap vars)
/* Make sure the last node in the new list has no successors. */
- if (last_phi)
- PHI_CHAIN (last_phi) = NULL_TREE;
+ *lastp = NULL;
bb_ann (bb)->phi_nodes = new_phi_list;
#if defined ENABLE_CHECKING