[3/5] Partially revert 681900d29683722b1cb0a8e565a0585846ec5a61

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

Commit Message

Siddhesh Poyarekar Dec. 15, 2020, 2:13 p.m. UTC
  Do not attempt to fix the significand top bit in long double input
received in printf.  The code should never reach here because isnan
should now detect unnormals as NaN.  This is already a NOP for glibc
since it uses the gcc __builtin_isnan, which detects unnormals as NaN.
---
 sysdeps/x86/ldbl2mpn.c | 8 --------
 1 file changed, 8 deletions(-)
  

Comments

Florian Weimer Dec. 15, 2020, 2:36 p.m. UTC | #1
* Siddhesh Poyarekar:

> Do not attempt to fix the significand top bit in long double input
> received in printf.  The code should never reach here because isnan
> should now detect unnormals as NaN.  This is already a NOP for glibc
> since it uses the gcc __builtin_isnan, which detects unnormals as NaN.
> ---
>  sysdeps/x86/ldbl2mpn.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c
> index 23afedfb67..ec8464eef7 100644
> --- a/sysdeps/x86/ldbl2mpn.c
> +++ b/sysdeps/x86/ldbl2mpn.c
> @@ -115,14 +115,6 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
>  	   && res_ptr[N - 1] == 0)
>      /* Pseudo zero.  */
>      *expt = 0;
> -  else
> -    /* Unlike other floating point formats, the most significant bit
> -       is explicit and expected to be set for normal numbers.  Set it
> -       in case it is cleared in the input.  Otherwise, callers will
> -       not be able to produce the expected multi-precision integer
> -       layout by shifting.  */
> -    res_ptr[N - 1] |= (mp_limb_t) 1 << (LDBL_MANT_DIG - 1
> -					- ((N - 1) * BITS_PER_MP_LIMB));
>  
>    return N;
>  }

I think you should also tweak the test in
sysdeps/x86/tst-ldbl-nonnormal-printf.c to expect "nan" only.

Thanks,
Florian
  
Siddhesh Poyarekar Dec. 15, 2020, 3:01 p.m. UTC | #2
On 12/15/20 8:06 PM, Florian Weimer via Libc-alpha wrote:

> I think you should also tweak the test in
> sysdeps/x86/tst-ldbl-nonnormal-printf.c to expect "nan" only.

Thanks for catching that.  I'll fix it up.

Siddhesh
  

Patch

diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c
index 23afedfb67..ec8464eef7 100644
--- a/sysdeps/x86/ldbl2mpn.c
+++ b/sysdeps/x86/ldbl2mpn.c
@@ -115,14 +115,6 @@  __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 	   && res_ptr[N - 1] == 0)
     /* Pseudo zero.  */
     *expt = 0;
-  else
-    /* Unlike other floating point formats, the most significant bit
-       is explicit and expected to be set for normal numbers.  Set it
-       in case it is cleared in the input.  Otherwise, callers will
-       not be able to produce the expected multi-precision integer
-       layout by shifting.  */
-    res_ptr[N - 1] |= (mp_limb_t) 1 << (LDBL_MANT_DIG - 1
-					- ((N - 1) * BITS_PER_MP_LIMB));
 
   return N;
 }