http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383

             Bug #: 53383
           Summary: Allow -mpreferred-stack-boundary=3 on x86-64
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: h...@zytor.com


In the Linux kernel, we do not use SSE or floating-point of any kind (except in
very particular highly controlled places); furthermore, stack space is at an
extreme premium.  As such, it makes absolutely no sense to align the stack to
16 bytes in x86-64.

gcc, however, refuses to allow setting the stack alignment to 8 bytes:

: anacreon 105 ; gcc -mpreferred-stack-boundary=3 -mincoming-stack-boundary=3
-O2 -mno-sse -c /tmp/foo.c
/tmp/foo.c:1:0: error: -mpreferred-stack-boundary=3 is not between 4 and 12
/tmp/foo.c:1:0: error: -mincoming-stack-boundary=3 is not between 4 and 12

This is particularly ironic since we have found out that, in fact, ALL kernel
stacks are actually 16-byte misaligned on x86-64 as the entry code pushes a
total of 88 bytes onto the stack.  As such, gcc trying to keep a 16-byte
alignment actually makes the code do worse, not better.

Reply via email to