|
|
a2cf7d |
From 6c5e5f498cd004b3f42d97997898018df8f798a4 Mon Sep 17 00:00:00 2001
|
|
|
a2cf7d |
From: Stefan Liebler <stli@linux.ibm.com>
|
|
|
a2cf7d |
Date: Wed, 11 Dec 2019 15:09:21 +0100
|
|
|
a2cf7d |
Subject: [PATCH 10/28] Use GCC builtins for ceil functions if desired.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
This patch is using the corresponding GCC builtin for ceilf, ceil,
|
|
|
a2cf7d |
ceill and ceilf128 if the USE_FUNCTION_BUILTIN macros are defined to one
|
|
|
a2cf7d |
in math-use-builtins.h.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
This is the case for s390 if build with at least --march=z196 --mzarch.
|
|
|
a2cf7d |
Otherwise the generic implementation is used. The code of the generic
|
|
|
a2cf7d |
implementation is not changed.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
a2cf7d |
(cherry picked from commit 62560ee84095274bab1050817f42e782df226a17)
|
|
|
a2cf7d |
---
|
|
|
a2cf7d |
sysdeps/generic/math-use-builtins.h | 5 +++++
|
|
|
a2cf7d |
sysdeps/ieee754/dbl-64/s_ceil.c | 6 ++++++
|
|
|
a2cf7d |
sysdeps/ieee754/float128/float128_private.h | 3 +++
|
|
|
a2cf7d |
sysdeps/ieee754/flt-32/s_ceilf.c | 7 ++++++-
|
|
|
a2cf7d |
sysdeps/ieee754/ldbl-128/s_ceill.c | 6 ++++++
|
|
|
a2cf7d |
sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++
|
|
|
a2cf7d |
6 files changed, 37 insertions(+), 1 deletion(-)
|
|
|
a2cf7d |
|
|
|
a2cf7d |
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
|
|
|
a2cf7d |
index e1c5df62e4..076ec661b0 100644
|
|
|
a2cf7d |
--- a/sysdeps/generic/math-use-builtins.h
|
|
|
a2cf7d |
+++ b/sysdeps/generic/math-use-builtins.h
|
|
|
a2cf7d |
@@ -36,4 +36,9 @@
|
|
|
a2cf7d |
#define USE_FLOORL_BUILTIN 0
|
|
|
a2cf7d |
#define USE_FLOORF128_BUILTIN 0
|
|
|
a2cf7d |
|
|
|
a2cf7d |
+#define USE_CEIL_BUILTIN 0
|
|
|
a2cf7d |
+#define USE_CEILF_BUILTIN 0
|
|
|
a2cf7d |
+#define USE_CEILL_BUILTIN 0
|
|
|
a2cf7d |
+#define USE_CEILF128_BUILTIN 0
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
#endif /* math-use-builtins.h */
|
|
|
a2cf7d |
diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c
|
|
|
a2cf7d |
index 3becdfc515..ee4a3abc19 100644
|
|
|
a2cf7d |
--- a/sysdeps/ieee754/dbl-64/s_ceil.c
|
|
|
a2cf7d |
+++ b/sysdeps/ieee754/dbl-64/s_ceil.c
|
|
|
a2cf7d |
@@ -20,10 +20,15 @@
|
|
|
a2cf7d |
#include <math.h>
|
|
|
a2cf7d |
#include <math_private.h>
|
|
|
a2cf7d |
#include <libm-alias-double.h>
|
|
|
a2cf7d |
+#include <math-use-builtins.h>
|
|
|
a2cf7d |
|
|
|
a2cf7d |
double
|
|
|
a2cf7d |
__ceil (double x)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
+#if USE_CEIL_BUILTIN
|
|
|
a2cf7d |
+ return __builtin_ceil (x);
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+ /* Use generic implementation. */
|
|
|
a2cf7d |
int64_t i0, i;
|
|
|
a2cf7d |
int32_t j0;
|
|
|
a2cf7d |
EXTRACT_WORDS64 (i0, x);
|
|
|
a2cf7d |
@@ -57,6 +62,7 @@ __ceil (double x)
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
INSERT_WORDS64 (x, i0);
|
|
|
a2cf7d |
return x;
|
|
|
a2cf7d |
+#endif /* ! USE_CEIL_BUILTIN */
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
#ifndef __ceil
|
|
|
a2cf7d |
libm_alias_double (__ceil, ceil)
|
|
|
a2cf7d |
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
|
|
|
a2cf7d |
index 667030ab06..19352ca26c 100644
|
|
|
a2cf7d |
--- a/sysdeps/ieee754/float128/float128_private.h
|
|
|
a2cf7d |
+++ b/sysdeps/ieee754/float128/float128_private.h
|
|
|
a2cf7d |
@@ -145,6 +145,8 @@
|
|
|
a2cf7d |
#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN
|
|
|
a2cf7d |
#undef USE_FLOORL_BUILTIN
|
|
|
a2cf7d |
#define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN
|
|
|
a2cf7d |
+#undef USE_CEILL_BUILTIN
|
|
|
a2cf7d |
+#define USE_CEILL_BUILTIN USE_CEILF128_BUILTIN
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* IEEE function renames. */
|
|
|
a2cf7d |
#define __ieee754_acoshl __ieee754_acoshf128
|
|
|
a2cf7d |
@@ -349,6 +351,7 @@
|
|
|
a2cf7d |
#define __builtin_nearbyintl __builtin_nearbyintf128
|
|
|
a2cf7d |
#define __builtin_rintl __builtin_rintf128
|
|
|
a2cf7d |
#define __builtin_floorl __builtin_floorf128
|
|
|
a2cf7d |
+#define __builtin_ceill __builtin_ceilf128
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Get the constant suffix from bits/floatn-compat.h. */
|
|
|
a2cf7d |
#define L(x) __f128 (x)
|
|
|
a2cf7d |
diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c
|
|
|
a2cf7d |
index f289ec2341..6cab7bdd62 100644
|
|
|
a2cf7d |
--- a/sysdeps/ieee754/flt-32/s_ceilf.c
|
|
|
a2cf7d |
+++ b/sysdeps/ieee754/flt-32/s_ceilf.c
|
|
|
a2cf7d |
@@ -16,11 +16,15 @@
|
|
|
a2cf7d |
#include <math.h>
|
|
|
a2cf7d |
#include <math_private.h>
|
|
|
a2cf7d |
#include <libm-alias-float.h>
|
|
|
a2cf7d |
-
|
|
|
a2cf7d |
+#include <math-use-builtins.h>
|
|
|
a2cf7d |
|
|
|
a2cf7d |
float
|
|
|
a2cf7d |
__ceilf(float x)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
+#if USE_CEILF_BUILTIN
|
|
|
a2cf7d |
+ return __builtin_ceilf (x);
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+ /* Use generic implementation. */
|
|
|
a2cf7d |
int32_t i0,j0;
|
|
|
a2cf7d |
uint32_t i;
|
|
|
a2cf7d |
|
|
|
a2cf7d |
@@ -43,6 +47,7 @@ __ceilf(float x)
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
SET_FLOAT_WORD(x,i0);
|
|
|
a2cf7d |
return x;
|
|
|
a2cf7d |
+#endif /* ! USE_CEILF_BUILTIN */
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
#ifndef __ceilf
|
|
|
a2cf7d |
libm_alias_float (__ceil, ceil)
|
|
|
a2cf7d |
diff --git a/sysdeps/ieee754/ldbl-128/s_ceill.c b/sysdeps/ieee754/ldbl-128/s_ceill.c
|
|
|
a2cf7d |
index e6aba5f2af..d212d86179 100644
|
|
|
a2cf7d |
--- a/sysdeps/ieee754/ldbl-128/s_ceill.c
|
|
|
a2cf7d |
+++ b/sysdeps/ieee754/ldbl-128/s_ceill.c
|
|
|
a2cf7d |
@@ -27,9 +27,14 @@ static char rcsid[] = "$NetBSD: $";
|
|
|
a2cf7d |
#include <math.h>
|
|
|
a2cf7d |
#include <math_private.h>
|
|
|
a2cf7d |
#include <libm-alias-ldouble.h>
|
|
|
a2cf7d |
+#include <math-use-builtins.h>
|
|
|
a2cf7d |
|
|
|
a2cf7d |
_Float128 __ceill(_Float128 x)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
+#if USE_CEILL_BUILTIN
|
|
|
a2cf7d |
+ return __builtin_ceill (x);
|
|
|
a2cf7d |
+#else
|
|
|
a2cf7d |
+ /* Use generic implementation. */
|
|
|
a2cf7d |
int64_t i0,i1,j0;
|
|
|
a2cf7d |
uint64_t i,j;
|
|
|
a2cf7d |
GET_LDOUBLE_WORDS64(i0,i1,x);
|
|
|
a2cf7d |
@@ -63,5 +68,6 @@ _Float128 __ceill(_Float128 x)
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
SET_LDOUBLE_WORDS64(x,i0,i1);
|
|
|
a2cf7d |
return x;
|
|
|
a2cf7d |
+#endif /* ! USE_CEILL_BUILTIN */
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
libm_alias_ldouble (__ceil, ceil)
|
|
|
a2cf7d |
diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
a2cf7d |
index c213c16c6f..5435cbb65f 100644
|
|
|
a2cf7d |
--- a/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
a2cf7d |
+++ b/sysdeps/s390/fpu/math-use-builtins.h
|
|
|
a2cf7d |
@@ -38,14 +38,20 @@
|
|
|
a2cf7d |
# define USE_FLOORF_BUILTIN 1
|
|
|
a2cf7d |
# define USE_FLOORL_BUILTIN 1
|
|
|
a2cf7d |
|
|
|
a2cf7d |
+# define USE_CEIL_BUILTIN 1
|
|
|
a2cf7d |
+# define USE_CEILF_BUILTIN 1
|
|
|
a2cf7d |
+# define USE_CEILL_BUILTIN 1
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
# if __GNUC_PREREQ (8, 0)
|
|
|
a2cf7d |
# define USE_NEARBYINTF128_BUILTIN 1
|
|
|
a2cf7d |
# define USE_RINTF128_BUILTIN 1
|
|
|
a2cf7d |
# define USE_FLOORF128_BUILTIN 1
|
|
|
a2cf7d |
+# define USE_CEILF128_BUILTIN 1
|
|
|
a2cf7d |
# else
|
|
|
a2cf7d |
# define USE_NEARBYINTF128_BUILTIN 0
|
|
|
a2cf7d |
# define USE_RINTF128_BUILTIN 0
|
|
|
a2cf7d |
# define USE_FLOORF128_BUILTIN 0
|
|
|
a2cf7d |
+# define USE_CEILF128_BUILTIN 0
|
|
|
a2cf7d |
# endif
|
|
|
a2cf7d |
|
|
|
a2cf7d |
#else
|
|
|
a2cf7d |
@@ -66,6 +72,11 @@
|
|
|
a2cf7d |
# define USE_FLOORL_BUILTIN 0
|
|
|
a2cf7d |
# define USE_FLOORF128_BUILTIN 0
|
|
|
a2cf7d |
|
|
|
a2cf7d |
+# define USE_CEIL_BUILTIN 0
|
|
|
a2cf7d |
+# define USE_CEILF_BUILTIN 0
|
|
|
a2cf7d |
+# define USE_CEILL_BUILTIN 0
|
|
|
a2cf7d |
+# define USE_CEILF128_BUILTIN 0
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */
|
|
|
a2cf7d |
|
|
|
a2cf7d |
#endif /* math-use-builtins.h */
|
|
|
a2cf7d |
--
|
|
|
a2cf7d |
2.18.2
|
|
|
a2cf7d |
|