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]

[lto] Stop using TREE_LIST in functions dealing with PENDING_STMT. (Take 2)


Hi,

Attached is a revised patch to stop using TREE_LIST in functions
dealing with PENDING_STMT.  The original version was posted at:

http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00064.html

This version incorporates comments from Diego.  I've also generated
some numbers.  This time, a unified diff is used.

I ran cc1 compilation fives times with and without my patch and threw
away the best and worst time for the "with" and "without" cases.

Rank  w/o     w/      Diff
----------------------------
    2 295.008 294.326
    3 295.066 294.366
    4 295.258 294.458
----------------------------
Total 885.332 883.150 -0.24%

A tiny improvement or noise?

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

Kazu Hirata

2006-06-03  Kazu Hirata  <kazu@codesourcery.com>

	* tree-ssa.c (ssa_redirect_edge): Store TREE_VEC in
	PENDING_STMT.
	(reinstall_phi_args): Adjust the uses of PENDING_STMT.
	* tree-cfgcleanup.c (remove_forwarder_block_with_phi):
	Likewise.

Index: tree-cfgcleanup.c
===================================================================
--- tree-cfgcleanup.c	(revision 114291)
+++ tree-cfgcleanup.c	(working copy)
@@ -649,15 +649,16 @@
 
 	  if (TREE_CODE (def) == SSA_NAME)
 	    {
-	      tree var;
+	      tree pending = PENDING_STMT (e);
+	      int i = 0;
 
 	      /* If DEF is one of the results of PHI nodes removed during
 		 redirection, replace it with the PHI argument that used
 		 to be on E.  */
-	      for (var = PENDING_STMT (e); var; var = TREE_CHAIN (var))
+	      for (i = 0; i < TREE_VEC_LENGTH (pending); i += 2)
 		{
-		  tree old_arg = TREE_PURPOSE (var);
-		  tree new_arg = TREE_VALUE (var);
+		  tree old_arg = TREE_VEC_ELT (pending, i);
+		  tree new_arg = TREE_VEC_ELT (pending, i + 1);
 
 		  if (def == old_arg)
 		    {
Index: tree-ssa.c
===================================================================
--- tree-ssa.c	(revision 114291)
+++ tree-ssa.c	(working copy)
@@ -48,30 +48,44 @@
 
 /* Remove the corresponding arguments from the PHI nodes in E's
    destination block and redirect it to DEST.  Return redirected edge.
-   The list of removed arguments is stored in PENDING_STMT (e).  */
+   The list of removed arguments is stored in PENDING_STMT (e) as a
+   TREE_VEC with PHI_RESULT in the even elements and PHI_ARG_DEF in
+   the odd elements.  */
 
 edge
 ssa_redirect_edge (edge e, basic_block dest)
 {
-  tree phi;
-  tree list = NULL, *last = &list;
-  tree src, dst, node;
+  tree phi, pending = NULL_TREE;
+  unsigned int num_phis = 0;
+  unsigned int i;
+  bool empty = true;
 
-  /* Remove the appropriate PHI arguments in E's destination block.  */
   for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
     {
-      if (PHI_ARG_DEF (phi, e->dest_idx) == NULL_TREE)
-	continue;
+      if (PHI_ARG_DEF (phi, e->dest_idx))
+	empty = false;
+      num_phis++;
+    }
+
+  if (!empty)
+    {
+      pending = make_tree_vec (num_phis * 2);
 
-      src = PHI_ARG_DEF (phi, e->dest_idx);
-      dst = PHI_RESULT (phi);
-      node = build_tree_list (dst, src);
-      *last = node;
-      last = &TREE_CHAIN (node);
+      /* Remove the appropriate PHI arguments in E's destination block.  */
+      for (phi = phi_nodes (e->dest), i = 0;
+	   phi;
+	   phi = PHI_CHAIN (phi), i += 2)
+	{
+	  if (PHI_ARG_DEF (phi, e->dest_idx) == NULL_TREE)
+	    continue;
+
+	  TREE_VEC_ELT (pending, i) = PHI_RESULT (phi);
+	  TREE_VEC_ELT (pending, i + 1) = PHI_ARG_DEF (phi, e->dest_idx);
+	}
     }
 
   e = redirect_edge_succ_nodup (e, dest);
-  PENDING_STMT (e) = list;
+  PENDING_STMT (e) = pending;
 
   return e;
 }
@@ -81,16 +95,17 @@
 void
 reinstall_phi_args (edge new_edge, edge old_edge)
 {
-  tree var, phi;
+  tree pending = PENDING_STMT (old_edge), phi;
+  unsigned int i;
 
-  if (!PENDING_STMT (old_edge))
+  if (!pending)
     return;
 
-  for (var = PENDING_STMT (old_edge), phi = phi_nodes (new_edge->dest);
-       var && phi;
-       var = TREE_CHAIN (var), phi = PHI_CHAIN (phi))
+  for (phi = phi_nodes (new_edge->dest), i = 0;
+       phi;
+       phi = PHI_CHAIN (phi), i += 2)
     {
-      tree arg = TREE_VALUE (var);
+      tree arg = TREE_VEC_ELT (pending, i + 1);
       add_phi_arg (phi, arg, new_edge);
     }
 


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