Default stack alignment on x86-64, fedora 11

Ian Lance Taylor iant@google.com
Thu Aug 27 09:17:00 GMT 2009


Rohit Garg <rpg.314@gmail.com> writes:

> My real issue is that I would like to declare certain variables on
> stack as aligned on 16 byte boundaries, so I can load/store them
> quickly.

You should be able to use __attribute__ ((aligned (16))) to make this
happen.

> This here says that stack can be aligned to 16 bytes, which is also
> default. If I wish to avoid any code size increase, is there any
> particular order of declaring these variables which I should follow so
> that no extra space is consumed for padding. I would have thought that
> GCC would be smart enough to reorder variables to minimize code bloat,
> but.....

gcc will normally sort the stack variables to avoid wasting stack space.
The order in which you declare the variables in your program is
irrelevant.  That said, stack space is fairly cheap.  Why do you need to
optimize it?

Ian



More information about the Gcc-help mailing list