This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] O(1) PHI argument look-up - Part 13/n
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 24 Nov 2004 09:36:33 -0500 (EST)
- Subject: [patch] O(1) PHI argument look-up - Part 13/n
Hi,
Attached is a patch to part 13 of my O(1) PHI argument look-up patch.
cprop_into_successor_phis has ugly code to find the index of a PHI
argument. Specifically, given an edge E, it caches the index of a PHI
argument for E, hoping that the same index in another PHI will also
correspond to E.
The patch removes the ugly code and uses e->dest_idx instead.
Tested on i686-pc-linux-gnu. OK to apply?
p.s.
Perhaps the variable name "hint" isn't a good name any more because we
know for sure that "hint = e->dest_idx;" gives us the correct index.
If you feel that the naming does not make sense, I'd like to address
that in a separate patch. I'd like this patch to address the index
calculation only.
Kazu Hirata
2004-11-23 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-dom.c (cprop_into_successor_phis): Remove code to
find the index of a PHI argument. Use e->dest_idx instead.
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.68
diff -u -d -p -r2.68 tree-ssa-dom.c
--- tree-ssa-dom.c 19 Nov 2004 18:21:42 -0000 2.68
+++ tree-ssa-dom.c 23 Nov 2004 13:59:38 -0000
@@ -2296,7 +2296,6 @@ cprop_into_successor_phis (basic_block b
FOR_EACH_EDGE (e, ei, bb->succs)
{
tree phi;
- int phi_num_args;
int hint;
/* If this is an abnormal edge, then we do not want to copy propagate
@@ -2308,43 +2307,13 @@ cprop_into_successor_phis (basic_block b
if (! phi)
continue;
- /* There is no guarantee that for any two PHI nodes in a block that
- the phi alternative associated with a particular edge will be
- at the same index in the phi alternative array.
-
- However, it is very likely they will be the same. So we keep
- track of the index of the alternative where we found the edge in
- the previous phi node and check that index first in the next
- phi node. If that hint fails, then we actually search all
- the entries. */
- phi_num_args = PHI_NUM_ARGS (phi);
- hint = phi_num_args;
+ hint = e->dest_idx;
for ( ; phi; phi = PHI_CHAIN (phi))
{
- int i;
tree new;
use_operand_p orig_p;
tree orig;
- /* If the hint is valid (!= phi_num_args), see if it points
- us to the desired phi alternative. */
- if (hint != phi_num_args && PHI_ARG_EDGE (phi, hint) == e)
- ;
- else
- {
- /* The hint was either invalid or did not point to the
- correct phi alternative. Search all the alternatives
- for the correct one. Update the hint. */
- for (i = 0; i < phi_num_args; i++)
- if (PHI_ARG_EDGE (phi, i) == e)
- break;
- hint = i;
- }
-
- /* If we did not find the proper alternative, then something is
- horribly wrong. */
- gcc_assert (hint != phi_num_args);
-
/* The alternative may be associated with a constant, so verify
it is an SSA_NAME before doing anything with it. */
orig_p = PHI_ARG_DEF_PTR (phi, hint);