This is the mail archive of the 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] O(1) PHI argument look-up - Part 11/n


Attached is a patch to part 11 of my O(1) PHI argument look-up patch.

Now that the infrastructure is in, we can take advantage of it to
clean/spped up various part of tree optimizers.

phi_translate has a linear look-up of a PHI argument.  Since a PHI
array and the corresponding edge vector are lined up, this look-up is
the same as a linear look-up of an edge.

The patch uses find_edge instead, hoping to find an edge quickly even
in presence of a large number of incoming edges to the basic block
that PHI belongs to.

Since VAL is a write-only variable, the patch removes that.

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

Kazu Hirata

2004-11-24  Kazu Hirata  <>

	* tree-ssa-pre.c (phi_translate): Use find_edge to find the
	index of a PHI argument.

Index: tree-ssa-pre.c
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.54
diff -u -d -p -r2.54 tree-ssa-pre.c
--- tree-ssa-pre.c	22 Nov 2004 12:23:58 -0000	2.54
+++ tree-ssa-pre.c	23 Nov 2004 14:59:30 -0000
@@ -922,22 +922,21 @@ phi_translate (tree expr, value_set_t se
     case tcc_exceptional:
 	tree phi = NULL;
-	int i;
+	edge e;
 	gcc_assert (TREE_CODE (expr) == SSA_NAME);
 	  phi = SSA_NAME_DEF_STMT (expr);
 	  return expr;
-	for (i = 0; i < PHI_NUM_ARGS (phi); i++)
-	  if (PHI_ARG_EDGE (phi, i)->src == pred)
-	    {
-	      tree val;
-	      if (is_undefined_value (PHI_ARG_DEF (phi, i)))
-		return NULL;
-	      val = vn_lookup_or_add (PHI_ARG_DEF (phi, i), NULL);
-	      return PHI_ARG_DEF (phi, i);
-	    }
+	e = find_edge (pred, bb_for_stmt (phi));
+	if (e)
+	  {
+	    if (is_undefined_value (PHI_ARG_DEF (phi, e->dest_idx)))
+	      return NULL;
+	    vn_lookup_or_add (PHI_ARG_DEF (phi, e->dest_idx), NULL);
+	    return PHI_ARG_DEF (phi, e->dest_idx);
+	  }
       return expr;

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