[Liboil] alignment problems with sse2

David Schleef ds at schleef.org
Tue Aug 29 14:53:00 PDT 2006

On Tue, Aug 29, 2006 at 12:40:02PM +0200, Matthias Drochner wrote:
> Hi -
> some of the sse2 optimized functions in liboil-0.3.9 cause
> GPFs for me occasionally, on a Pentium 4 running NetBSD-current
> (which uses a gcc 4.1.2 prerelease).
> This appears to be caused by aligned moves of __m128i variables
> allocated on the stack from/to xmm registers. Depending on
> stack alignment the variables are aligned to a 16-byte boundary
> or not, which explains that the problem occurs only sometimes.
> (I also wouldn't expect this to happen on amd64 because stack
> alignment is defined by the ABI there.)
> I believe this is gcc's fault: If I compile a small test function:
> #include <emmintrin.h>
> void
> mist(__m128i *p)
> {
>         __m128i a;
>         a = *p;
> }
> I'm getting code which doesn't enforce alignment:
> mist:
>         pushl   %ebp
>         movl    %esp, %ebp
>         subl    $24, %esp
>         movl    8(%ebp), %eax
>         movdqa  (%eax), %xmm0
>         movdqa  %xmm0, -24(%ebp)    <--HERE!
>         leave
>         ret
> Am I right here? If yes, is this a known gcc problem or should
> it be reported to the gcc people?

This is a known problem, see 

The best solution at this point (not yet implemented) is to fix
all the liboil functions to not use local variables for SSE.


David Schleef
Big Kitten LLC (http://www.bigkitten.com/) -- data acquisition on Linux

More information about the Liboil mailing list