diff mbox series

math: x86: Remove extra '%' on FP_INIT_ROUNDMODE inline asm

Message ID 20220831181443.3875972-1-adhemerval.zanella@linaro.org
State New
Headers show
Series math: x86: Remove extra '%' on FP_INIT_ROUNDMODE inline asm | expand

Commit Message

Adhemerval Zanella Netto Aug. 31, 2022, 6:14 p.m. UTC
Checked on x86_64-linux-gnu.
---
 sysdeps/x86/fpu/sfp-machine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

H.J. Lu Aug. 31, 2022, 7:33 p.m. UTC | #1
On Wed, Aug 31, 2022 at 11:16 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
> index 5892f4f5fe..1cacdb4ebd 100644
> --- a/sysdeps/x86/fpu/sfp-machine.h
> +++ b/sysdeps/x86/fpu/sfp-machine.h
> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
>
>  # define FP_INIT_ROUNDMODE                                     \
>    do {                                                         \
> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));      \
> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));       \
>    } while (0)
>  #else
>  # define _FP_W_TYPE_SIZE       32
> --
> 2.34.1
>

The intention was to generate stmxcsr with SSE and vstmxcsr with
AVX.  I think we should define a special prefix, like AVX_INSN_PREFIX,
which is 'v' if __AVX__ is defined and empty if __AVX__ isn't defined.
Joseph Myers Aug. 31, 2022, 7:35 p.m. UTC | #2
On Wed, 31 Aug 2022, Adhemerval Zanella via Libc-alpha wrote:

> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
> index 5892f4f5fe..1cacdb4ebd 100644
> --- a/sysdeps/x86/fpu/sfp-machine.h
> +++ b/sysdeps/x86/fpu/sfp-machine.h
> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
>  
>  # define FP_INIT_ROUNDMODE					\
>    do {								\
> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));	\
> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));	\

That's incorrect.  %v means "'v' if AVX, empty string otherwise".
Adhemerval Zanella Netto Sept. 1, 2022, 1:01 p.m. UTC | #3
On 31/08/22 16:33, H.J. Lu wrote:
> On Wed, Aug 31, 2022 at 11:16 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> Checked on x86_64-linux-gnu.
>> ---
>>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
>> index 5892f4f5fe..1cacdb4ebd 100644
>> --- a/sysdeps/x86/fpu/sfp-machine.h
>> +++ b/sysdeps/x86/fpu/sfp-machine.h
>> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
>>
>>  # define FP_INIT_ROUNDMODE                                     \
>>    do {                                                         \
>> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));      \
>> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));       \
>>    } while (0)
>>  #else
>>  # define _FP_W_TYPE_SIZE       32
>> --
>> 2.34.1
>>
> 
> The intention was to generate stmxcsr with SSE and vstmxcsr with
> AVX.  I think we should define a special prefix, like AVX_INSN_PREFIX,
> which is 'v' if __AVX__ is defined and empty if __AVX__ isn't defined.
> 

Right, I was not aware of it.  Is is documented on gcc inline assembly
manual somewhere (I could not find it)? In any case I will follow your
suggestion.
H.J. Lu Sept. 1, 2022, 2:51 p.m. UTC | #4
On Thu, Sep 1, 2022 at 6:01 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 31/08/22 16:33, H.J. Lu wrote:
> > On Wed, Aug 31, 2022 at 11:16 AM Adhemerval Zanella via Libc-alpha
> > <libc-alpha@sourceware.org> wrote:
> >>
> >> Checked on x86_64-linux-gnu.
> >> ---
> >>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
> >> index 5892f4f5fe..1cacdb4ebd 100644
> >> --- a/sysdeps/x86/fpu/sfp-machine.h
> >> +++ b/sysdeps/x86/fpu/sfp-machine.h
> >> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
> >>
> >>  # define FP_INIT_ROUNDMODE                                     \
> >>    do {                                                         \
> >> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));      \
> >> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));       \
> >>    } while (0)
> >>  #else
> >>  # define _FP_W_TYPE_SIZE       32
> >> --
> >> 2.34.1
> >>
> >
> > The intention was to generate stmxcsr with SSE and vstmxcsr with
> > AVX.  I think we should define a special prefix, like AVX_INSN_PREFIX,
> > which is 'v' if __AVX__ is defined and empty if __AVX__ isn't defined.
> >
>
> Right, I was not aware of it.  Is is documented on gcc inline assembly

I need to take a look.

> manual somewhere (I could not find it)? In any case I will follow your
> suggestion.

