https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98110
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And no, the asm isn't marked volatile, that would have prevented it too:
# define THREAD_SELF \
({ struct pthread *__self; \
asm ("mov %%fs:%c1,%0" : "=r" (__self) \
: "i" (offsetof (struct pthread, header.self))); \
__self;})
This all boils down to:
void
foo (int *p)
{
for (int i = 0; i < 64; i++)
{
if (p[i])
{
int *q;
asm ("mov %%fs:%c1,%0" : "=r" (q) : "i" (16));
q[0]++;
}
}
}
which would hoist the inline asm to the function prologue even in GCC 4.1.