On Wed, Nov 21, 2018 at 3:28 AM Jeff Law <l...@redhat.com> wrote: > > Richi's recent change to fix 88069 is causing various targets to fail > tree-ssa/20030711-2.c. That test is verifying a variety of > optimizations occur during the first DOM pass. > > Prior to Richi's change FRE1 would do some significant cleanups of the > IL and as a result DOM was fully able to optimize the resultant code.
Hum... I obviously missed the FAIL during testing somehow. FRE1 behavior shouldn't change so I'll fixup. Richard. > After Richi's change we've got a redundant load in the IL. After > analyzing the CFG and IL it was clear that DOM *should* be able to > remove the redundant load, but simply wasn't. > > DOM would discover that it could statically determine the result of a > branch condition. This resulted in one arm of the branch becoming > unreachable. That in turn caused some PHI nodes to become degenerates. > > Normally when a PHI node becomes a degenerate we record it as a copy in > the const_and_copies table and *most* of the time we'll propagate the > src value into uses of the dest. But propagation is not guaranteed > (there's a BZ around that issue you can find if you dig into the history > of some of this code). > > Anyway, exposing the degenerate PHI *should* have exposed the redundant > load, but we didn't record anything into the const/copies table for the > virtual phi. That's a conscious decision to avoid issues with > overlapping lifetimes of virtual SSA_NAMEs. > > While investigating the history here I noticed Richi's little trick > which allows propagation of virtuals if we propagate to all the uses. > Twiddling DOM to use that same trick results in the virtual operand > propagating. That in turn allows DOM to see and remove the redundant load. > > Bootstrapped and regression tested on x86_64 where is fixes > 20030711-2.c. Also verified that it fixed various other targets where > that test had started failing. > > Installing on the trunk. > > jeff