[Liboil] alignment problems with sse2

Matthias Drochner M.Drochner at fz-juelich.de
Tue Aug 29 03:40:02 PDT 2006


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?

best regards
Matthias




More information about the Liboil mailing list