i386 stack slot optimisation

James E Wilson wilson@specifixinc.com
Wed Apr 20 00:18:00 GMT 2005


Øyvind Harboe wrote:
> The external functions in my example using the arrays ensures that the
> arrays are not optimized away.

Ah, right, stupid mistake on my part.

> The registers that are spilled are allocated place in the stack frame
> last, so when FRAME_GROWS_DOWNWARD, the displacement offsets are
> smaller for spilled registers than with the stack frame growing upwards.

I see what I missed the first time.  Without optimization, we have stack 
locals, which get allocated early.  With optimization, we have 
pseudo-regs which get spilled to the stack, which get allocated late. 
So you are right, it is FRAME_GROWS_DOWNWARD that caused the behaviour 
you saw.

However, I would not call this an optimization.  This is just how the 
toolchain accidentally happens to work.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list