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-phinodes.c: Speed up resize_phi_node.


Hi,

Attached is a patch to speed up resize_phi_node.

resize_phi_node resizes a PHI node by allocating a new PHI node and
copying the old PHI node to the new one.

With my recent change to tree.h:tree_phi_node, the garbage collector
will not look at the PHI node beyond the first PHI_NUM_ARGS elements.
Therefore, all we have to copy is a portion of the PHI node currently
in use.

The patch implements the above idea by changing the expression to
compute how many bytes to copy.  Notice how OLD_SIZE is used in memcpy
at the end of the patch.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

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

	* tree-phinodes.c (resize_phi_node): Copy only a portion of
	the PHI node currently in use.

Index: tree-phinodes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-phinodes.c,v
retrieving revision 2.17
diff -U4 -d -p -r2.17 tree-phinodes.c
--- tree-phinodes.c	2 Nov 2004 13:23:05 -0000	2.17
+++ tree-phinodes.c	3 Nov 2004 02:17:45 -0000
@@ -255,9 +255,9 @@ resize_phi_node (tree *phi, int len)
   gcc_assert (len >= PHI_ARG_CAPACITY (*phi));
 
   /* Note that OLD_SIZE is guaranteed to be smaller than SIZE.  */
   old_size = (sizeof (struct tree_phi_node)
-	     + (PHI_ARG_CAPACITY (*phi) - 1) * sizeof (struct phi_arg_d));
+	     + (PHI_NUM_ARGS (*phi) - 1) * sizeof (struct phi_arg_d));
 
   new_phi = allocate_phi_node (len);
 
   memcpy (new_phi, *phi, old_size);


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