This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] tree-phinode.c: Speed up remove_all_phi_nodes_for.


Hi,

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?

Kazu Hirata

2004-11-06  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-phinodes.c (remove_all_phi_nodes_for): Speed up using a
	pointer to the last PHI node in the new PHI chain.

Index: tree-phinodes.c
===================================================================
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)
   FOR_EACH_BB (bb)
     {
       /* 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;
-	      else
-		{
-		  PHI_CHAIN (last_phi) = phi;
-		  last_phi = phi;
-		}
+	      *lastp = phi;
+	      lastp = &PHI_CHAIN (phi);
 	    }
 	  else
 	    {
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]