Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Fix GCC's preferred stack alignment to match psABI

On Sun, Sep 16, 2012 at 06:36:09PM +0100, David Laight wrote:
> On Tue, Sep 11, 2012 at 10:22:48PM +0200, Joerg Sonnenberger wrote:
> > Hi all,
> > the attached patch consists of two parts. The first part ensures that
> > GCC honours the SYSV ABI on i386 as used by NetBSD. The second part
> > adjusts the alignment of stack variables, so that double and complex
> > double as well as long long are not aligned to 64bit by default, if the
> > stack alignment is smaller. This avoids triggering unnecessary stack
> > reliagnments.
> What was wrong with enabling -mstackrealign by default?
> That leaves the efficiency of aligning the stack on 16 byte boundaries.
> But adds explicit alignment of the stack only when 128bit alignment
> is requested.

It is enabled by default, but doesn't work since the assumption of
inbound 16 Bytes alignment doesn't match the ABI. There isn't a real
intermediate option either, since the code can either take the penalty
of realigning the stack or not. The patch as is defaults to not taking
it and restores essentially the behavior of old GCC before Linux
switched to the "GNU" ABI. The only case where it might actually be
slower is if the CPU does provide a real penalty for loading a double
from a misaligned dword (e.g. address is 4 mod 8). I doubt that a lot of
code is affected by that, if at all. In that case, explicit realignment
can still be requested.


Home | Main Index | Thread Index | Old Index