Message ID | 20220901130253.1684344-1-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | math: x86: Use prefix for FP_INIT_ROUNDMODE | expand |
On Thu, Sep 1, 2022 at 6:03 AM Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: > > Not all compilers support the inline asm prefix '%v' to emit the avx > instruction if AVX is enable. Use a prefix instead. > > Checked on x86_64-linux-gnu and i686-linux-gnu. > --- > sysdeps/x86/fpu/sfp-machine.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h > index 5892f4f5fe..006eebe257 100644 > --- a/sysdeps/x86/fpu/sfp-machine.h > +++ b/sysdeps/x86/fpu/sfp-machine.h > @@ -39,9 +39,15 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); > > # define FP_RND_MASK 0x6000 > > +# ifdef __AVX__ > +# define AVX_INSN_PREFIX "v" > +# else > +# define AVX_INSN_PREFIX "" > +# endif > + > # define FP_INIT_ROUNDMODE \ > do { \ > - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ > + __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \ > } while (0) > #else > # define _FP_W_TYPE_SIZE 32 > -- > 2.34.1 > Should we use __builtin_ia32_stmxcsr instead?
On Thu, Sep 1, 2022 at 9:42 AM H.J. Lu <hjl.tools@gmail.com> wrote: > > On Thu, Sep 1, 2022 at 6:03 AM Adhemerval Zanella via Libc-alpha > <libc-alpha@sourceware.org> wrote: > > > > Not all compilers support the inline asm prefix '%v' to emit the avx > > instruction if AVX is enable. Use a prefix instead. > > > > Checked on x86_64-linux-gnu and i686-linux-gnu. > > --- > > sysdeps/x86/fpu/sfp-machine.h | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h > > index 5892f4f5fe..006eebe257 100644 > > --- a/sysdeps/x86/fpu/sfp-machine.h > > +++ b/sysdeps/x86/fpu/sfp-machine.h > > @@ -39,9 +39,15 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); > > > > # define FP_RND_MASK 0x6000 > > > > +# ifdef __AVX__ > > +# define AVX_INSN_PREFIX "v" > > +# else > > +# define AVX_INSN_PREFIX "" > > +# endif > > + > > # define FP_INIT_ROUNDMODE \ > > do { \ > > - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ > > + __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \ > > } while (0) > > #else > > # define _FP_W_TYPE_SIZE 32 > > -- > > 2.34.1 > > > > Should we use __builtin_ia32_stmxcsr instead? > __builtin_ia32_stmxcsr requires extra instructions.
On 01/09/22 13:49, H.J. Lu wrote: > On Thu, Sep 1, 2022 at 9:42 AM H.J. Lu <hjl.tools@gmail.com> wrote: >> >> On Thu, Sep 1, 2022 at 6:03 AM Adhemerval Zanella via Libc-alpha >> <libc-alpha@sourceware.org> wrote: >>> >>> Not all compilers support the inline asm prefix '%v' to emit the avx >>> instruction if AVX is enable. Use a prefix instead. >>> >>> Checked on x86_64-linux-gnu and i686-linux-gnu. >>> --- >>> sysdeps/x86/fpu/sfp-machine.h | 8 +++++++- >>> 1 file changed, 7 insertions(+), 1 deletion(-) >>> >>> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h >>> index 5892f4f5fe..006eebe257 100644 >>> --- a/sysdeps/x86/fpu/sfp-machine.h >>> +++ b/sysdeps/x86/fpu/sfp-machine.h >>> @@ -39,9 +39,15 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); >>> >>> # define FP_RND_MASK 0x6000 >>> >>> +# ifdef __AVX__ >>> +# define AVX_INSN_PREFIX "v" >>> +# else >>> +# define AVX_INSN_PREFIX "" >>> +# endif >>> + >>> # define FP_INIT_ROUNDMODE \ >>> do { \ >>> - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ >>> + __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \ >>> } while (0) >>> #else >>> # define _FP_W_TYPE_SIZE 32 >>> -- >>> 2.34.1 >>> >> >> Should we use __builtin_ia32_stmxcsr instead? >> > > __builtin_ia32_stmxcsr requires extra instructions. > I don't have a strong option, although in theory builtins would play nice in general code generation.
On Thu, Sep 1, 2022 at 6:03 AM Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: > > Not all compilers support the inline asm prefix '%v' to emit the avx > instruction if AVX is enable. Use a prefix instead. > > Checked on x86_64-linux-gnu and i686-linux-gnu. > --- > sysdeps/x86/fpu/sfp-machine.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h > index 5892f4f5fe..006eebe257 100644 > --- a/sysdeps/x86/fpu/sfp-machine.h > +++ b/sysdeps/x86/fpu/sfp-machine.h > @@ -39,9 +39,15 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); > > # define FP_RND_MASK 0x6000 > > +# ifdef __AVX__ > +# define AVX_INSN_PREFIX "v" > +# else > +# define AVX_INSN_PREFIX "" > +# endif > + > # define FP_INIT_ROUNDMODE \ > do { \ > - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ > + __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \ > } while (0) > #else > # define _FP_W_TYPE_SIZE 32 > -- > 2.34.1 > LGTM. Thanks.
diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index 5892f4f5fe..006eebe257 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -39,9 +39,15 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); # define FP_RND_MASK 0x6000 +# ifdef __AVX__ +# define AVX_INSN_PREFIX "v" +# else +# define AVX_INSN_PREFIX "" +# endif + # define FP_INIT_ROUNDMODE \ do { \ - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ + __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \ } while (0) #else # define _FP_W_TYPE_SIZE 32