This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


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

Re: -mpreferred-stack-boundary=2?


Christopher Faylor wrote:
> 
> I just added the -mpreferred-stack-boundary=2 option to Makefile.common.
> Is there a good reason not to do this?  From the description in
> gcc.info, it seems like the cases that they are talking about don't
> affect the cygwin part of things, although it would conceivably be iffy
> to use this switch in the newlib.
> 
> The code size reduction is noticeable.
> 

Hmm...  In my use of this switch I set the value to 8.  I did this based
on the documentation for this switch in the info file.

<info>
`-mpreferred-stack-boundary=NUM'
     Attempt to keep the stack boundary aligned to a 2 raised to NUM
     byte boundary.  If `-mpreferred-stack-boundary' is not specified,
     the default is 4 (16 bytes or 128 bits).

     The stack is required to be aligned on a 4 byte boundary.  On
     Pentium and PentiumPro, `double' and `long double' values should be
     aligned to an 8 byte boundary (see `-malign-double') or suffer
     significant run time performance penalties.  On Pentium III, the
     Streaming SIMD Extention (SSE) data type `__m128' suffers similar
     penalties if it is not 16 byte aligned.

     To ensure proper alignment of this values on the stack, the stack
     boundary must be as aligned as that required by any value stored
     on the stack.  Further, every function must be generated such that
     it keeps the stack aligned.  Thus calling a function compiled with
     a higher preferred stack boundary from a function compiled with a
     lower preferred stack boundary will most likely misalign the
     stack.  It is recommended that libraries that use callbacks always
     use the default setting.

     This extra alignment does consume extra stack space.  Code that is
     sensitive to stack space usage, such as embedded systems and
     operating system kernels, may want to reduce the preferred
     alignment to `-mpreferred-stack-boundary=2'.
</info>

The bits on pentium suggest that I didn't want 2, I don't have results
for tests using 8 bit it felt faster.

-- 
Earnie.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



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