summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-10 10:28:56 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-11-17 11:17:07 -0300
commit13cfd77bf5679e8a888a63e233fb60529177b278 (patch)
tree5a5df83fab6cd1d08f0a225a10a6cd39c2749f31
parenta0ce8b0779e290596e99ca6d96c301684a2d7cfe (diff)
math: Don't redirect inlined builtin math functions
When we want to inline builtin math functions, like truncf, for extern float truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); float (truncf) (float) asm ("__truncf"); compiler may redirect truncf calls to __truncf, instead of inlining it (for instance, clang). The USE_TRUNCF_BUILTIN is 1 to indicate that truncf should be inlined. In this case, we don't want the truncf redirection: 1. For each math function which may be inlined, we define #if USE_TRUNCF_BUILTIN # define NO_truncf_BUILTIN inline_truncf #else # define NO_truncf_BUILTIN truncf #endif in <math-use-builtins.h>. 2. Include <math-use-builtins.h> in include/math.h. 3. Change MATH_REDIRECT to #define MATH_REDIRECT(FUNC, PREFIX, ARGS) \ float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \ asm (PREFIX #FUNC "f"); With this change If USE_TRUNCF_BUILTIN is 0, we get float (truncf) (float) asm ("__truncf"); truncf will be redirected to __truncf. And for USE_TRUNCF_BUILTIN 1, we get: float (inline_truncf) (float) asm ("__truncf"); In both cases either truncf will be inlined or the internal alias (__truncf) will be called. It is not required for all math-use-builtin symbol, only the one defined in math.h. It also allows to remove all the math-use-builtin inclusion, since it is now implicitly included by math.h. For MIPS, some math-use-builtin headers include sysdep.h and this in turn includes a lot of extra headers that do not allow ldbl-128 code to override alias definition (math.h will include some stdlib.h definition). The math-use-builtin only requires the __mips_isa_rev, so move the defintion to sgidefs.h. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r--include/math.h22
-rw-r--r--math/s_fmax_template.c1
-rw-r--r--math/s_fmin_template.c2
-rw-r--r--sysdeps/generic/math-use-builtins-copysign.h2
-rw-r--r--sysdeps/generic/math-use-builtins.h196
-rw-r--r--sysdeps/ieee754/dbl-64/e_hypot.c1
-rw-r--r--sysdeps/ieee754/dbl-64/e_sqrt.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_ceil.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_floor.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_fma.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_fmaf.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_llrint.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_llround.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_logb.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_lrint.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_lround.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_modf.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_nearbyint.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_rint.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_round.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_roundeven.c1
-rw-r--r--sysdeps/ieee754/dbl-64/s_trunc.c2
-rw-r--r--sysdeps/ieee754/float128/float128_private.h1
-rw-r--r--sysdeps/ieee754/flt-32/s_ceilf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_floorf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_llrintf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_llroundf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_logbf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_lrintf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_lroundf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_modff.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_nearbyintf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_rintf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_roundevenf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_roundf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_truncf.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_ceill.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_copysignl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_floorl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_fmal.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_llrintl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_logbl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_lrintl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_nearbyintl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_rintl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_roundevenl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_roundl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_truncl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_fabsl.c1
-rw-r--r--sysdeps/ieee754/ldbl-96/s_fabsl.c1
-rw-r--r--sysdeps/mips/fpu/math-use-builtins-fma.h2
-rw-r--r--sysdeps/mips/isarev.h8
-rw-r--r--sysdeps/mips/math-use-builtins-ffs.h2
-rw-r--r--sysdeps/powerpc/fpu/e_sqrt.c1
-rw-r--r--sysdeps/unix/mips/sysdep.h4
-rw-r--r--sysdeps/x86_64/fpu/multiarch/s_modf-avx.c4
-rw-r--r--sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c4
-rw-r--r--sysdeps/x86_64/fpu/multiarch/s_modff-avx.c4
-rw-r--r--sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c4
59 files changed, 225 insertions, 79 deletions
diff --git a/include/math.h b/include/math.h
index 1236268804..84d44d44dc 100644
--- a/include/math.h
+++ b/include/math.h
@@ -139,25 +139,35 @@ fabsf128 (_Float128 x)
/* NB: Internal tests don't have access to internal symbols. */
# if !IS_IN (testsuite_internal) \
&& !(defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
+/* NO_MATH_REDIRECT must be defined in the source implementing function,
+ FUNC, if FUNC is implemented as an alias of __FUNC or vice versa to
+ avoid redirecting FUNC to __FUNC. */
+# include <math-use-builtins.h>
+/* NB: Do not redirect math builtin functions when they are inlined. */
# ifndef NO_MATH_REDIRECT
/* Declare some functions for use within GLIBC. Compilers typically
inline those functions as a single instruction. Use an asm to
avoid use of PLTs if it doesn't. */
# define MATH_REDIRECT(FUNC, PREFIX, ARGS) \
- float (FUNC ## f) (ARGS (float)) asm (PREFIX #FUNC "f"); \
- double (FUNC) (ARGS (double)) asm (PREFIX #FUNC ); \
+ float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \
+ asm (PREFIX #FUNC "f"); \
+ double (NO_ ## FUNC ## _BUILTIN) (ARGS (double)) \
+ asm (PREFIX #FUNC ); \
MATH_REDIRECT_LDBL (FUNC, PREFIX, ARGS) \
MATH_REDIRECT_F128 (FUNC, PREFIX, ARGS)
+
# if defined __NO_LONG_DOUBLE_MATH \
|| __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
# define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS)
# else
-# define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS) \
- long double (FUNC ## l) (ARGS (long double)) asm (PREFIX #FUNC "l");
+# define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS) \
+ long double (NO_ ## FUNC ## l ## _BUILTIN) (ARGS (long double)) \
+ asm (PREFIX #FUNC "l");
# endif
# if __HAVE_DISTINCT_FLOAT128
-# define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS) \
- _Float128 (FUNC ## f128) (ARGS (_Float128)) asm (PREFIX #FUNC "f128");
+# define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS) \
+ _Float128 (NO_ ## FUNC ## f128 ## _BUILTIN) (ARGS (_Float128)) \
+ asm (PREFIX #FUNC "f128");
# else
# define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS)
# endif
diff --git a/math/s_fmax_template.c b/math/s_fmax_template.c
index bdf71096af..87e6ee67df 100644
--- a/math/s_fmax_template.c
+++ b/math/s_fmax_template.c
@@ -17,7 +17,6 @@
<https://www.gnu.org/licenses/>. */
#include <math.h>
-#include <math-use-builtins.h>
FLOAT
M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y)
diff --git a/math/s_fmin_template.c b/math/s_fmin_template.c
index 99d25aa5b9..9ff330969f 100644
--- a/math/s_fmin_template.c
+++ b/math/s_fmin_template.c
@@ -17,8 +17,6 @@
<https://www.gnu.org/licenses/>. */
#include <math.h>
-#include <math-use-builtins.h>
-
FLOAT
M_DECL_FUNC (__fmin) (FLOAT x, FLOAT y)
diff --git a/sysdeps/generic/math-use-builtins-copysign.h b/sysdeps/generic/math-use-builtins-copysign.h
index b774931f43..4bca2ee1b1 100644
--- a/sysdeps/generic/math-use-builtins-copysign.h
+++ b/sysdeps/generic/math-use-builtins-copysign.h
@@ -1,4 +1,6 @@
/* Generic implementations for float and double always use the builtin. */
+#define USE_COPYSIGNF_BUILTIN 1
+#define USE_COPYSIGN_BUILTIN 1
#define USE_COPYSIGNL_BUILTIN 1
#if __GNUC_PREREQ (7, 0)
# define USE_COPYSIGNF128_BUILTIN 1
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
index e069b161b1..13b037fb9e 100644
--- a/sysdeps/generic/math-use-builtins.h
+++ b/sysdeps/generic/math-use-builtins.h
@@ -44,4 +44,200 @@
#include <math-use-builtins-lround.h>
#include <math-use-builtins-llround.h>
+
+/* Disable internal alias optimizations done at include/math.h if the
+ compiler can expand the builtin for the symbol. Different than gcc, the
+ clang will always expand the alias before handling the builtin expansion,
+ which makes the builtin expansion ineffective. */
+
+#if USE_SQRT_BUILTIN
+# define NO_sqrt_BUILTIN inline_sqrt
+#else
+# define NO_sqrt_BUILTIN sqrt
+#endif
+#if USE_SQRTF_BUILTIN
+# define NO_sqrtf_BUILTIN inline_sqrtf
+#else
+# define NO_sqrtf_BUILTIN sqrtf
+#endif
+#if USE_SQRTL_BUILTIN
+# define NO_sqrtl_BUILTIN inline_sqrtl
+#else
+# define NO_sqrtl_BUILTIN sqrtl
+#endif
+#if USE_SQRTF128_BUILTIN
+# define NO_sqrtf128_BUILTIN inline_sqrtf128
+#else
+# define NO_sqrtf128_BUILTIN sqrtf128
+#endif
+
+
+#if USE_CEIL_BUILTIN
+# define NO_ceil_BUILTIN inline_ceil
+#else
+# define NO_ceil_BUILTIN ceil
+#endif
+#if USE_CEILF_BUILTIN
+# define NO_ceilf_BUILTIN inline_ceilf
+#else
+# define NO_ceilf_BUILTIN ceilf
+#endif
+#if USE_CEILL_BUILTIN
+# define NO_ceill_BUILTIN inline_ceill
+#else
+# define NO_ceill_BUILTIN ceill
+#endif
+#if USE_CEILF128_BUILTIN
+# define NO_ceilf128_BUILTIN inline_ceilf128
+#else
+# define NO_ceilf128_BUILTIN ceilf128
+#endif
+
+#if USE_FLOOR_BUILTIN
+# define NO_floor_BUILTIN inline_floor
+#else
+# define NO_floor_BUILTIN floor
+#endif
+#if USE_FLOORF_BUILTIN
+# define NO_floorf_BUILTIN inline_floorf
+#else
+# define NO_floorf_BUILTIN floorf
+#endif
+#if USE_FLOORL_BUILTIN
+# define NO_floorl_BUILTIN inline_floorl
+#else
+# define NO_floorl_BUILTIN floorl
+#endif
+#if USE_FLOORF128_BUILTIN
+# define NO_floorf128_BUILTIN inline_floorf128
+#else
+# define NO_floorf128_BUILTIN floorf128
+#endif
+
+#if USE_ROUNDEVEN_BUILTIN
+# define NO_roundeven_BUILTIN inline_roundeven
+#else
+# define NO_roundeven_BUILTIN roundeven
+#endif
+#if USE_ROUNDEVENF_BUILTIN
+# define NO_roundevenf_BUILTIN inline_roundevenf
+#else
+# define NO_roundevenf_BUILTIN roundevenf
+#endif
+#if USE_ROUNDEVENL_BUILTIN
+# define NO_roundevenl_BUILTIN inline_roundevenl
+#else
+# define NO_roundevenl_BUILTIN roundevenl
+#endif
+#if USE_ROUNDEVENF128_BUILTIN
+# define NO_roundevenf128_BUILTIN inline_roundevenf128
+#else
+# define NO_roundevenf128_BUILTIN roundevenf128
+#endif
+
+#if USE_RINT_BUILTIN
+# define NO_rint_BUILTIN inline_rint
+#else
+# define NO_rint_BUILTIN rint
+#endif
+#if USE_RINTF_BUILTIN
+# define NO_rintf_BUILTIN inline_rintf
+#else
+# define NO_rintf_BUILTIN rintf
+#endif
+#if USE_RINTL_BUILTIN
+# define NO_rintl_BUILTIN inline_rintl
+#else
+# define NO_rintl_BUILTIN rintl
+#endif
+#if USE_RINTF128_BUILTIN
+# define NO_rintf128_BUILTIN inline_rintf128
+#else
+# define NO_rintf128_BUILTIN rintf128
+#endif
+
+#if USE_TRUNC_BUILTIN
+# define NO_trunc_BUILTIN inline_trunc
+#else
+# define NO_trunc_BUILTIN trunc
+#endif
+#if USE_TRUNCF_BUILTIN
+# define NO_truncf_BUILTIN inline_truncf
+#else
+# define NO_truncf_BUILTIN truncf
+#endif
+#if USE_TRUNCL_BUILTIN
+# define NO_truncl_BUILTIN inline_truncl
+#else
+# define NO_truncl_BUILTIN truncl
+#endif
+#if USE_TRUNCF128_BUILTIN
+# define NO_truncf128_BUILTIN inline_truncf128
+#else
+# define NO_truncf128_BUILTIN truncf128
+#endif
+
+#if USE_ROUND_BUILTIN
+# define NO_round_BUILTIN inline_round
+#else
+# define NO_round_BUILTIN round
+#endif
+#if USE_ROUNDF_BUILTIN
+# define NO_roundf_BUILTIN inline_roundf
+#else
+# define NO_roundf_BUILTIN roundf
+#endif
+#if USE_ROUNDL_BUILTIN
+# define NO_roundl_BUILTIN inline_roundl
+#else
+# define NO_roundl_BUILTIN roundl
+#endif
+#if USE_ROUNDF128_BUILTIN
+# define NO_roundf128_BUILTIN inline_roundf128
+#else
+# define NO_roundf128_BUILTIN roundf128
+#endif
+
+#if USE_COPYSIGN_BUILTIN
+# define NO_copysign_BUILTIN inline_copysign
+#else
+# define NO_copysign_BUILTIN copysign
+#endif
+#if USE_COPYSIGNF_BUILTIN
+# define NO_copysignf_BUILTIN inline_copysignf
+#else
+# define NO_copysignf_BUILTIN copysignf
+#endif
+#if USE_COPYSIGNL_BUILTIN
+# define NO_copysignl_BUILTIN inline_copysignl
+#else
+# define NO_copysignl_BUILTIN copysignl
+#endif
+#if USE_COPYSIGNF128_BUILTIN
+# define NO_copysignf128_BUILTIN inline_copysignf128
+#else
+# define NO_copysignf128_BUILTIN copysignf128
+#endif
+
+#if USE_FMA_BUILTIN
+# define NO_fma_BUILTIN inline_fma
+#else
+# define NO_fma_BUILTIN fma
+#endif
+#if USE_FMAF_BUILTIN
+# define NO_fmaf_BUILTIN inline_fmaf
+#else
+# define NO_fmaf_BUILTIN fmaf
+#endif
+#if USE_FMAL_BUILTIN
+# define NO_fmal_BUILTIN inline_fmal
+#else
+# define NO_fmal_BUILTIN fmal
+#endif
+#if USE_FMAF128_BUILTIN
+# define NO_fmaf128_BUILTIN inline_fmaf128
+#else
+# define NO_fmaf128_BUILTIN fmaf128
+#endif
+
#endif /* MATH_USE_BUILTINS_H */
diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c
index 29555927ed..799ccbd08e 100644
--- a/sysdeps/ieee754/dbl-64/e_hypot.c
+++ b/sysdeps/ieee754/dbl-64/e_hypot.c
@@ -39,7 +39,6 @@
#include <math_private.h>
#include <math-underflow.h>
#include <math-narrow-eval.h>
-#include <math-use-builtins.h>
#include <math-svid-compat.h>
#include <libm-alias-finite.h>
#include <libm-alias-double.h>
diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c
index c01f0248c3..95956e44ad 100644
--- a/sysdeps/ieee754/dbl-64/e_sqrt.c
+++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
@@ -40,7 +40,6 @@
#include <math_private.h>
#include <fenv_private.h>
#include <libm-alias-finite.h>
-#include <math-use-builtins.h>
/*********************************************************************/
/* An ultimate sqrt routine. Given an IEEE double machine number x */
diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c
index 3738211360..c401e4c0bf 100644
--- a/sysdeps/ieee754/dbl-64/s_ceil.c
+++ b/sysdeps/ieee754/dbl-64/s_ceil.c
@@ -21,7 +21,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-double.h>
-#include <math-use-builtins.h>
double
__ceil (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_floor.c b/sysdeps/ieee754/dbl-64/s_floor.c
index 72c426ee59..78ffb51e49 100644
--- a/sysdeps/ieee754/dbl-64/s_floor.c
+++ b/sysdeps/ieee754/dbl-64/s_floor.c
@@ -34,7 +34,6 @@
#include <math_private.h>
#include <stdint.h>
#include <libm-alias-double.h>
-#include <math-use-builtins.h>
/*
* floor(x)
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index d157e8b472..c7ff3cf447 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -30,7 +30,6 @@
#include <libm-alias-double.h>
#include <math-narrow-alias.h>
#include <tininess.h>
-#include <math-use-builtins.h>
/* This implementation uses rounding to odd to avoid problems with
double rounding. See a paper by Boldo and Melquiond:
diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
index 7bf9941dd8..26ced15465 100644
--- a/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -23,7 +23,6 @@
#include <math-barriers.h>
#include <fenv_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
/* This implementation relies on double being more than twice as
precise as float and uses rounding to odd in order to avoid problems
diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c
index ec2643dcfe..0745a75666 100644
--- a/sysdeps/ieee754/dbl-64/s_llrint.c
+++ b/sysdeps/ieee754/dbl-64/s_llrint.c
@@ -25,7 +25,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long long int
diff --git a/sysdeps/ieee754/dbl-64/s_llround.c b/sysdeps/ieee754/dbl-64/s_llround.c
index e86d3dcb67..2339b92a16 100644
--- a/sysdeps/ieee754/dbl-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/s_llround.c
@@ -27,7 +27,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long long int
__llround (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index 64749bc499..cc6daf53aa 100644
--- a/sysdeps/ieee754/dbl-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/s_logb.c
@@ -17,11 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <math.h>
-
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-int-fp-convert-zero.h>
-#include <math-use-builtins.h>
double
__logb (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c
index 980959292e..e4f034283e 100644
--- a/sysdeps/ieee754/dbl-64/s_lrint.c
+++ b/sysdeps/ieee754/dbl-64/s_lrint.c
@@ -25,7 +25,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long int
diff --git a/sysdeps/ieee754/dbl-64/s_lround.c b/sysdeps/ieee754/dbl-64/s_lround.c
index e92fa5ceed..c7abd1410b 100644
--- a/sysdeps/ieee754/dbl-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/s_lround.c
@@ -23,7 +23,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
/* For LP64, lround is an alias for llround. */
#ifndef _LP64
diff --git a/sysdeps/ieee754/dbl-64/s_modf.c b/sysdeps/ieee754/dbl-64/s_modf.c
index 90cd8e8c3e..77e0226be9 100644
--- a/sysdeps/ieee754/dbl-64/s_modf.c
+++ b/sysdeps/ieee754/dbl-64/s_modf.c
@@ -19,7 +19,6 @@
#include <math.h>
#include <libm-alias-double.h>
#include "math_config.h"
-#include <math-use-builtins-trunc.h>
double
__modf (double x, double *iptr)
diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c
index 606002d680..b2a6a81517 100644
--- a/sysdeps/ieee754/dbl-64/s_nearbyint.c
+++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c
@@ -25,7 +25,6 @@
#include <math_private.h>
#include <fenv_private.h>
#include <libm-alias-double.h>
-#include <math-use-builtins.h>
double
__nearbyint (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c
index 8604733ef9..a9740af444 100644
--- a/sysdeps/ieee754/dbl-64/s_rint.c
+++ b/sysdeps/ieee754/dbl-64/s_rint.c
@@ -23,7 +23,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-double.h>
-#include <math-use-builtins.h>
double
__rint (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_round.c b/sysdeps/ieee754/dbl-64/s_round.c
index d3b8fcffc5..064773011b 100644
--- a/sysdeps/ieee754/dbl-64/s_round.c
+++ b/sysdeps/ieee754/dbl-64/s_round.c
@@ -22,8 +22,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <stdint.h>
-#include <math-use-builtins.h>
-
double
__round (double x)
diff --git a/sysdeps/ieee754/dbl-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/s_roundeven.c
index 9f6b108dbd..f35a1f63e6 100644
--- a/sysdeps/ieee754/dbl-64/s_roundeven.c
+++ b/sysdeps/ieee754/dbl-64/s_roundeven.c
@@ -21,7 +21,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
#include <stdint.h>
-#include <math-use-builtins.h>
#define BIAS 0x3ff
#define MANT_DIG 53
diff --git a/sysdeps/ieee754/dbl-64/s_trunc.c b/sysdeps/ieee754/dbl-64/s_trunc.c
index d2323d6f17..c426770cb6 100644
--- a/sysdeps/ieee754/dbl-64/s_trunc.c
+++ b/sysdeps/ieee754/dbl-64/s_trunc.c
@@ -21,8 +21,6 @@
#include <math_private.h>
#include <libm-alias-double.h>
-#include <math-use-builtins.h>
-
double
__trunc (double x)
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
index 1430bba794..d12cec9472 100644
--- a/sysdeps/ieee754/float128/float128_private.h
+++ b/sysdeps/ieee754/float128/float128_private.h
@@ -142,7 +142,6 @@
#define libm_alias_ldouble_narrow(from, to) \
libm_alias_float128_narrow (from, to)
-#include <math-use-builtins.h>
#undef USE_NEARBYINTL_BUILTIN
#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN
#undef USE_RINTL_BUILTIN
diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c
index 0263552dee..4ff9fe3230 100644
--- a/sysdeps/ieee754/flt-32/s_ceilf.c
+++ b/sysdeps/ieee754/flt-32/s_ceilf.c
@@ -16,7 +16,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
__ceilf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c
index a5c38818f1..b0447d73da 100644
--- a/sysdeps/ieee754/flt-32/s_floorf.c
+++ b/sysdeps/ieee754/flt-32/s_floorf.c
@@ -23,7 +23,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
__floorf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_llrintf.c b/sysdeps/ieee754/flt-32/s_llrintf.c
index dab8d22f67..7aba715a48 100644
--- a/sysdeps/ieee754/flt-32/s_llrintf.c
+++ b/sysdeps/ieee754/flt-32/s_llrintf.c
@@ -25,7 +25,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long long int
diff --git a/sysdeps/ieee754/flt-32/s_llroundf.c b/sysdeps/ieee754/flt-32/s_llroundf.c
index bb92acbc49..849735aa62 100644
--- a/sysdeps/ieee754/flt-32/s_llroundf.c
+++ b/sysdeps/ieee754/flt-32/s_llroundf.c
@@ -23,7 +23,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long long int
__llroundf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c
index b027e7b9c2..29316e5787 100644
--- a/sysdeps/ieee754/flt-32/s_logbf.c
+++ b/sysdeps/ieee754/flt-32/s_logbf.c
@@ -16,7 +16,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
#include <fix-int-fp-convert-zero.h>
-#include <math-use-builtins.h>
float
__logbf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c
index 079bc5d70b..a63fb7ba04 100644
--- a/sysdeps/ieee754/flt-32/s_lrintf.c
+++ b/sysdeps/ieee754/flt-32/s_lrintf.c
@@ -25,7 +25,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long int
diff --git a/sysdeps/ieee754/flt-32/s_lroundf.c b/sysdeps/ieee754/flt-32/s_lroundf.c
index f31c53136a..50decf6657 100644
--- a/sysdeps/ieee754/flt-32/s_lroundf.c
+++ b/sysdeps/ieee754/flt-32/s_lroundf.c
@@ -23,7 +23,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long int
__lroundf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_modff.c b/sysdeps/ieee754/flt-32/s_modff.c
index 965136bac9..b5dac7521d 100644
--- a/sysdeps/ieee754/flt-32/s_modff.c
+++ b/sysdeps/ieee754/flt-32/s_modff.c
@@ -19,7 +19,6 @@
#include <math.h>
#include <libm-alias-float.h>
#include "math_config.h"
-#include <math-use-builtins-trunc.h>
float
__modff (float x, float *iptr)
diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c
index 5dd0e8f8af..162bcde906 100644
--- a/sysdeps/ieee754/flt-32/s_nearbyintf.c
+++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c
@@ -19,7 +19,6 @@
#include <math_private.h>
#include <fenv_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
__nearbyintf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c
index fe5258ae61..32afd71e9a 100644
--- a/sysdeps/ieee754/flt-32/s_rintf.c
+++ b/sysdeps/ieee754/flt-32/s_rintf.c
@@ -16,7 +16,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
__rintf (float x)
diff --git a/sysdeps/ieee754/flt-32/s_roundevenf.c b/sysdeps/ieee754/flt-32/s_roundevenf.c
index 2981f365a5..882b55787d 100644
--- a/sysdeps/ieee754/flt-32/s_roundevenf.c
+++ b/sysdeps/ieee754/flt-32/s_roundevenf.c
@@ -21,7 +21,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
#include <stdint.h>
#define BIAS 0x7f
diff --git a/sysdeps/ieee754/flt-32/s_roundf.c b/sysdeps/ieee754/flt-32/s_roundf.c
index eb714e975e..746a7759f4 100644
--- a/sysdeps/ieee754/flt-32/s_roundf.c
+++ b/sysdeps/ieee754/flt-32/s_roundf.c
@@ -21,7 +21,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
diff --git a/sysdeps/ieee754/flt-32/s_truncf.c b/sysdeps/ieee754/flt-32/s_truncf.c
index 6b36e1d491..cef7c9168d 100644
--- a/sysdeps/ieee754/flt-32/s_truncf.c
+++ b/sysdeps/ieee754/flt-32/s_truncf.c
@@ -21,7 +21,6 @@
#include <math_private.h>
#include <libm-alias-float.h>
-#include <math-use-builtins.h>
float
diff --git a/sysdeps/ieee754/ldbl-128/s_ceill.c b/sysdeps/ieee754/ldbl-128/s_ceill.c
index f363d2f898..5040a27325 100644
--- a/sysdeps/ieee754/ldbl-128/s_ceill.c
+++ b/sysdeps/ieee754/ldbl-128/s_ceill.c
@@ -27,7 +27,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__ceill (_Float128 x)
diff --git a/sysdeps/ieee754/ldbl-128/s_copysignl.c b/sysdeps/ieee754/ldbl-128/s_copysignl.c
index d512d9a1e2..92b8352648 100644
--- a/sysdeps/ieee754/ldbl-128/s_copysignl.c
+++ b/sysdeps/ieee754/ldbl-128/s_copysignl.c
@@ -26,7 +26,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__copysignl (_Float128 x, _Float128 y)
diff --git a/sysdeps/ieee754/ldbl-128/s_floorl.c b/sysdeps/ieee754/ldbl-128/s_floorl.c
index 02eb663dd5..7c9d518fef 100644
--- a/sysdeps/ieee754/ldbl-128/s_floorl.c
+++ b/sysdeps/ieee754/ldbl-128/s_floorl.c
@@ -27,7 +27,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__floorl (_Float128 x)
diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c
index 17ad90ca31..ea253330b3 100644
--- a/sysdeps/ieee754/ldbl-128/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
@@ -28,7 +28,6 @@
#include <libm-alias-ldouble.h>
#include <math-narrow-alias.h>
#include <tininess.h>
-#include <math-use-builtins.h>
/* This implementation uses rounding to odd to avoid problems with
double rounding. See a paper by Boldo and Melquiond:
diff --git a/sysdeps/ieee754/ldbl-128/s_llrintl.c b/sysdeps/ieee754/ldbl-128/s_llrintl.c
index 07f5aca347..d9283eab3e 100644
--- a/sysdeps/ieee754/ldbl-128/s_llrintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_llrintl.c
@@ -24,7 +24,6 @@
#include <math_private.h>
#include <libm-alias-ldouble.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long long int
diff --git a/sysdeps/ieee754/ldbl-128/s_logbl.c b/sysdeps/ieee754/ldbl-128/s_logbl.c
index 59b08aa295..7927155cac 100644
--- a/sysdeps/ieee754/ldbl-128/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128/s_logbl.c
@@ -25,7 +25,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__logbl (_Float128 x)
diff --git a/sysdeps/ieee754/ldbl-128/s_lrintl.c b/sysdeps/ieee754/ldbl-128/s_lrintl.c
index e5c0d5adb8..027400d137 100644
--- a/sysdeps/ieee754/ldbl-128/s_lrintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_lrintl.c
@@ -24,7 +24,6 @@
#include <math_private.h>
#include <libm-alias-ldouble.h>
#include <fix-fp-int-convert-overflow.h>
-#include <math-use-builtins.h>
long int
diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
index d76d0155ad..8e2b5bd1fa 100644
--- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
@@ -27,7 +27,6 @@
#include <math-barriers.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__nearbyintl (_Float128 x)
diff --git a/sysdeps/ieee754/ldbl-128/s_rintl.c b/sysdeps/ieee754/ldbl-128/s_rintl.c
index 072ed8ec15..7badd06e85 100644
--- a/sysdeps/ieee754/ldbl-128/s_rintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_rintl.c
@@ -30,7 +30,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
__rintl (_Float128 x)
diff --git a/sysdeps/ieee754/ldbl-128/s_roundevenl.c b/sysdeps/ieee754/ldbl-128/s_roundevenl.c
index ca3a5527cd..0f935f63dd 100644
--- a/sysdeps/ieee754/ldbl-128/s_roundevenl.c
+++ b/sysdeps/ieee754/ldbl-128/s_roundevenl.c
@@ -21,7 +21,6 @@
#include <math.h>
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
#include <stdint.h>
#define BIAS 0x3fff
diff --git a/sysdeps/ieee754/ldbl-128/s_roundl.c b/sysdeps/ieee754/ldbl-128/s_roundl.c
index 9a87a463e8..c5e70f33a8 100644
--- a/sysdeps/ieee754/ldbl-128/s_roundl.c
+++ b/sysdeps/ieee754/ldbl-128/s_roundl.c
@@ -21,7 +21,6 @@
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
diff --git a/sysdeps/ieee754/ldbl-128/s_truncl.c b/sysdeps/ieee754/ldbl-128/s_truncl.c
index 2db087e85b..f4c6415521 100644
--- a/sysdeps/ieee754/ldbl-128/s_truncl.c
+++ b/sysdeps/ieee754/ldbl-128/s_truncl.c
@@ -21,7 +21,6 @@
#include <math_private.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
_Float128
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c
index 7f26315e84..fabe08f0b3 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c
@@ -24,7 +24,6 @@ static char rcsid[] = "$NetBSD: $";
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
-#include <math-use-builtins.h>
long double __fabsl(long double x)
{
diff --git a/sysdeps/ieee754/ldbl-96/s_fabsl.c b/sysdeps/ieee754/ldbl-96/s_fabsl.c
index 9891bb3a02..19bcf089b3 100644
--- a/sysdeps/ieee754/ldbl-96/s_fabsl.c
+++ b/sysdeps/ieee754/ldbl-96/s_fabsl.c
@@ -18,7 +18,6 @@
#include <math.h>
#include <libm-alias-ldouble.h>
-#include <math-use-builtins.h>
long double
__fabsl (long double x)
diff --git a/sysdeps/mips/fpu/math-use-builtins-fma.h b/sysdeps/mips/fpu/math-use-builtins-fma.h
index 06e97922aa..5a8e170aa2 100644
--- a/sysdeps/mips/fpu/math-use-builtins-fma.h
+++ b/sysdeps/mips/fpu/math-use-builtins-fma.h
@@ -19,7 +19,7 @@
ISA, double support can be subsetted. Only FMAF is enabled for this
case. */
-#include <sysdep.h>
+#include <isarev.h>
#if __mips_isa_rev >= 6
# ifdef __mips_single_float
diff --git a/sysdeps/mips/isarev.h b/sysdeps/mips/isarev.h
new file mode 100644
index 0000000000..d3da6a9cb3
--- /dev/null
+++ b/sysdeps/mips/isarev.h
@@ -0,0 +1,8 @@
+#ifndef _ISAREV_H
+#define _ISAREV_H
+
+#ifndef __mips_isa_rev
+# define __mips_isa_rev 0
+#endif
+
+#endif
diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h
index 2ab6a03a16..94393ce91a 100644
--- a/sysdeps/mips/math-use-builtins-ffs.h
+++ b/sysdeps/mips/math-use-builtins-ffs.h
@@ -1,3 +1,3 @@
-#include <sysdep.h>
+#include <isarev.h>
#define USE_FFS_BUILTIN (__mips_isa_rev >= 1)
#define USE_FFSLL_BUILTIN (__mips_isa_rev >= 1)
diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c
index 9bac5c2bbc..a65e818926 100644
--- a/sysdeps/powerpc/fpu/e_sqrt.c
+++ b/sysdeps/powerpc/fpu/e_sqrt.c
@@ -20,7 +20,6 @@
#include <math_private.h>
#include <fenv_libc.h>
#include <libm-alias-finite.h>
-#include <math-use-builtins.h>
double
__ieee754_sqrt (double x)
diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h
index 5f7706b182..4b58344bb7 100644
--- a/sysdeps/unix/mips/sysdep.h
+++ b/sysdeps/unix/mips/sysdep.h
@@ -15,12 +15,10 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <isarev.h>
#include <sgidefs.h>
#include <sysdeps/unix/sysdep.h>
-#ifndef __mips_isa_rev
-# define __mips_isa_rev 0
-#endif
#ifdef __ASSEMBLER__
diff --git a/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c b/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c
index 0982280d25..9b8b951a97 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c
@@ -1,6 +1,2 @@
-#include <math_private.h>
-
#define __modf __modf_avx
-#define trunc __trunc
-
#include <sysdeps/ieee754/dbl-64/s_modf.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c b/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c
index f6fb996f97..1f77386336 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c
@@ -1,6 +1,2 @@
-#include <math_private.h>
-
#define __modf __modf_sse41
-#define trunc __trunc
-
#include <sysdeps/ieee754/dbl-64/s_modf.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c b/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c
index b2afe1efe3..488f93700c 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c
@@ -1,6 +1,2 @@
-#include <math_private.h>
-
#define __modff __modff_avx
-#define truncf __truncf
-
#include <sysdeps/ieee754/flt-32/s_modff.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c b/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c
index 0352c3ea4b..8e49970ffc 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c
@@ -1,6 +1,2 @@
-#include <math_private.h>
-
#define __modff __modff_sse41
-#define truncf __truncf
-
#include <sysdeps/ieee754/flt-32/s_modff.c>