CONUNDRUN & stack alignment

Marc Lehmann (mlehmann@hildesheim.sgh-net.de)
Thu, 13 Feb 1997 23:45:38 +0100 (MET)


>> First guess Alexey. Linux crt0.s doesnt align the stack on an eight byte
>> boundary.
>
>Any reason why it shouldn't? Could this simple thing case a >10%
>performance drop for some applications? If so why wasn't this noticed and
>fixed long ago?

it can decrease performance by over 40% in numerical programs.
Although alexey said that watcom would round the stack down
on procedure entry, I'm a bit reluctant to believe this..
why should any compiler insert an additional "and $-8,%esp"
into every function prolog, where it may cause an
agi stall at the next 3 instructions??

Some reasons why it wasn't implemented (I mean 8-byte stack alignment)
(note that libc-5.4.22 DOES round the stack down correctly
before calling main()) are:

- the standard ABIs for the x86 say that doubles are aligned on a 4 byte boundary
- gcc didnt support it (gcc-2.8.0 will partially)
- changing the alignment of function parameters can break
existing code (like libm)

---------------------------------------------------------------------

for a pentium-optimizing gcc, look at http://www.goof.com/pcg

-----==-
----==-- _
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / mlehmann@hildesheim.sgh-net.de
-=====/_/_//_/\_,_/ /_/\_\ pcg@goof.com
The choice of a GNU generation

----- End of forwarded message from MAILER-DAEMON@cerebro.laendle -----

---------------------------------------------------------------------

for a pentium-optimizing gcc, look at http://www.goof.com/pcg

-----==-
----==-- _
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / mlehmann@hildesheim.sgh-net.de
-=====/_/_//_/\_,_/ /_/\_\ pcg@goof.com
The choice of a GNU generation