summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2018-03-15 17:57:03 +0000
committerWilco Dijkstra <wdijkstr@arm.com>2018-03-15 19:21:35 +0000
commit1294b1892e19d70e9e4dca0a2f3e39497f262a42 (patch)
treecb9e404c7e1bb559c1a47ace05df8327695ef884 /include
parentc429a8d8d63a12cac9754834f3a2667f7dbdb0fb (diff)
Add support for sqrt asm redirects
This patch series cleans up the many uses of __ieee754_sqrt(f/l) in GLIBC. The goal is to enable GCC to do the inlining, and if this fails call the __ieee754_sqrt function. This is done by internally declaring sqrt with asm redirects. The compat symbols and sqrt wrappers need to disable the redirect. The redirect is also disabled if there are already redirects defined when using -ffinite-math-only. All math functions (but not math tests, non-library code and libnldbl) are built with -fno-math-errno which means GCC will typically inline sqrt as a single instruction. This means targets are no longer forced to add a special inline for sqrt. * include/math.h (sqrt): Declare with asm redirect. (sqrtf): Likewise. (sqrtl): Likewise. (sqrtf128): Likewise. * Makeconfig: Add -fno-math-errno for libc/libm, but build testsuite, nonlib and libnldbl with -fmath-errno. * math/w_sqrt_compat.c: Define NO_MATH_REDIRECT. * math/w_sqrt_template.c: Likewise. * math/w_sqrtf_compat.c: Likewise. * math/w_sqrtl_compat.c: Likewise. * sysdeps/i386/fpu/w_sqrt.c: Likewise. * sysdeps/i386/fpu/w_sqrt_compat.c: Likewise. * sysdeps/generic/math-type-macros-float128.h: Remove math.h and complex.h.
Diffstat (limited to 'include')
-rw-r--r--include/math.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/math.h b/include/math.h
index 7ee291fc97..e21d34b868 100644
--- a/include/math.h
+++ b/include/math.h
@@ -54,5 +54,20 @@ libm_hidden_proto (__expf128)
libm_hidden_proto (__expm1f128)
# endif
+# if !(defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
+# ifndef NO_MATH_REDIRECT
+/* Declare sqrt for use within GLIBC. Compilers typically inline sqrt as a
+ single instruction. Use an asm to avoid use of PLTs if it doesn't. */
+float (sqrtf) (float) asm ("__ieee754_sqrtf");
+double (sqrt) (double) asm ("__ieee754_sqrt");
+# ifndef __NO_LONG_DOUBLE_MATH
+long double (sqrtl) (long double) asm ("__ieee754_sqrtl");
+# endif
+# if __HAVE_DISTINCT_FLOAT128 > 0
+_Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128");
+# endif
+# endif
+# endif
+
#endif
#endif