From 1294b1892e19d70e9e4dca0a2f3e39497f262a42 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Thu, 15 Mar 2018 17:57:03 +0000 Subject: 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. --- sysdeps/generic/math-type-macros-float128.h | 3 --- sysdeps/i386/fpu/w_sqrt.c | 1 + sysdeps/i386/fpu/w_sqrt_compat.c | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h index 605996e0ba..485c13bb88 100644 --- a/sysdeps/generic/math-type-macros-float128.h +++ b/sysdeps/generic/math-type-macros-float128.h @@ -19,9 +19,6 @@ #ifndef _MATH_TYPE_MACROS_FLOAT128 #define _MATH_TYPE_MACROS_FLOAT128 -#include -#include - #define M_LIT(c) __f128 (c) #define M_PFX FLT128 #define M_SUF(c) c ## f128 diff --git a/sysdeps/i386/fpu/w_sqrt.c b/sysdeps/i386/fpu/w_sqrt.c index d37a5d55bf..8bef04e68a 100644 --- a/sysdeps/i386/fpu/w_sqrt.c +++ b/sysdeps/i386/fpu/w_sqrt.c @@ -1,5 +1,6 @@ /* The inline __ieee754_sqrt is not correctly rounding; it's OK for most internal uses in glibc, but not for sqrt itself. */ +#define NO_MATH_REDIRECT #define __ieee754_sqrt __avoid_ieee754_sqrt #include #include diff --git a/sysdeps/i386/fpu/w_sqrt_compat.c b/sysdeps/i386/fpu/w_sqrt_compat.c index ddd36d0964..dd485f4b88 100644 --- a/sysdeps/i386/fpu/w_sqrt_compat.c +++ b/sysdeps/i386/fpu/w_sqrt_compat.c @@ -1,5 +1,6 @@ /* The inline __ieee754_sqrt is not correctly rounding; it's OK for most internal uses in glibc, but not for sqrt itself. */ +#define NO_MATH_REDIRECT #define __ieee754_sqrt __avoid_ieee754_sqrt #include #include -- cgit v1.2.3