This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Altivec + 16 byte alignment


At 18:25 11.02.2003, John David Anglin wrote:
> I have a problem in that altivec requires all inputs to be 16 byte
> aligned, so I am placing my vectors in a structure like this:
>
> struct vector {
>         float x,y,z,w;
> }__attribute__((aligned(16)));

We had a similar problem with respect to the alignment of data for
the ldcw instruction on the PA which needs 16-byte alignment on PA 1.X.
We have found an alternative solution.  However, the patch below
will allow the aligned attribute to be respected for stack locals
up to PREFERRED_STACK_BOUNDARY.  Note however, that alignment of
stack locals is only guaranteed up to STACK_BOUNDARY.  The default
alignment for structs on the stack is BIGGEST_ALIGNMENT, which I
presume is set 64 (8 bytes).

It may well be with altvec you really want BIGGEST_ALIGNMENT set to
256, but the change would affect the ABI and alignment of long doubles.
The i386 code provides an example of what needs doing if there are
types such as long doubles that don't require natural alignment.
BIGGEST_ALIGNMENT is 128, but STACK_BOUNDARY is 64 unless you give -mabi=altivec (in 3.2+). Now, if we would increase STACK_BOUNDARY to be always 128 on powerpc-linux-gnu, would this affect binary compatibility at all? I can't think of a situation where this would happen, but maybe I'm wrong?
If changing STACK_BOUNDARY doesn't affect binary compatibility, I will submit a patch to set it to 128 in rs6000/linux.h.

Franz.


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