|
|
7c0489 |
From 8353881ede286045dc5bdc00af6407560ca5d05b 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 09/28] Use GCC builtins for floor functions if desired.
|
|
|
7c0489 |
|
|
|
7c0489 |
This patch is using the corresponding GCC builtin for floorf, floor,
|
|
|
7c0489 |
floorl and floorf128 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 6c1b6a5e8cd91e0e1965509ad91e627e60eb00a3)
|
|
|
7c0489 |
---
|
|
|
7c0489 |
sysdeps/generic/math-use-builtins.h | 5 +++++
|
|
|
7c0489 |
sysdeps/ieee754/dbl-64/s_floor.c | 6 ++++++
|
|
|
7c0489 |
sysdeps/ieee754/float128/float128_private.h | 3 +++
|
|
|
7c0489 |
sysdeps/ieee754/flt-32/s_floorf.c | 6 ++++++
|
|
|
7c0489 |
sysdeps/ieee754/ldbl-128/s_floorl.c | 6 ++++++
|
|
|
7c0489 |
sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++
|
|
|
7c0489 |
6 files changed, 37 insertions(+)
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
index 64b4a4bb5b..e1c5df62e4 100644
|
|
|
7c0489 |
--- a/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
+++ b/sysdeps/generic/math-use-builtins.h
|
|
|
7c0489 |
@@ -31,4 +31,9 @@
|
|
|
7c0489 |
#define USE_RINTL_BUILTIN 0
|
|
|
7c0489 |
#define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
|
|
|
7c0489 |
+#define USE_FLOOR_BUILTIN 0
|
|
|
7c0489 |
+#define USE_FLOORF_BUILTIN 0
|
|
|
7c0489 |
+#define USE_FLOORL_BUILTIN 0
|
|
|
7c0489 |
+#define USE_FLOORF128_BUILTIN 0
|
|
|
7c0489 |
+
|
|
|
7c0489 |
#endif /* math-use-builtins.h */
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/dbl-64/s_floor.c b/sysdeps/ieee754/dbl-64/s_floor.c
|
|
|
7c0489 |
index b551a1aafa..693938b708 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/dbl-64/s_floor.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/dbl-64/s_floor.c
|
|
|
7c0489 |
@@ -34,6 +34,7 @@
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <stdint.h>
|
|
|
7c0489 |
#include <libm-alias-double.h>
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
/*
|
|
|
7c0489 |
* floor(x)
|
|
|
7c0489 |
@@ -45,6 +46,10 @@
|
|
|
7c0489 |
double
|
|
|
7c0489 |
__floor (double x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_FLOOR_BUILTIN
|
|
|
7c0489 |
+ return __builtin_floor (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
int64_t i0;
|
|
|
7c0489 |
EXTRACT_WORDS64 (i0, x);
|
|
|
7c0489 |
int32_t j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
|
|
|
7c0489 |
@@ -72,6 +77,7 @@ __floor (double x)
|
|
|
7c0489 |
else if (j0 == 0x400)
|
|
|
7c0489 |
return x + x; /* inf or NaN */
|
|
|
7c0489 |
return x;
|
|
|
7c0489 |
+#endif /* ! USE_FLOOR_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
#ifndef __floor
|
|
|
7c0489 |
libm_alias_double (__floor, floor)
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
index b872aefbfd..667030ab06 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/float128/float128_private.h
|
|
|
7c0489 |
@@ -143,6 +143,8 @@
|
|
|
7c0489 |
#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN
|
|
|
7c0489 |
#undef USE_RINTL_BUILTIN
|
|
|
7c0489 |
#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN
|
|
|
7c0489 |
+#undef USE_FLOORL_BUILTIN
|
|
|
7c0489 |
+#define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN
|
|
|
7c0489 |
|
|
|
7c0489 |
/* IEEE function renames. */
|
|
|
7c0489 |
#define __ieee754_acoshl __ieee754_acoshf128
|
|
|
7c0489 |
@@ -346,6 +348,7 @@
|
|
|
7c0489 |
#define __builtin_signbitl __builtin_signbit
|
|
|
7c0489 |
#define __builtin_nearbyintl __builtin_nearbyintf128
|
|
|
7c0489 |
#define __builtin_rintl __builtin_rintf128
|
|
|
7c0489 |
+#define __builtin_floorl __builtin_floorf128
|
|
|
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_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c
|
|
|
7c0489 |
index 12aed343a0..6d37ab90a1 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/flt-32/s_floorf.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/flt-32/s_floorf.c
|
|
|
7c0489 |
@@ -23,10 +23,15 @@
|
|
|
7c0489 |
#include <math.h>
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <libm-alias-float.h>
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
float
|
|
|
7c0489 |
__floorf(float x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_FLOORF_BUILTIN
|
|
|
7c0489 |
+ return __builtin_floorf (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
int32_t i0,j0;
|
|
|
7c0489 |
uint32_t i;
|
|
|
7c0489 |
GET_FLOAT_WORD(i0,x);
|
|
|
7c0489 |
@@ -49,6 +54,7 @@ __floorf(float x)
|
|
|
7c0489 |
}
|
|
|
7c0489 |
SET_FLOAT_WORD(x,i0);
|
|
|
7c0489 |
return x;
|
|
|
7c0489 |
+#endif /* ! USE_FLOORF_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
#ifndef __floorf
|
|
|
7c0489 |
libm_alias_float (__floor, floor)
|
|
|
7c0489 |
diff --git a/sysdeps/ieee754/ldbl-128/s_floorl.c b/sysdeps/ieee754/ldbl-128/s_floorl.c
|
|
|
7c0489 |
index f9c5e014f9..6143fe6ec5 100644
|
|
|
7c0489 |
--- a/sysdeps/ieee754/ldbl-128/s_floorl.c
|
|
|
7c0489 |
+++ b/sysdeps/ieee754/ldbl-128/s_floorl.c
|
|
|
7c0489 |
@@ -27,9 +27,14 @@ static char rcsid[] = "$NetBSD: $";
|
|
|
7c0489 |
#include <math.h>
|
|
|
7c0489 |
#include <math_private.h>
|
|
|
7c0489 |
#include <libm-alias-ldouble.h>
|
|
|
7c0489 |
+#include <math-use-builtins.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
_Float128 __floorl(_Float128 x)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
+#if USE_FLOORL_BUILTIN
|
|
|
7c0489 |
+ return __builtin_floorl (x);
|
|
|
7c0489 |
+#else
|
|
|
7c0489 |
+ /* Use generic implementation. */
|
|
|
7c0489 |
int64_t i0,i1,j0;
|
|
|
7c0489 |
uint64_t i,j;
|
|
|
7c0489 |
GET_LDOUBLE_WORDS64(i0,i1,x);
|
|
|
7c0489 |
@@ -64,5 +69,6 @@ _Float128 __floorl(_Float128 x)
|
|
|
7c0489 |
}
|
|
|
7c0489 |
SET_LDOUBLE_WORDS64(x,i0,i1);
|
|
|
7c0489 |
return x;
|
|
|
7c0489 |
+#endif /* ! USE_FLOORL_BUILTIN */
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_alias_ldouble (__floor, floor)
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
index 8b702a6a90..c213c16c6f 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
7c0489 |
@@ -34,12 +34,18 @@
|
|
|
7c0489 |
# define USE_RINTF_BUILTIN 1
|
|
|
7c0489 |
# define USE_RINTL_BUILTIN 1
|
|
|
7c0489 |
|
|
|
7c0489 |
+# define USE_FLOOR_BUILTIN 1
|
|
|
7c0489 |
+# define USE_FLOORF_BUILTIN 1
|
|
|
7c0489 |
+# define USE_FLOORL_BUILTIN 1
|
|
|
7c0489 |
+
|
|
|
7c0489 |
# if __GNUC_PREREQ (8, 0)
|
|
|
7c0489 |
# define USE_NEARBYINTF128_BUILTIN 1
|
|
|
7c0489 |
# define USE_RINTF128_BUILTIN 1
|
|
|
7c0489 |
+# define USE_FLOORF128_BUILTIN 1
|
|
|
7c0489 |
# else
|
|
|
7c0489 |
# define USE_NEARBYINTF128_BUILTIN 0
|
|
|
7c0489 |
# define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
+# define USE_FLOORF128_BUILTIN 0
|
|
|
7c0489 |
# endif
|
|
|
7c0489 |
|
|
|
7c0489 |
#else
|
|
|
7c0489 |
@@ -55,6 +61,11 @@
|
|
|
7c0489 |
# define USE_RINTL_BUILTIN 0
|
|
|
7c0489 |
# define USE_RINTF128_BUILTIN 0
|
|
|
7c0489 |
|
|
|
7c0489 |
+# define USE_FLOOR_BUILTIN 0
|
|
|
7c0489 |
+# define USE_FLOORF_BUILTIN 0
|
|
|
7c0489 |
+# define USE_FLOORL_BUILTIN 0
|
|
|
7c0489 |
+# define USE_FLOORF128_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 |
|