This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-phinodes.c: Speed up resize_phi_node.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 03 Nov 2004 00:29:07 -0500 (EST)
- Subject: [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);