There is no need for it.  %v is handled by compiler with an operand.
Adhemerval Zanella Netto Sept. 1, 2022, 3:21 p.m. UTC | #5
On 01/09/22 11:51, H.J. Lu wrote:
> On Thu, Sep 1, 2022 at 6:01 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 31/08/22 16:33, H.J. Lu wrote:
>>> On Wed, Aug 31, 2022 at 11:16 AM Adhemerval Zanella via Libc-alpha
>>> <libc-alpha@sourceware.org> wrote:
>>>>
>>>> Checked on x86_64-linux-gnu.
>>>> ---
>>>>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
>>>> index 5892f4f5fe..1cacdb4ebd 100644
>>>> --- a/sysdeps/x86/fpu/sfp-machine.h
>>>> +++ b/sysdeps/x86/fpu/sfp-machine.h
>>>> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
>>>>
>>>>  # define FP_INIT_ROUNDMODE                                     \
>>>>    do {                                                         \
>>>> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));      \
>>>> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));       \
>>>>    } while (0)
>>>>  #else
>>>>  # define _FP_W_TYPE_SIZE       32
>>>> --
>>>> 2.34.1
>>>>
>>>
>>> The intention was to generate stmxcsr with SSE and vstmxcsr with
>>> AVX.  I think we should define a special prefix, like AVX_INSN_PREFIX,
>>> which is 'v' if __AVX__ is defined and empty if __AVX__ isn't defined.
>>>
>>
>> Right, I was not aware of it.  Is is documented on gcc inline assembly
> 
> I need to take a look.

Thanks.

> 
>> manual somewhere (I could not find it)? In any case I will follow your
>> suggestion.
> 
> There is no need for it.  %v is handled by compiler with an operand.

Not by all compilers in fact, that's why I proposing the change.
H.J. Lu Sept. 1, 2022, 4:26 p.m. UTC | #6
On Thu, Sep 1, 2022 at 8:23 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 01/09/22 11:51, H.J. Lu wrote:
> > On Thu, Sep 1, 2022 at 6:01 AM Adhemerval Zanella Netto
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >>
> >> On 31/08/22 16:33, H.J. Lu wrote:
> >>> On Wed, Aug 31, 2022 at 11:16 AM Adhemerval Zanella via Libc-alpha
> >>> <libc-alpha@sourceware.org> wrote:
> >>>>
> >>>> Checked on x86_64-linux-gnu.
> >>>> ---
> >>>>  sysdeps/x86/fpu/sfp-machine.h | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
> >>>> index 5892f4f5fe..1cacdb4ebd 100644
> >>>> --- a/sysdeps/x86/fpu/sfp-machine.h
> >>>> +++ b/sysdeps/x86/fpu/sfp-machine.h
> >>>> @@ -41,7 +41,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
> >>>>
> >>>>  # define FP_INIT_ROUNDMODE                                     \
> >>>>    do {                                                         \
> >>>> -    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));      \
> >>>> +    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));       \
> >>>>    } while (0)
> >>>>  #else
> >>>>  # define _FP_W_TYPE_SIZE       32
> >>>> --
> >>>> 2.34.1
> >>>>
> >>>
> >>> The intention was to generate stmxcsr with SSE and vstmxcsr with
> >>> AVX.  I think we should define a special prefix, like AVX_INSN_PREFIX,
> >>> which is 'v' if __AVX__ is defined and empty if __AVX__ isn't defined.
> >>>
> >>
> >> Right, I was not aware of it.  Is is documented on gcc inline assembly
> >
> > I need to take a look.
>
> Thanks.
>
> >
> >> manual somewhere (I could not find it)? In any case I will follow your
> >> suggestion.
> >
> > There is no need for it.  %v is handled by compiler with an operand.
>
> Not by all compilers in fact, that's why I proposing the change.

Then my scheme should work.
diff mbox series

Patch

diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h
index 5892f4f5fe..1cacdb4ebd 100644
--- a/sysdeps/x86/fpu/sfp-machine.h
+++ b/sysdeps/x86/fpu/sfp-machine.h
@@ -41,7 +41,7 @@  typedef unsigned int UTItype __attribute__ ((mode (TI)));
 
 # define FP_INIT_ROUNDMODE					\
   do {								\
-    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));	\
+    __asm__ __volatile__ ("vstmxcsr\t%0" : "=m" (_fcw));	\
   } while (0)
 #else
 # define _FP_W_TYPE_SIZE	32