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