This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Gcc extra alignment..


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]