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]

[tree-ssa] More PHI node recycling


Richard pointed out that we were not recycling dead PHI nodes created
when we resized PHI nodes.  This patch fixes that minor oversight.  It
also avoids the overhead of updating the PHI chains in cases where it
is not necessary.

Bootstrapped and regression tested on i686-pc-linux-gnu.

	* tree-phinodes.c (add_phi_arg): If we receive a new node from
	resize_phi_node, then release the old node and update the PHI
	chain.

Index: tree-phinodes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-phinodes.c,v
retrieving revision 1.1.2.4
diff -c -3 -p -r1.1.2.4 tree-phinodes.c
*** tree-phinodes.c	2 Dec 2003 04:21:53 -0000	1.1.2.4
--- tree-phinodes.c	2 Dec 2003 19:58:37 -0000
*************** add_phi_arg (tree *phi, tree def, edge e
*** 286,314 ****
  
    if (i >= PHI_ARG_CAPACITY (*phi))
      {
-       /* Resize the phi.  Unfortunately, this also relocates it...  */
        tree old_phi = *phi;
  
        resize_phi_node (phi, i + 4);
  
        /* The result of the phi is defined by this phi node.  */
        SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
  
!       /* Update the list head if replacing the first listed phi.  */
!       if (phi_nodes (e->dest) == old_phi)
! 	VARRAY_TREE (tree_phi_root, e->dest->index) = *phi;
!       else
  	{
!           /* Traverse the list looking for the phi node to chain to.  */
! 	  tree p;
! 	  for (p = phi_nodes (e->dest);
! 	       p && TREE_CHAIN (p) != old_phi;
! 	       p = TREE_CHAIN (p));
  
! 	  if (!p)
! 	    abort ();
  
! 	  TREE_CHAIN (p) = *phi;
  	}
      }
  
--- 286,323 ----
  
    if (i >= PHI_ARG_CAPACITY (*phi))
      {
        tree old_phi = *phi;
  
+       /* Resize the phi.  Unfortunately, this may also relocate it.  */
        resize_phi_node (phi, i + 4);
  
        /* The result of the phi is defined by this phi node.  */
        SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
  
!       /* If the PHI was relocated, update the PHI chains appropriately and
! 	 release the old PHI node.  */
!       if (*phi != old_phi)
  	{
! 	  release_phi_node (old_phi);
  
! 	  /* Update the list head if replacing the first listed phi.  */
! 	  if (phi_nodes (e->dest) == old_phi)
! 	    VARRAY_TREE (tree_phi_root, e->dest->index) = *phi;
! 	  else
! 	    {
! 	      /* Traverse the list looking for the phi node to chain to.  */
! 	      tree p;
  
! 	      for (p = phi_nodes (e->dest);
! 		   p && TREE_CHAIN (p) != old_phi;
! 		   p = TREE_CHAIN (p))
! 		;
! 
! 	      if (!p)
! 		abort ();
! 
! 	      TREE_CHAIN (p) = *phi;
! 	    }
  	}
      }
  








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