This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Reload patch v4
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: Reload patch v4
- From: Bernd Schmidt <crux at Pool dot Informatik dot RWTH-Aachen dot DE>
- Date: Thu, 1 Oct 1998 14:23:50 +0200 (MET DST)
- cc: egcs-patches at cygnus dot com
> > > I think we need to fix forget_old_reloads_1 to handle cases where we
> > > store into a pseudo which happens to be allocated to a hard reg that
> > > has also been used as a spill reg. Imagine
> > >
> > > Use reg 0 as an output reload for some value V
> > >
> > > Psuedo X is made live and is allocated to reg 0
> > > [ ... ]
> > > Pseudo X dies
> > >
> > > Use of V which needs an input reload.
> > >
> > > In this case we might try and use reg0 to satisfy the input reload
> > > even though it no longer holds the value we need.
> >
> > I'm not convinced yet that anything is broken. The situation you describe
> > could already occur with the old reload code, since it has some simple code
> > to avoid spilling within one basic block.
> We only avoid spilling a pseudo in a block if the block needed no spilling of
> any class that contains the hard register the pseudo was allocated to.
>
> Thus if we use reg0 to hold an output reload, then no pseudos can be allocated
> to reg0 in that block and thus the above situation can not currently occur.
>
> [ Remember, we can't inherit a reload across basic block boundaries, at least
> we shouldn't do it right now :-) ]
Are you sure about this? It should be perfectly legal to inherit across
a basic block boundary, unless there's a CODE_LABEL at the start of the second
basic block. I can't find any code that forgets old reloads when a new basic
block starts, only a piece of code that does so at a label.
The situation might look like this:
[first basic block]
Use reg 0 as an output reload for some value V
conditional jump to some place
[second basic block, this one didn't spill reg 0]
Psuedo X is made live and is allocated to reg 0
[ ... ]
Pseudo X dies
conditional jump to some place
[third basic block]
Use of V which needs an input reload.
> > In the above example, if pseudo X is allocated to reg 0, its rtl will have
> > been modified to look like hard reg 0 by the time forget_old_reloads_1 runs > .
> > And in that case, the following piece of code in find_old_reloads_1 should
> > run.
> Normally I would agree with you, but if the pseudo's rtl had been changed,
> then why does forget_old_reload_1 check for regno >= FIRST_PSEUDO_REGISTER?
>
> I *know* pseudos can be passed to that function. I've seen it happen. When
> they do, they do not go through the code you quoted.
Maybe because of this (from eliminate_regs):
/* If SET_DEST changed from a REG to a MEM and INSN is an insn,
write a CLOBBER insn. */
if (GET_CODE (SET_DEST (x)) == REG && GET_CODE (new0) == MEM
&& insn != 0 && GET_CODE (insn) != EXPR_LIST
&& GET_CODE (insn) != INSN_LIST)
emit_insn_after (gen_rtx_CLOBBER (VOIDmode, SET_DEST (x)), insn);
This appears to emit CLOBBERs for some pseudos that didn't get hard registers.
I think I remember that there was code in reload.c that did something similar,
but I can't find it right now.
Bernd