[gomp] i386 cmpxchg8b and x86_64 cmpxchg16b support
Jakub Jelinek
jakub@redhat.com
Tue Oct 11 06:56:00 GMT 2005
On Tue, Oct 11, 2005 at 01:34:34AM +0200, Andi Kleen wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> >
> > --- libgomp/testsuite/libgomp.dg/atomic-2.c.jj 2005-10-10 23:23:40.000000000 +0200
> > +++ libgomp/testsuite/libgomp.dg/atomic-2.c 2005-10-10 23:28:51.000000000 +0200
> > @@ -0,0 +1,35 @@
> > +/* { dg-do run } */
> > +/* { dg-options "-O2 -fopenmp" } */
> > +/* { dg-options "-O2 -fopenmp -march=nocona" { target i?86-*-* x86_64-*-* } } */
You missed one line below it:
/* { dg-options "-O2 -fopenmp" { target ilp32 } } */
> > +main (void)
> > +{
> > +#ifdef __x86_64__
>
> This needs to be #if defined(__i386__) || defined(__x86_64__)
> otherwise you will crash on most i386 boxes.
The above means, add -march=nocona only on {i?86,x86_64}-*-* if generating
64-bit code. So #ifdef __x86_64__ is correct.
> > +# define bit_SSE3 (1 << 0)
> > +# define bit_CX16 (1 << 13)
> > + unsigned int ax, bx, cx, dx;
> > + __asm__ ("cpuid" : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx)
> > + : "0" (1) : "cc");
> > + if ((cx & (bit_SSE3 | bit_CX16)) != (bit_SSE3 | bit_CX16))
> > + return 0;
> > +#endif
>
> Also as a nitpick CX16 is in theory legal without SSE3.
True, but I'm not adding -mcmpxchg16b switch (which doesn't exist),
but selecting -march=nocona. So I'd better make sure all code gcc generates
for -march=nocona runs on the target processor.
Jakub
More information about the Gcc-patches
mailing list