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 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.

For those of us who don't have an innate knowledge of gcc config stuff
explain the exact effect of these proposed changes.
Including what some of the variables/constants actually contain.
I can also see 5 changes, not 2.

I presume/hope that they have no effect on 64bit compilations.
This isn't 100% obvious.

For 32bit compilations things are slightly more complicated.

The physical alignment of stack variables doesn't matter for
anything smaller than 16 bytes, but it is definitely advantageous
to align 8 bytes items on 8 byte boundaries (and probably complex
double on 16 byte ones for that matter).

I suspect that one effects of the current code it to align the locals
on their natural boundary with respect to the stack pointer
(ie align large items at > 4byte boundaries).

16 byte alignment is needed for the 128bit media instructions (I think
later AMD cpus have instructions for unaligned accesses, but the intel
ones don't).

This means that it would be nice to maintain the current stack layout
except that we force realignment if any locals require 16 byte alignemnt
(rather than the current 32).

I think your changes remove the code that tries to keep 64bit
items aligned.


David Laight: david%l8s.co.uk@localhost

Home | Main Index | Thread Index | Old Index