Ian Lance Taylor wrote:
Jeff Law <l...@redhat.com> writes:

No, that makes no sense.  What I'm suggesting is that we fix the stack
offsets of all local variables before register allocation, based on a
conservative assessment of how many registers will be saved on the
stack.  Then we know during register allocation whether the memory
reference will be in or out of the +- 16 byte range.
Just fixing the offset is not sufficient for the case I'm concerned
about because you don't know what offsets are valid until you know
precisely what registers are used in the insn.   That's absolutely
critical.  So you have to assume worst case which is you can only use
the +-16 byte insns which will pessimize just about every stack
reference.

You fix the offset of the value stored on the stack.  Given that, you
know which instruction you can use.
No, it's not that simple. If you spill, then you can change the registers that are used and that in turn changes the set of valid offsets in reg+d instructions.
Perhaps the confusion in this case is because we're not really
relaxing -- we're dealing with a case where the offset alone isn't
enough to determine if the addressing mode is valid.

The confusion may be that we may be talking about different things.
I'm talking about removing this loop in the reload function:

  /* This loop scans the entire function each go-round
     and repeats until one repetition spills no additional hard regs.  */
Most of that loop's real work isn't in the address relaxation code, but in digging through instructions to determine what needs to be reloaded and how many registers are necessary to perform the requested reloads.

It is unfortunate that spilling and allocating stack slots requires the loop to iterate again -- I do believe it is possible to remove some silly iterating, but removing the whole loop is a pipe dream at the moment.



Without knowing the size of the frame, how do you plan on doing this
without making the assumption that nothing is going to fit in the
shorter displacement variants?  How can you do this when the range of
valid displacements can change because the register you used got
spilled and you got a register from a different class (which in turn
has a drastically smaller set of valid displacements).
I'm saying that you guess the size of the frame, so your premise does
not describe the aproach that I am suggesting.
But the offsets are relative to the size of the frame.  So I don't see
how you can set the offsets without knowing the size of the frame.

You know the size of the frame, by guessing conservatively as to how
many registers will be required.
A conservative guess would be something like "every pseudo needs a slot" -- anything less than that isn't conservative, it's optimistic. Guessing conservative is going to be wasteful on so many levels. Guessing optimistic doesn't solve any of the problems we want to solve as we still need to deal with the case where our guess was wrong.

jeff


Reply via email to