[1/5] x86 long double: Support pseudo numbers in fpclassifyl

Message ID 20201215141339.2684384-2-siddhesh@sourceware.org
State Superseded
Headers
Series x86 pseudo-normal numbers |

Commit Message

Siddhesh Poyarekar Dec. 15, 2020, 2:13 p.m. UTC
  ---
 sysdeps/i386/fpu/s_fpclassifyl.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Adhemerval Zanella Netto Dec. 22, 2020, 6:43 p.m. UTC | #1
On 15/12/2020 11:13, Siddhesh Poyarekar via Libc-alpha wrote:
> ---
>  sysdeps/i386/fpu/s_fpclassifyl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/sysdeps/i386/fpu/s_fpclassifyl.c b/sysdeps/i386/fpu/s_fpclassifyl.c
> index 501312f51e..aeaec7279c 100644
> --- a/sysdeps/i386/fpu/s_fpclassifyl.c
> +++ b/sysdeps/i386/fpu/s_fpclassifyl.c
> @@ -34,6 +34,10 @@ __fpclassifyl (long double x)
>      retval = FP_ZERO;
>    else if (ex == 0 && (hx & 0x80000000) == 0)
>      retval = FP_SUBNORMAL;
> +  /* Pseudo-normals, i.e. pseudo-zero, pseudo-infinity and unnormals.  They

Intel manual adds a hyphen for un-normals.

> +     behave like NaNs, so categorize them as such.  */
> +  else if ((hx & 0x80000000) == 0)
> +    retval = FP_NAN;

Ok.

>    else if (ex == 0x7fff)
>      retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE;
>  
> 

Maybe move the implementation to sysdep/x86/fpu since it is used for
both x86_64 and i386?  It avoid the implicit cross abi include the
and make the implementation selection more clear.
  
Siddhesh Poyarekar Dec. 23, 2020, 1:43 a.m. UTC | #2
On 12/23/20 12:13 AM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 15/12/2020 11:13, Siddhesh Poyarekar via Libc-alpha wrote:
>> ---
>>   sysdeps/i386/fpu/s_fpclassifyl.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/sysdeps/i386/fpu/s_fpclassifyl.c b/sysdeps/i386/fpu/s_fpclassifyl.c
>> index 501312f51e..aeaec7279c 100644
>> --- a/sysdeps/i386/fpu/s_fpclassifyl.c
>> +++ b/sysdeps/i386/fpu/s_fpclassifyl.c
>> @@ -34,6 +34,10 @@ __fpclassifyl (long double x)
>>       retval = FP_ZERO;
>>     else if (ex == 0 && (hx & 0x80000000) == 0)
>>       retval = FP_SUBNORMAL;
>> +  /* Pseudo-normals, i.e. pseudo-zero, pseudo-infinity and unnormals.  They
> 
> Intel manual adds a hyphen for un-normals.
> 

Fixed.

>> +     behave like NaNs, so categorize them as such.  */
>> +  else if ((hx & 0x80000000) == 0)
>> +    retval = FP_NAN;
> 
> Ok.
> 
>>     else if (ex == 0x7fff)
>>       retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE;
>>   
>>
> 
> Maybe move the implementation to sysdep/x86/fpu since it is used for
> both x86_64 and i386?  It avoid the implicit cross abi include the
> and make the implementation selection more clear.
> 

OK.

Thanks,
Siddhesh
  

Patch

diff --git a/sysdeps/i386/fpu/s_fpclassifyl.c b/sysdeps/i386/fpu/s_fpclassifyl.c
index 501312f51e..aeaec7279c 100644
--- a/sysdeps/i386/fpu/s_fpclassifyl.c
+++ b/sysdeps/i386/fpu/s_fpclassifyl.c
@@ -34,6 +34,10 @@  __fpclassifyl (long double x)
     retval = FP_ZERO;
   else if (ex == 0 && (hx & 0x80000000) == 0)
     retval = FP_SUBNORMAL;
+  /* Pseudo-normals, i.e. pseudo-zero, pseudo-infinity and unnormals.  They
+     behave like NaNs, so categorize them as such.  */
+  else if ((hx & 0x80000000) == 0)
+    retval = FP_NAN;
   else if (ex == 0x7fff)
     retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE;