Stack Alignment

Jeffrey A Law law@cygnus.com
Tue Aug 31 23:20:00 GMT 1999


  In message < 199908151938.MAA22159@beowulf.ucsd.edu >you write:
  > I'd first like to thank the gcc-2.95 people.  I had a code that previously
  > had odd behavior with egcc-2.91 and I suspect it was due to the alignment 
  > of doubles on the stack for a Pentium II machine.  My question is,
  > what rules did they use to align for the stack on the Pentium II?
Quite likely.

The ABI used for x86 machines only requires doubles to be 4 byte aligned,
and earlier versions of gcc made no special effort to provide more alignment
for doubles.

  > Well I saw that gcc-2.95 was out... installed it and just gave it a
  > shot (with little real hope) and lo and behold... my performance woes
  > were fixed (I could get performance on both of the above codes).
  > While I'm happy with that I'd like to know what I was doing wrong to
  > avoid such a problem again.  
gcc-2.95 *attempts* to keep the stack aligned to a 16 byte boundary and to
align doubles on their natural boundary.  

If you ever run into a case where gcc-2.95 does not preserve stack alignment
or a case where a double is not aligned to at least an 8 byte boundary we
would like to see the code so that we can fix it.

jeff



More information about the Gcc mailing list