In recent versions of GCC I have seen a transformation of inline
assembly that I'd like to confirm is valid.

The code in question can be found in mplayer/mp3lib/dct64_sse.c

          "movaps    %0, %%xmm0\n\t"
          "shufps    $27, %%xmm0, %%xmm0\n\t"
          "movaps    %1, %%xmm5\n\t"
          "movaps    %%xmm5, %%xmm6\n\t"
          :
          :"m"(*costab), "m"(*nnnn)

where nnnn is
 static const int nnnn[4] __attribute__((aligned(16))) = { 1 << 31, 1
<< 31, 1 << 31, 1 << 31 };

GCC turns this into:
     "movaps    %0, %%xmm0
      shufps    $27, %%xmm0, %%xmm0
      movaps    %1, %%xmm5
      movaps    %%xmm5, %%xmm6
      " :  : "m" costab_mmx[24], *"m" -2147483648*);

The new constant might end up in an unaligned address causing the
program to segfault on Intel platforms.

Marking nnnn volatile or changing the code to the following avoids the
transformation:

 __asm__(
            "movaps    %a0, %%xmm0\n\t"
            "shufps    $27, %%xmm0, %%xmm0\n\t"
            "movaps    %a1, %%xmm5\n\t"
            "movaps    %%xmm5, %%xmm6\n\t"
            :
            :"p"(costab), "p"(nnnn)
           );

Thanks!
Martin

Reply via email to