Help with inline assembly constraints
Jason Garrett-Glaser
darkshikari@gmail.com
Tue Oct 28 03:01:00 GMT 2008
We have received multiple reports of miscompilation with the following
code in the case of i_count == 128:
static ALWAYS_INLINE int array_non_zero_int_mmx( void *v, int i_count )
{
if(i_count == 128)
{
int nonzero = 0;
asm(
"movq (%1), %%mm0 \n"
"por 8(%1), %%mm0 \n"
"por 16(%1), %%mm0 \n"
"por 24(%1), %%mm0 \n"
"por 32(%1), %%mm0 \n"
"por 40(%1), %%mm0 \n"
"por 48(%1), %%mm0 \n"
"por 56(%1), %%mm0 \n"
"por 64(%1), %%mm0 \n"
"por 72(%1), %%mm0 \n"
"por 80(%1), %%mm0 \n"
"por 88(%1), %%mm0 \n"
"por 96(%1), %%mm0 \n"
"por 104(%1), %%mm0 \n"
"por 112(%1), %%mm0 \n"
"por 120(%1), %%mm0 \n"
"packsswb %%mm0, %%mm0 \n"
"movd %%mm0, %0 \n"
:"=r"(nonzero)
:"r"(v), "m"(*(struct {int16_t x[64];} *)v)
);
return !!nonzero;
}
else return array_non_zero_int_c( v, i_count );
}
I would have thought the constraints would be enough to ensure that
GCC compiled this correctly; is there anything that could be missing,
or is this a GCC bug?
Dark Shikari
More information about the Gcc-help
mailing list