RFA PR 48770
Bernd Schmidt
bernds@codesourcery.com
Wed May 25 13:45:00 GMT 2011
On 05/24/2011 03:34 PM, Jeff Law wrote:
>
> This has gone latent on the trunk, but the underlying issue hasn't been
> resolved.
>
> ira.c::update_equiv_regs can create REG_EQUIV notes for equivalences
> which are local to a block rather than the traditional function-wide
> equivalences we typically work with.
>
> This occurs when we have an insn that loads a pseudo from a MEM and the
> pseudo is used within only a single block and the MEM remains unchanged
> through the life of the pseudo.
>
> Starting with the assumption that we're going to create a block local
> pseudo under the rules noted above, consider this RTL:
>
> (set (reg X) (some address))
> (set (reg Y) (mem (reg X)))
> (use Y)
>
>
> We're going to create an equivalence between (reg Y) and its memory
> location in update_equiv_regs. Assume IRA is able to allocate a hard
> reg for reg X, but not reg Y.
>
> reload's strategy in this situation will be to remove the insn which
> creates the equivalence between reg Y and the memory location. Uses of
> reg Y will be replaced with the equivalent memory location.
>
> That's all fine and good, except reload uses delete_dead_insn, which
> deletes the equivalencing insn, but also recursively tries to remove the
> prior insn if it becomes dead as a result of removing the equivalencing
> insn.
>
> Anyway, continuing with our example, reg X gets a hard reg, so our RTL
> will look something like
>
> (set (reg 0) (some address))
> (set (reg Y) (mem (reg 0)))
> (use Y)
>
> Then we remove the equivalencing insn resulting in
>
> (set (reg 0) (some address)
> (use Y)
>
> And we recurse from delete_dead_insn and determine that the first insn
> was dead as well, so it gets removed leaving:
>
> (use Y)
>
> We then replace Y with its equivalent memory location
>
> (use (mem (reg 0))
>
> At which point we lose because hard reg 0 is no longer initialized.
>
>
> The code in question is literally 20 years old and predates running any
> real dead code elimination after reload. ISTM the right thing to do is
> stop using delete_dead_insn in this code and let the post-reload DCE
> pass do its job. That allows us to continue to record the block local
> equivalence.
Sounds like the right thing to do. OK. (Can we eliminate the other caller?)
I've looked at code generation; it appears unchanged on i686-linux,
which I think is the expected result. There are minor differences in
assembly output on mips64-linux. If you want to look at it, I'm
attaching a testcase - compile with "-O2 -fno-reorder-blocks".
Bernd
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bitmap.i
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110525/081ed517/attachment.ksh>
More information about the Gcc-patches
mailing list