alignment issues for sse

Brian Budge brian.budge@gmail.com
Tue Feb 15 16:13:00 GMT 2005


Hello all -

I just wrote  a small vector/matrix template library that allows use
of sse intstructions.

I wrote some simple test programs and everything seems to work great. 
But then I tried to move the classes into my ray tracer and things
started to look not so good.

I use the __m128 type defined in xmmintrin.h.  Additionally (because I
was having so many problems) I set the alignment attribute of all of
my classes to 16 bytes.

The program crashes everytime I do an sse assignment (such as __m128
foo = bar;).

I traces things down in gdb, and apparently my classes are not aligned
on 16 byte boundaries.  This seems strange given that I've done just
about all that I can to make sure that they are aligned correctly.

I'm compiling into separate object files and then linking at the end
(this is the only difference I can think of between my simple test app
and my ray tracer).  Is it possible that the alignment gets thrown off
in the link step?

Thanks,
  Brian



More information about the Gcc-help mailing list