This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] tree-phinodes.c: Speed up resize_phi_node.
Hi Diego,
> > * tree-phinodes.c (resize_phi_node): Copy only a portion of
> > the PHI node currently in use.
> >
> OK with a comment above the computation of OLD_SIZE explaining why the
> shortcut is safe.
Thanks. Attached is the final patch that I committed.
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 -c -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 21:22:11 -0000
*************** resize_phi_node (tree *phi, int len)
*** 254,262 ****
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));
new_phi = allocate_phi_node (len);
--- 254,264 ----
gcc_assert (len >= PHI_ARG_CAPACITY (*phi));
! /* 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. */
old_size = (sizeof (struct tree_phi_node)
! + (PHI_NUM_ARGS (*phi) - 1) * sizeof (struct phi_arg_d));
new_phi = allocate_phi_node (len);