This problem is driving me a bit crazy. The code seems to be segmentation faulting for no good reason:
#define MULT_FLOAT4(X, Y) ({ \
asm volatile ( \
"movups (%0), %%xmm0\n\t" \
"mulps (%1), %%xmm0\n\t" \
"movups %%xmm0, (%1)" \
:: "r" (X), "r" (Y)); })
int main(void)
{
int before;
float a[4] = { 10, 20, 30, 40 };
float b[4] = { 0.1, 0.1, 0.1, 0.1 };
/* Segmentation faults if I uncomment this line below, otherwise works fine. Why?? */
int after;
MULT_FLOAT4(a, b);
return 0;
}
Note that so long as I have defined both the 'before' and 'after' variables it segmentation faults. If I just have 'before' or just have 'after' then it works fine.
I'm on Ubuntu Hardy (8.04), GCC version 4.2.4 (Ubuntu 4.2.4-1ubuntu4). Linux kernel: 2.6.24-16-generic.