On Fri, 2011-12-02 at 13:08 -0600, William J. Schmidt wrote: > > On Fri, 2011-12-02 at 11:28 -0700, Jeff Law wrote: > > On 12/02/11 11:10, William J. Schmidt wrote: > > > > > >> > > >> I see a mention of creating equivalences for redundant PHIs? Are > > >> we just trying to determine that two PHIs are going to result in > > >> the same value? > > > > > > Jeff, see comment #37 in > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39976. The issue is > > > that we have two PHIs in the same block as follows: > > > > > > # prephitmp.35_322 = PHI <prephitmp.35_59(6), prephitmp.35_113(7)> > > > # prephitmp.35_225 = PHI <prephitmp.35_59(6), prephitmp.35_113(7)> > > OK. Make sure you has the phi argument & its edge... Simlarly the > > equality comparison needs to check args & edges. Or s/edge/edge->src/ > > if that's easier. > > > > OK, this is what I was missing. Including edge->src->index in the hash > and equality test to get the actual origin of the arguments should allow > the PHIs to match when they're truly equivalent. Thanks!
Erm, wait. How are PHIs in different blocks going to have the same incoming edges? (I was thinking of control dependence edges, but these are just regular control flow incoming edges, right?) So this really isn't going to help. > > > > > > > The coalescing algorithm in tree-outof-ssa doesn't handle this well > > > and ends up splitting the back arc of a simple loop as a result. > > > I'm creating an equivalence between prephitmp.35_322 and > > > prephitmp.35_225 in this case so that one PHI goes dead and is > > > removed. > > Right. I don't think I bothered with this because I didn't see it > > happening and the comparison of the PHIs with each other gets > > potentially expensive. > > > > As pointed out in > > > the comments, this needs to be restricted to occur only in the > > > same block since the PHIs aren't necessarily equivalent otherwise. > > I must be missing something -- why is the equivalence only valid in > > the same block? > > > > Conceptually this situation isn't any different replacing the second > > PHI with a copy > > blah_225 = blah_322 > > > > And the equivalence is valid for the entire dominator subtree. If you go back a couple of posts in this thread, I have an example of control flow where two control-equivalent blocks contain PHIs with identical constant arguments. But the constants are "defined" in different blocks with different control dependence, so while the constants are equivalent, the PHIs aren't. I originally replaced this with a copy as suggested, which broke things. > > Yes, once the origin of the PHI arguments is correctly taken into > account, then equivalent PHIs can be eliminated within the subtree. ...but none will be found... > > > > > If you really need to create a temporary equiv, pushing the marker, > > create the equiv and pop the marker when equiv dies is simple and easy. > > Yes, this still seems like the most promising thing to do. > > Jeff > > Much obliged, > Bill