|
|
8a8cfb |
commit 4997e8f31e7415652c3dedec672c0e9bf8caa9ca
|
|
|
8a8cfb |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
8a8cfb |
Date: Fri Feb 1 10:39:57 2019 -0200
|
|
|
8a8cfb |
|
|
|
8a8cfb |
math: Enable some math builtins for clang
|
|
|
8a8cfb |
|
|
|
8a8cfb |
This patch enable the builtin usage for clang for the C99 functions
|
|
|
8a8cfb |
fpclassify, isfinite, isnormal, isnan, isinf, and sigbit. This allows
|
|
|
8a8cfb |
clang optimize the calls on frontend instead of call the appropriate
|
|
|
8a8cfb |
glibc symbols.
|
|
|
8a8cfb |
|
|
|
8a8cfb |
Checked on aarch64-linux-gnu and x86_64-linux-gnu. I checked the supported
|
|
|
8a8cfb |
version for each builtin based on released version from clang/llvm.
|
|
|
8a8cfb |
|
|
|
8a8cfb |
* math/math.h (fpclassify, isfinite, isnormal, isnan): Use builtin for
|
|
|
8a8cfb |
clang 2.8.
|
|
|
8a8cfb |
(signbit): Use builtin for clang 3.3.
|
|
|
8a8cfb |
(isinf): Use builtin for clang 3.7.
|
|
|
8a8cfb |
|
|
|
8a8cfb |
diff --git a/math/math.h b/math/math.h
|
|
|
8a8cfb |
index ddee4e408389722f..b3b414f3678e91f7 100644
|
|
|
8a8cfb |
--- a/math/math.h
|
|
|
8a8cfb |
+++ b/math/math.h
|
|
|
8a8cfb |
@@ -874,7 +874,8 @@ enum
|
|
|
8a8cfb |
the __SUPPORT_SNAN__ check may be skipped for those versions. */
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Return number of classification appropriate for X. */
|
|
|
8a8cfb |
-# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \
|
|
|
8a8cfb |
+# if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
|
|
|
8a8cfb |
+ || __glibc_clang_prereq (2,8)) \
|
|
|
8a8cfb |
&& (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
|
|
|
8a8cfb |
/* The check for __cplusplus allows the use of the builtin, even
|
|
|
8a8cfb |
when optimization for size is on. This is provided for
|
|
|
8a8cfb |
@@ -889,7 +890,7 @@ enum
|
|
|
8a8cfb |
# endif
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Return nonzero value if sign of X is negative. */
|
|
|
8a8cfb |
-# if __GNUC_PREREQ (6,0)
|
|
|
8a8cfb |
+# if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3)
|
|
|
8a8cfb |
# define signbit(x) __builtin_signbit (x)
|
|
|
8a8cfb |
# elif defined __cplusplus
|
|
|
8a8cfb |
/* In C++ mode, __MATH_TG cannot be used, because it relies on
|
|
|
8a8cfb |
@@ -907,14 +908,16 @@ enum
|
|
|
8a8cfb |
# endif
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Return nonzero value if X is not +-Inf or NaN. */
|
|
|
8a8cfb |
-# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
|
|
|
8a8cfb |
+# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
|
|
|
8a8cfb |
+ || __glibc_clang_prereq (2,8)
|
|
|
8a8cfb |
# define isfinite(x) __builtin_isfinite (x)
|
|
|
8a8cfb |
# else
|
|
|
8a8cfb |
# define isfinite(x) __MATH_TG ((x), __finite, (x))
|
|
|
8a8cfb |
# endif
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
|
|
|
8a8cfb |
-# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
|
|
|
8a8cfb |
+# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
|
|
|
8a8cfb |
+ || __glibc_clang_prereq (2,8)
|
|
|
8a8cfb |
# define isnormal(x) __builtin_isnormal (x)
|
|
|
8a8cfb |
# else
|
|
|
8a8cfb |
# define isnormal(x) (fpclassify (x) == FP_NORMAL)
|
|
|
8a8cfb |
@@ -922,7 +925,8 @@ enum
|
|
|
8a8cfb |
|
|
|
8a8cfb |
/* Return nonzero value if X is a NaN. We could use `fpclassify' but
|
|
|
8a8cfb |
we already have this functions `__isnan' and it is faster. */
|
|
|
8a8cfb |
-# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
|
|
|
8a8cfb |
+# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
|
|
|
8a8cfb |
+ || __glibc_clang_prereq (2,8)
|
|
|
8a8cfb |
# define isnan(x) __builtin_isnan (x)
|
|
|
8a8cfb |
# else
|
|
|
8a8cfb |
# define isnan(x) __MATH_TG ((x), __isnan, (x))
|
|
|
8a8cfb |
@@ -939,7 +943,8 @@ enum
|
|
|
8a8cfb |
# define isinf(x) \
|
|
|
8a8cfb |
(__builtin_types_compatible_p (__typeof (x), _Float128) \
|
|
|
8a8cfb |
? __isinff128 (x) : __builtin_isinf_sign (x))
|
|
|
8a8cfb |
-# elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
|
|
|
8a8cfb |
+# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
|
|
|
8a8cfb |
+ || __glibc_clang_prereq (3,7)
|
|
|
8a8cfb |
# define isinf(x) __builtin_isinf_sign (x)
|
|
|
8a8cfb |
# else
|
|
|
8a8cfb |
# define isinf(x) __MATH_TG ((x), __isinf, (x))
|