[1/2] Remove dbl-64/wordsize-64

Message ID VE1PR08MB5599EA0DE0781E02F925455183C50@VE1PR08MB5599.eurprd08.prod.outlook.com
State Superseded
Headers
Series [1/2] Remove dbl-64/wordsize-64 |

Commit Message

Wilco Dijkstra Dec. 16, 2020, 4:56 p.m. UTC
  Remove the wordsize-64 implementations by merging them into the main dbl-64
directory. The first patch adds special cases needed for 32-bit targets 
(FIX_INT_FP_CONVERT_ZERO and FIX_DBL_LONG_CONVERT_OVERFLOW) to the
wordsize-64 versions. This has no effect on 64-bit targets since they don't define
these macros.

---
  

Comments

Adhemerval Zanella Dec. 21, 2020, 5:36 p.m. UTC | #1
On 16/12/2020 13:56, Wilco Dijkstra via Libc-alpha wrote:
> Remove the wordsize-64 implementations by merging them into the main dbl-64
> directory. The first patch adds special cases needed for 32-bit targets 
> (FIX_INT_FP_CONVERT_ZERO and FIX_DBL_LONG_CONVERT_OVERFLOW) to the
> wordsize-64 versions. This has no effect on 64-bit targets since they don't define
> these macros.

LGTM, with some changes below.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> ---
> 
> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
> index 0b4116e0a843e0c925b08501a028d15e8daa64ae..b89064fb7c41dd857d216b911aeb3935605c6d38 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
> @@ -44,6 +44,7 @@
>   */
>  
>  #include <math.h>
> +#include <fix-int-fp-convert-zero.h>
>  #include <math_private.h>
>  #include <stdint.h>
>  #include <libm-alias-finite.h>
> @@ -80,6 +81,8 @@ __ieee754_log10 (double x)
>    i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63;
>    hx = (hx & UINT64_C(0x000fffffffffffff)) | ((0x3ff - i) << 52);
>    y = (double) (k + i);
> +  if (FIX_INT_FP_CONVERT_ZERO && y == 0.0)
> +    y = 0.0;
>    INSERT_WORDS64 (x, hx);
>    z = y * log10_2lo + ivln10 * __ieee754_log (x);
>    return z + y * log10_2hi;

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
> index eba96d0c771a84ccae9bfc99200d8a4c0c3ea14f..d541f0f1b6b00ed78d2ec6f05086f5c053841f2b 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
> @@ -1,4 +1,4 @@
> -/* Get NaN payload.  dbl-64/wordsize-64 version.
> +/* Get NaN payload.
>     Copyright (C) 2016-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> @@ -20,6 +20,7 @@
>  #include <math_private.h>
>  #include <libm-alias-double.h>
>  #include <stdint.h>
> +#include <fix-int-fp-convert-zero.h>
>  
>  double
>  __getpayload (const double *x)
> @@ -30,6 +31,8 @@ __getpayload (const double *x)
>        || (ix & 0xfffffffffffffULL) == 0)
>      return -1;
>    ix &= 0x7ffffffffffffULL;
> +  if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
> +    return 0.0f;
>    return (double) ix;
>  }
>  libm_alias_double (__getpayload, getpayload)

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
> index a91099f0d5e129f511cd7eeb219a9b763b96874f..1d9c6c5b1676920c951fdb56cf133bfc64195405 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
> @@ -20,12 +20,14 @@
>  #define lround __hidden_lround
>  #define __lround __hidden___lround
>  
> +#include <fenv.h>
> +#include <limits.h>
>  #include <math.h>
>  #include <sysdep.h>
>  
>  #include <math_private.h>
>  #include <libm-alias-double.h>
> -
> +#include <fix-fp-int-convert-overflow.h>
>  
>  long long int
>  __llround (double x)
> @@ -56,8 +58,16 @@ __llround (double x)
>      }
>    else
>      {
> -      /* The number is too large.  It is left implementation defined
> -	 what happens.  */
> +#ifdef FE_INVALID
> +      /* The number is too large.  Unless it rounds to LLONG_MIN,
> +	 FE_INVALID must be raised and the return value is
> +	 unspecified.  */
> +      if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
> +	{
> +	  feraiseexcept (FE_INVALID);
> +	  return sign == 1 ? LLONG_MAX : LLONG_MIN;
> +	}
> +#endif
>        return (long long int) x;
>      }
>  

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
> index 787a7c201dd607584c64af416b9a7447dccc8c38..c0cebe57b798c910f2f3cdc02e86cbecb14285a3 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
> @@ -22,6 +22,7 @@
>  
>  #include <math_private.h>
>  #include <libm-alias-double.h>
> +#include <fix-fp-int-convert-overflow.h>
>  
>  /* For LP64, lround is an alias for llround.  */
>  #ifndef _LP64
> @@ -66,7 +67,17 @@ __lround (double x)
>  	 FE_INVALID must be raised and the return value is
>  	 unspecified.  */
>  #ifdef FE_INVALID
> -      if (sizeof (long int) == 4
> +      if (FIX_DBL_LONG_CONVERT_OVERFLOW
> +	  && !(sign == -1
> +	       && (sizeof (long int) == 4
> +		   ? x > (double) LONG_MIN - 0.5
> +		   : x >= (double) LONG_MIN)))
> +	{
> +	  feraiseexcept (FE_INVALID);
> +	  return sign == 1 ? LONG_MAX : LONG_MIN;
> +	}
> +      else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
> +	  && sizeof (long int) == 4
>  	  && x <= (double) LONG_MIN - 0.5)
>  	{
>  	  /* If truncation produces LONG_MIN, the cast will not raise

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
> index 47dca5f00043e1890d86552446f2bdb2324da8b2..f6b592a368199679fb078d545771219ac794f46c 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
> @@ -1,5 +1,4 @@
>  /* Round to nearest integer value, rounding halfway cases to even.
> -   dbl-64/wordsize-64 version.
>     Copyright (C) 2016-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  

I think you should move it to the part 2 of the set.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
> index 4240c4c54c8e6a33af4968f68bb5cb4672e509ce..dda177c5ee7a7a53878c7db575e288d9a021870b 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
> @@ -1,4 +1,4 @@
> -/* Set NaN payload.  dbl-64/wordsize-64 version.
> +/* Set NaN payload.
>     Copyright (C) 2016-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  

Ditto.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
> index 6f7020a96e8c3857da30c7e434c7bbf8dc0ebb91..acc629a00ffbcb8ebcadc38caadfe46d3d8189b8 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
> @@ -1,4 +1,4 @@
> -/* Total order operation.  dbl-64/wordsize-64 version.
> +/* Total order operation.
>     Copyright (C) 2016-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  

Ditto.

> diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
> index a5b0d417a9660cf448bd68fb13a0e216ff91ab2f..a60cf57129d80c50e6e8608dc252db68106cc47d 100644
> --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
> +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
> @@ -1,4 +1,4 @@
> -/* Total order operation on absolute values.  dbl-64/wordsize-64 version.
> +/* Total order operation on absolute values.
>     Copyright (C) 2016-2020 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
> 

Ditto.
  

Patch

diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
index 0b4116e0a843e0c925b08501a028d15e8daa64ae..b89064fb7c41dd857d216b911aeb3935605c6d38 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
@@ -44,6 +44,7 @@ 
  */
 
 #include <math.h>
+#include <fix-int-fp-convert-zero.h>
 #include <math_private.h>
 #include <stdint.h>
 #include <libm-alias-finite.h>
@@ -80,6 +81,8 @@  __ieee754_log10 (double x)
   i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63;
   hx = (hx & UINT64_C(0x000fffffffffffff)) | ((0x3ff - i) << 52);
   y = (double) (k + i);
+  if (FIX_INT_FP_CONVERT_ZERO && y == 0.0)
+    y = 0.0;
   INSERT_WORDS64 (x, hx);
   z = y * log10_2lo + ivln10 * __ieee754_log (x);
   return z + y * log10_2hi;
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
index eba96d0c771a84ccae9bfc99200d8a4c0c3ea14f..d541f0f1b6b00ed78d2ec6f05086f5c053841f2b 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
@@ -1,4 +1,4 @@ 
-/* Get NaN payload.  dbl-64/wordsize-64 version.
+/* Get NaN payload.
    Copyright (C) 2016-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -20,6 +20,7 @@ 
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <stdint.h>
+#include <fix-int-fp-convert-zero.h>
 
 double
 __getpayload (const double *x)
@@ -30,6 +31,8 @@  __getpayload (const double *x)
       || (ix & 0xfffffffffffffULL) == 0)
     return -1;
   ix &= 0x7ffffffffffffULL;
+  if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
+    return 0.0f;
   return (double) ix;
 }
 libm_alias_double (__getpayload, getpayload)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
index a91099f0d5e129f511cd7eeb219a9b763b96874f..1d9c6c5b1676920c951fdb56cf133bfc64195405 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
@@ -20,12 +20,14 @@ 
 #define lround __hidden_lround
 #define __lround __hidden___lround
 
+#include <fenv.h>
+#include <limits.h>
 #include <math.h>
 #include <sysdep.h>
 
 #include <math_private.h>
 #include <libm-alias-double.h>
-
+#include <fix-fp-int-convert-overflow.h>
 
 long long int
 __llround (double x)
@@ -56,8 +58,16 @@  __llround (double x)
     }
   else
     {
-      /* The number is too large.  It is left implementation defined
-	 what happens.  */
+#ifdef FE_INVALID
+      /* The number is too large.  Unless it rounds to LLONG_MIN,
+	 FE_INVALID must be raised and the return value is
+	 unspecified.  */
+      if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LLONG_MAX : LLONG_MIN;
+	}
+#endif
       return (long long int) x;
     }
 
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
index 787a7c201dd607584c64af416b9a7447dccc8c38..c0cebe57b798c910f2f3cdc02e86cbecb14285a3 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
@@ -22,6 +22,7 @@ 
 
 #include <math_private.h>
 #include <libm-alias-double.h>
