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


Gianni Tedesco wrote:

Hi,

I'm currently working on a project which uses altivec (as inline
assembly) to perform 3d affine transformations, and some other 3d vector
functions.

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)));

This seems to work for global variables, but when allocated on the
stack, my structures end up mis-aligned (on to 8-byte boundaries) which
totally screws up the results of the altivec computation.

Is this a compiler problem, or can't the compiler be expected to
guarantee alignments that large?

This is a problem with the malloc implementation.

Most malloc's support 8 byte alignment. You could specifically tune one of the
many malloc packages out there to be 16 byte aligned and hence this would solve
your problem.


gcc version 2.95.4 20010319 (prerelease/franzo/20011204)

PS. Is there any documentation about the vector support directly in C? I
hear gcc3 has that feature.

Thanks.

PS. Please CC replies, im not a list subscriber.





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