|
|
7c0489 |
From d37e99de7ab1cd8c3d427f74bf8ceb5774795fe5 Mon Sep 17 00:00:00 2001
|
|
|
7c0489 |
From: Stefan Liebler <stli@linux.ibm.com>
|
|
|
7c0489 |
Date: Wed, 11 Dec 2019 15:09:20 +0100
|
|
|
7c0489 |
Subject: [PATCH 08/28] Use GCC builtins for rint functions if desired.
|
|
|
7c0489 |
|
|
|
7c0489 |
This patch is using the corresponding GCC builtin for rintf, rint,
|
|
|
7c0489 |
rintl and rintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
|
|
|
7c0489 |
in math-use-builtins.h.
|
|
|
7c0489 |
|
|
|
7c0489 |
This is the case for s390 if build with at least --march=z196 --mzarch.
|
|
|
7c0489 |
Otherwise the generic implementation is used. The code of the generic
|
|
|
7c0489 |
implementation is not changed.
|
|
|
7c0489 |
|
|
|
7c0489 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
7c0489 |
(cherry picked from commit a2a9b004297b777758420c952cb6eea5985d37fe)
|
|
|
7c0489 |
---
|
|
|
7c0489 |
sysdeps/generic/math-use-builtins.h | 5 +++++
|
|
|
7c0489 |
sysdeps/ieee754/dbl-64/s_rint.c | 17 +++++++++++------
|
|
|
7c0489 |
sysdeps/ieee754/float128/float128_private.h | 3 +++
|
|
|
7c0489 |
sysdeps/ieee754/flt-32/s_rintf.c | 17 +++++++++++------
|
|
|
7c0489 |
sysdeps/ieee754/ldbl-128/s_rintl.c | 17 +++++++++++------
|
|
|
7c0489 |
sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++
|
|
|
7c0489 |
6 files changed, 52 insertions(+), 18 deletions(-)
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
index e12490ed41..64b4a4bb5b 100644
|
|
|
7c0489 |
--- a/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
+++ b/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
@@ -26,4 +26,9 @@
|
|
|
7c0489 |
#define USE_NEARBYINTL_BUILTIN 0
|
|
|
7c0489 |
#define USE_NEARBYINTF128_BUILTIN 0
|
|
|
7c0489 |
|
|
|
7c0489 |
+#define USE_RINT_BUILTIN 0
|
|
|
7c0489 |
+#define USE_RINTF_BUILTIN 0
|
|
|
7c0489 |
+#define USE_RINTL_BUILTIN 0
|
|
|
7c0489 |
+#define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
+
|
|
|
7c0489 |
#endif /* math-use-builtins.h */
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c
|
|
|
7c0489 |
index 7f3dc87b96..5f4ac7c1e3 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/dbl-64/s_rint.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/dbl-64/s_rint.c
|
|
|
7c0489 |
@@ -22,16 +22,20 @@
|
|
|
7c0489 |
#include <math.h>
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <libm-alias-double.h>
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static const double
|
|
|
7c0489 |
-TWO52[2] = {
|
|
|
7c0489 |
- 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
|
|
|
7c0489 |
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
|
|
|
7c0489 |
-};
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
double
|
|
|
7c0489 |
__rint (double x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_RINT_BUILTIN
|
|
|
7c0489 |
+ return __builtin_rint (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
+ static const double
|
|
|
7c0489 |
+ TWO52[2] = {
|
|
|
7c0489 |
+ 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
|
|
|
7c0489 |
+ -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
|
|
|
7c0489 |
+ };
|
|
|
7c0489 |
int64_t i0, sx;
|
|
|
7c0489 |
int32_t j0;
|
|
|
7c0489 |
EXTRACT_WORDS64 (i0, x);
|
|
|
7c0489 |
@@ -58,6 +62,7 @@ __rint (double x)
|
|
|
7c0489 |
}
|
|
|
7c0489 |
double w = TWO52[sx] + x;
|
|
|
7c0489 |
return w - TWO52[sx];
|
|
|
7c0489 |
+#endif /* ! USE_RINT_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
#ifndef __rint
|
|
|
7c0489 |
libm_alias_double (__rint, rint)
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
index 0bf6e8dee2..b872aefbfd 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
@@ -141,6 +141,8 @@
|
|
|
7c0489 |
#include <math-use-builtins.h>
|
|
|
7c0489 |
#undef USE_NEARBYINTL_BUILTIN
|
|
|
7c0489 |
#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN
|
|
|
7c0489 |
+#undef USE_RINTL_BUILTIN
|
|
|
7c0489 |
+#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN
|
|
|
7c0489 |
|
|
|
7c0489 |
/* IEEE function renames. */
|
|
|
7c0489 |
#define __ieee754_acoshl __ieee754_acoshf128
|
|
|
7c0489 |
@@ -343,6 +345,7 @@
|
|
|
7c0489 |
#define __builtin_copysignl __builtin_copysignf128
|
|
|
7c0489 |
#define __builtin_signbitl __builtin_signbit
|
|
|
7c0489 |
#define __builtin_nearbyintl __builtin_nearbyintf128
|
|
|
7c0489 |
+#define __builtin_rintl __builtin_rintf128
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Get the constant suffix from bits/floatn-compat.h. */
|
|
|
7c0489 |
#define L(x) __f128 (x)
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c
|
|
|
7c0489 |
index db6f260a0b..a266b1999e 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/flt-32/s_rintf.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/flt-32/s_rintf.c
|
|
|
7c0489 |
@@ -16,16 +16,20 @@
|
|
|
7c0489 |
#include <math.h>
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <libm-alias-float.h>
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static const float
|
|
|
7c0489 |
-TWO23[2]={
|
|
|
7c0489 |
- 8.3886080000e+06, /* 0x4b000000 */
|
|
|
7c0489 |
- -8.3886080000e+06, /* 0xcb000000 */
|
|
|
7c0489 |
-};
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
float
|
|
|
7c0489 |
__rintf(float x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_RINTF_BUILTIN
|
|
|
7c0489 |
+ return __builtin_rintf (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
+ static const float
|
|
|
7c0489 |
+ TWO23[2] = {
|
|
|
7c0489 |
+ 8.3886080000e+06, /* 0x4b000000 */
|
|
|
7c0489 |
+ -8.3886080000e+06, /* 0xcb000000 */
|
|
|
7c0489 |
+ };
|
|
|
7c0489 |
int32_t i0,j0,sx;
|
|
|
7c0489 |
float w,t;
|
|
|
7c0489 |
GET_FLOAT_WORD(i0,x);
|
|
|
7c0489 |
@@ -45,6 +49,7 @@ __rintf(float x)
|
|
|
7c0489 |
}
|
|
|
7c0489 |
w = TWO23[sx]+x;
|
|
|
7c0489 |
return w-TWO23[sx];
|
|
|
7c0489 |
+#endif /* ! USE_RINTF_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
#ifndef __rintf
|
|
|
7c0489 |
libm_alias_float (__rint, rint)
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/ldbl-128/s_rintl.c b/sysdeps/ieee754/ldbl-128/s_rintl.c
|
|
|
7c0489 |
index 9e6637a225..f060503066 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/ldbl-128/s_rintl.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/ldbl-128/s_rintl.c
|
|
|
7c0489 |
@@ -30,15 +30,19 @@ static char rcsid[] = "$NetBSD: $";
|
|
|
7c0489 |
#include <math.h>
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <libm-alias-ldouble.h>
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-static const _Float128
|
|
|
7c0489 |
-TWO112[2]={
|
|
|
7c0489 |
- 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */
|
|
|
7c0489 |
- -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */
|
|
|
7c0489 |
-};
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
_Float128 __rintl(_Float128 x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_RINTL_BUILTIN
|
|
|
7c0489 |
+ return __builtin_rintl (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
+ static const _Float128
|
|
|
7c0489 |
+ TWO112[2] = {
|
|
|
7c0489 |
+ 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */
|
|
|
7c0489 |
+ -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */
|
|
|
7c0489 |
+ };
|
|
|
7c0489 |
int64_t i0,j0,sx;
|
|
|
7c0489 |
uint64_t i1 __attribute__ ((unused));
|
|
|
7c0489 |
_Float128 w,t;
|
|
|
7c0489 |
@@ -59,5 +63,6 @@ _Float128 __rintl(_Float128 x)
|
|
|
7c0489 |
}
|
|
|
7c0489 |
w = TWO112[sx]+x;
|
|
|
7c0489 |
return w-TWO112[sx];
|
|
|
7c0489 |
+#endif /* ! USE_RINTL_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_alias_ldouble (__rint, rint)
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
index 7abbfb3b50..8b702a6a90 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
@@ -30,10 +30,16 @@
|
|
|
7c0489 |
# define USE_NEARBYINTF_BUILTIN 1
|
|
|
7c0489 |
# define USE_NEARBYINTL_BUILTIN 1
|
|
|
7c0489 |
|
|
|
7c0489 |
+# define USE_RINT_BUILTIN 1
|
|
|
7c0489 |
+# define USE_RINTF_BUILTIN 1
|
|
|
7c0489 |
+# define USE_RINTL_BUILTIN 1
|
|
|
7c0489 |
+
|
|
|
7c0489 |
# if __GNUC_PREREQ (8, 0)
|
|
|
7c0489 |
# define USE_NEARBYINTF128_BUILTIN 1
|
|
|
7c0489 |
+# define USE_RINTF128_BUILTIN 1
|
|
|
7c0489 |
# else
|
|
|
7c0489 |
# define USE_NEARBYINTF128_BUILTIN 0
|
|
|
7c0489 |
+# define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
# endif
|
|
|
7c0489 |
|
|
|
7c0489 |
#else
|
|
|
7c0489 |
@@ -44,6 +50,11 @@
|
|
|
7c0489 |
# define USE_NEARBYINTL_BUILTIN 0
|
|
|
7c0489 |
# define USE_NEARBYINTF128_BUILTIN 0
|
|
|
7c0489 |
|
|
|
7c0489 |
+# define USE_RINT_BUILTIN 0
|
|
|
7c0489 |
+# define USE_RINTF_BUILTIN 0
|
|
|
7c0489 |
+# define USE_RINTL_BUILTIN 0
|
|
|
7c0489 |
+# define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
+
|
|
|
7c0489 |
#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */
|
|
|
7c0489 |
|
|
|
7c0489 |
#endif /* math-use-builtins.h */
|
|
|
7c0489 |
--
|
|
|
7c0489 |
2.18.2
|
|
|
7c0489 |
|