This is the mail archive of the gcc-help@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]
Other format: [Raw text]

RE: extra space on stack allocated for recursive functions


Chris Meyer wrote: 

> I noticed that when I call a recursive function there is extra space
> allocated on the stack.

You mean this subl, say?

>	subl	$12, %esp
>	pushl	$3
>	call	factorial

It's keeping the stack pointer 16-byte aligned. If you passed two arguments
it would have subled $8 first, etc. This isn't unique to recursive
functions.

Why? It's probably so you can get all the arguments in a single L1 cache
load or something. I'd guess it's in the Intel's optimisation guide,
downloadable as part of the architecture docs.

Rup.


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