+#include <fix-fp-int-convert-overflow.h>
 
 /* For LP64, lround is an alias for llround.  */
 #ifndef _LP64
@@ -66,7 +67,17 @@  __lround (double x)
 	 FE_INVALID must be raised and the return value is
 	 unspecified.  */
 #ifdef FE_INVALID
-      if (sizeof (long int) == 4
+      if (FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && !(sign == -1
+	       && (sizeof (long int) == 4
+		   ? x > (double) LONG_MIN - 0.5
+		   : x >= (double) LONG_MIN)))
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LONG_MAX : LONG_MIN;
+	}
+      else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && sizeof (long int) == 4
 	  && x <= (double) LONG_MIN - 0.5)
 	{
 	  /* If truncation produces LONG_MIN, the cast will not raise
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
index 47dca5f00043e1890d86552446f2bdb2324da8b2..f6b592a368199679fb078d545771219ac794f46c 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c
@@ -1,5 +1,4 @@ 
 /* Round to nearest integer value, rounding halfway cases to even.
-   dbl-64/wordsize-64 version.
    Copyright (C) 2016-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
index 4240c4c54c8e6a33af4968f68bb5cb4672e509ce..dda177c5ee7a7a53878c7db575e288d9a021870b 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c
@@ -1,4 +1,4 @@ 
-/* Set NaN payload.  dbl-64/wordsize-64 version.
+/* Set NaN payload.
    Copyright (C) 2016-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
index 6f7020a96e8c3857da30c7e434c7bbf8dc0ebb91..acc629a00ffbcb8ebcadc38caadfe46d3d8189b8 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c
@@ -1,4 +1,4 @@ 
-/* Total order operation.  dbl-64/wordsize-64 version.
+/* Total order operation.
    Copyright (C) 2016-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
index a5b0d417a9660cf448bd68fb13a0e216ff91ab2f..a60cf57129d80c50e6e8608dc252db68106cc47d 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
@@ -1,4 +1,4 @@ 
-/* Total order operation on absolute values.  dbl-64/wordsize-64 version.
+/* Total order operation on absolute values.
    Copyright (C) 2016-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.