This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Help with inline assembly constraints
- From: "Jason Garrett-Glaser" <darkshikari at gmail dot com>
- To: "GCC Help" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 27 Oct 2008 20:00:24 -0700
- Subject: Help with inline assembly constraints
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