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