Altivec + 16 byte alignment

Gianni Tedesco gianni@scaramanga.co.uk
Tue Feb 11 10:07:00 GMT 2003


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?

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.

-- 
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/gianni-at-ecsc.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20030211/56d70de1/attachment.sig>


More information about the Gcc mailing list