Gcc extra alignment..

Jamie Lokier egcs@tantalophile.demon.co.uk
Wed Nov 1 16:10:00 GMT 2000


Linus Torvalds wrote:
> 	foo:
> 	        subl    $12, %esp
> 	        call    bar
> 	        addl    $12, %esp
> 	        ret

As opposed to:

> 	foo:
> 	        jmp     bar

> (I wonder why. It's not as if we're adding any new variables in scope or
> anything like that. Strange. I'm sure it has a perfectly good explanation,
> but it does look like some obvious optimization is trivially missed).

The loop causes the tail-call to be missed, hence "call bar" instead of
"jmp bar".

The stack is aligned to 16 bytes for some reason I don't entirely see
the point in.  (Like, why can't the few functions that use 128-bit SIMD
use `and' to align their stack instead?)  So, because of the call GCC
has to adjust the stack to maintain the alignment.

If you're seeing this in the kernel, you probably want to use
-mpreferred-stack-boundary=2 to get better code.

enjoy,
-- Jamie




More information about the Gcc mailing list