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 12/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 08:23:42 -0500 (EST)
- Subject: [patch] O(1) PHI argument look-up - Part 12/n
Hi,
Attached is a patch to part 12 of my O(1) PHI argument look-up patch.
lv_adjust_loop_header_phi 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.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-11-24 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-loop-manip.c (lv_adjust_loop_header_phi): Use
find_edge to find the index of a PHI argument.
Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.18
diff -c -d -p -r2.18 tree-ssa-loop-manip.c
*** tree-ssa-loop-manip.c 14 Nov 2004 04:08:07 -0000 2.18
--- tree-ssa-loop-manip.c 23 Nov 2004 13:58:26 -0000
*************** lv_adjust_loop_header_phi (basic_block f
*** 667,680 ****
phi2 && phi1;
phi2 = PHI_CHAIN (phi2), phi1 = PHI_CHAIN (phi1))
{
! int i;
! for (i = 0; i < PHI_NUM_ARGS (phi2); i++)
{
! if (PHI_ARG_EDGE (phi2, i)->src == new_head)
! {
! tree def = PHI_ARG_DEF (phi2, i);
! add_phi_arg (&phi1, def, e);
! }
}
}
}
--- 667,678 ----
phi2 && phi1;
phi2 = PHI_CHAIN (phi2), phi1 = PHI_CHAIN (phi1))
{
! edge e2 = find_edge (new_head, second);
!
! if (e2)
{
! tree def = PHI_ARG_DEF (phi2, e2->dest_idx);
! add_phi_arg (&phi1, def, e);
}
}
}