From patchwork Fri Sep 15 17:15:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 22904 Received: (qmail 33473 invoked by alias); 15 Sep 2017 17:16:02 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 33462 invoked by uid 89); 15 Sep 2017 17:16:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=pone X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH] Cleanup __ieee754_sqrt(f) Date: Fri, 15 Sep 2017 17:15:52 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB1319; 6:/HGBbvc9XAvmao3GBs+qszJnF2xNR8Tx+h0/cIlb2vXcNug9xyLk+2B2kuvg9R9BoGl83ZQjzcV3VvvoM4tjA6bjLtLLThEkul7Ln/iNbc1cgP/8FN+T9MfnxtBGBA+EK5ZJ/z7kOJybG40/lUICdXnDVEfFvTdGesmSugvWGgbJI5hQCSV89icH7szY4G6Eku7854IPWyyv8l8UOhGqZgS5Dzx/pdAMDP2vin5QqN0OWSUHqfLeKnQShCabIOxyIgKuUjbNYqlULX63iEAc2RmF/aPvYFJAriIgWNrAhp5v4zQwk8k3j8cTsOHUlsd6NzvavEZsd66iFt21zF8hDQ==; 5:x+hxCNzIJAZDTPSVFW9gd0yF1qU8qk/8zi8+LqZtSXmTsGO97JS2tcL2NUE6aBMT5M8xcAxldPQB3TqjdnHa/l6fho9rt2qZVok174BJCzt+6/fCR0QETxqcO1iff7YEJ2SDXDpIjHmfCrJfdB7EXg==; 24:bSpNhG06gKUF5MrESOJNUmpMqYz3nEoh+Z6sKMen9c8YtJ/fdhU4PRA83yLYsOiMgchu8PdNQ7m8EsNd6JIhZ7AOFiYRT0ANbaJBJz6vrWE=; 7:6BpkjPoC1tbZwcp4qkBSJOdsu9Y2ekXuubl56Yh62wkS1IFws+W5djIc+fPRUgt7PNTkLpL+sV5/sfYQFg7z0SBGeIow/5+/E5bO2LHgrwNyPEPyBHz3X0bxy/mhIUwwC+22vn7i0XZS+Sxd54VGAgGPjKK1KyYesyzYv8qUe7b38GX/INXWIj+IQJEp8mL3KaUAR1650yVFh/OtFgiwK7PrkHLKaJ6BMmsj5m+oSrE= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 439bc013-0804-4085-729d-08d4fc5d6af4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DB6PR0801MB1319; x-ms-traffictypediagnostic: DB6PR0801MB1319: nodisclaimer: True x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB1319; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB1319; x-forefront-prvs: 0431F981D8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(54534003)(199003)(189002)(4326008)(53936002)(3280700002)(3660700001)(110136004)(54356999)(53946003)(2906002)(50986999)(3846002)(9686003)(6116002)(102836003)(68736007)(106356001)(33656002)(2351001)(101416001)(105586002)(99286003)(55016002)(72206003)(5640700003)(2900100001)(189998001)(478600001)(25786009)(7736002)(2501003)(5250100002)(5660300001)(74316002)(14454004)(7696004)(305945005)(86362001)(6506006)(81166006)(66066001)(575784001)(81156014)(97736004)(316002)(8936002)(8676002)(6436002)(6916009)(11771545001)(579004)(559001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1319; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2017 17:15:52.1551 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1319 This patch cleans up the many uses of __ieee754_sqrt(f) in GLIBC. We can compile all of the math functions with -fno-math-errno which means GCC will inline sqrt as a single instruction. This means targets are no longer forced to add a special inline, and the resulting code is better without asm() constructs. I verified there is no diff in the math libs except if there are new opportunities for optimization (for example fewer callee-saves are needed in some functions and sqrt was CSEd in a few cases). I have left __ieee754_sqrtl alone for now, however this could also be removed in principle. Also given pretty much every target has a hardware sqrt instruction that GCC will inline, it would be feasible to change all the target sqrt implementations into a single generic one that does something like: #if USE_SQRT_BUILTIN return __builtin_sqrt (x) #else // generic implementation #endif ChangeLog: * Makeconfig (math-flags): Add -fno-math-errno. * math/w_sqrt_compat.c (__sqrt): Call __builtin_sqrt. * math/w_sqrtf_compat.c (__sqrtf): Call __builtin_sqrtf. * sysdeps/aarch64/fpu/e_sqrt.c (__ieee754_sqrt): Call __builtin_sqrt. * sysdeps/aarch64/fpu/e_sqrtf.c (__ieee754_sqrtf): Call __builtin_sqrtf. * sysdeps/aarch64/fpu/math_private.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. * sysdeps/alpha/fpu/math_private.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. * sysdeps/generic/math-type-macros.h (M_SQRT): Use __builtin_sqrt(f). * sysdeps/ieee754/dbl-64/e_acosh.c (__ieee754_acosh): Use sqrt. * sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Likewise. * sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Likewise. * sysdeps/ieee754/dbl-64/e_j0.c (__ieee754_j0): Likewise. * sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Likewise. * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise. * sysdeps/ieee754/dbl-64/halfulp.c (__halfulp): Likewise. * sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise. * sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c (__ieee754_acosh): Likewise. * sysdeps/ieee754/flt-32/e_acosf.c (__ieee754_acosf): Likewise. * sysdeps/ieee754/flt-32/e_acoshf.c (__ieee754_acoshf): Likewise. * sysdeps/ieee754/flt-32/e_asinf.c (__ieee754_asinf): Likewise. * sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise. * sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Likewise. * sysdeps/ieee754/flt-32/e_j0f.c (__ieee754_j0f): Likewise. * sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Likewise. * sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise. * sysdeps/powerpc/fpu/e_hypot.c (__ieee754_hypot): Likewise. * sysdeps/powerpc/fpu/e_hypotf.c (__ieee754_hypotf): Likewise. * sysdeps/powerpc/fpu/math_private.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. * sysdeps/s390/fpu/bits/mathinline.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. * sysdeps/sparc/fpu/bits/mathinline.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. * sysdeps/x86_64/fpu/math_private.h (__ieee754_sqrt): Remove. (__ieee754_sqrtf): Remove. diff --git a/Makeconfig b/Makeconfig index b51904b7973e508e49ab87a8678c8fd3f9cba9a5..1fb93ae1e3fcec7c17ea99cce6a17bc15b11eafb 100644 --- a/Makeconfig +++ b/Makeconfig @@ -812,7 +812,7 @@ endif # We have to assume that glibc functions are called in any rounding # mode and also change the rounding mode in a few functions. So, # disable any optimization that assume default rounding mode. -+math-flags = -frounding-math ++math-flags = -frounding-math -fno-math-errno # We might want to compile with some stack-protection flag. ifneq ($(stack-protector),) diff --git a/math/w_sqrt_compat.c b/math/w_sqrt_compat.c index aeead2e49c2bad906017412e2a4538c8e8f51f34..f131e6ba0381fa7a0a252b431c4e0bcaf1f8f762 100644 --- a/math/w_sqrt_compat.c +++ b/math/w_sqrt_compat.c @@ -29,7 +29,7 @@ __sqrt (double x) if (__builtin_expect (isless (x, 0.0), 0) && _LIB_VERSION != _IEEE_) return __kernel_standard (x, x, 26); /* sqrt(negative) */ - return __ieee754_sqrt (x); + return __builtin_sqrt (x); } weak_alias (__sqrt, sqrt) # ifdef NO_LONG_DOUBLE diff --git a/math/w_sqrtf_compat.c b/math/w_sqrtf_compat.c index bd3d5048fc45a6b1a1189b0f2ef9fd5bc84e2776..b88a53877716bfa44c17c6dd0caeee0eb50bda6b 100644 --- a/math/w_sqrtf_compat.c +++ b/math/w_sqrtf_compat.c @@ -29,7 +29,7 @@ __sqrtf (float x) if (__builtin_expect (isless (x, 0.0f), 0) && _LIB_VERSION != _IEEE_) return __kernel_standard_f (x, x, 126); /* sqrt(negative) */ - return __ieee754_sqrtf (x); + return __builtin_sqrtf (x); } weak_alias (__sqrtf, sqrtf) #endif diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c index f984d877b64eea72e23b8c099c41923bf60911f7..b80ac272611ebf8d4959f366ea7e5e8207ddbe22 100644 --- a/sysdeps/aarch64/fpu/e_sqrt.c +++ b/sysdeps/aarch64/fpu/e_sqrt.c @@ -21,8 +21,6 @@ double __ieee754_sqrt (double d) { - double res; - asm ("fsqrt %d0, %d1" : "=w" (res) : "w" (d)); - return res; + return __builtin_sqrt (d); } strong_alias (__ieee754_sqrt, __sqrt_finite) diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c index 67707ef83374fdb2b330d0c9b0cfb8770036a98b..73804542c812f28de96ce68a6fe64f44284856eb 100644 --- a/sysdeps/aarch64/fpu/e_sqrtf.c +++ b/sysdeps/aarch64/fpu/e_sqrtf.c @@ -21,8 +21,6 @@ float __ieee754_sqrtf (float s) { - float res; - asm ("fsqrt %s0, %s1" : "=w" (res) : "w" (s)); - return res; + return __builtin_sqrtf (s); } strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/sysdeps/aarch64/fpu/math_private.h b/sysdeps/aarch64/fpu/math_private.h index 775237ffb2040772f97fdef2a6fbe9041f27ad6e..1282418fffdc89bf15f7eb5b9051f3f9fc76f5cd 100644 --- a/sysdeps/aarch64/fpu/math_private.h +++ b/sysdeps/aarch64/fpu/math_private.h @@ -27,22 +27,6 @@ #define math_force_eval(x) \ ({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "w" (__x)); }) -extern __always_inline double -__ieee754_sqrt (double d) -{ - double res; - asm __volatile__ ("fsqrt %d0, %d1" : "=w" (res) : "w" (d)); - return res; -} - -extern __always_inline float -__ieee754_sqrtf (float s) -{ - float res; - asm __volatile__ ("fsqrt %s0, %s1" : "=w" (res) : "w" (s)); - return res; -} - static __always_inline void libc_feholdexcept_aarch64 (fenv_t *envp) { diff --git a/sysdeps/alpha/fpu/math_private.h b/sysdeps/alpha/fpu/math_private.h index 1e97c867c38767a2237df21f84e9c55a53ad13bb..95dc32c969c1133add0d5a1c42e1f1bd0c9d0e2d 100644 --- a/sysdeps/alpha/fpu/math_private.h +++ b/sysdeps/alpha/fpu/math_private.h @@ -21,30 +21,4 @@ #include_next -#ifdef __alpha_fix__ -extern __always_inline double -__ieee754_sqrt (double d) -{ - double ret; -# ifdef _IEEE_FP_INEXACT - asm ("sqrtt/suid %1,%0" : "=&f"(ret) : "f"(d)); -# else - asm ("sqrtt/sud %1,%0" : "=&f"(ret) : "f"(d)); -# endif - return ret; -} - -extern __always_inline float -__ieee754_sqrtf (float d) -{ - float ret; -# ifdef _IEEE_FP_INEXACT - asm ("sqrts/suid %1,%0" : "=&f"(ret) : "f"(d)); -# else - asm ("sqrts/sud %1,%0" : "=&f"(ret) : "f"(d)); -# endif - return ret; -} -#endif /* FIX */ - #endif /* ALPHA_MATH_PRIVATE_H */ diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h index 6aaa2335b9b165ba5ec9384e730f10382e3b969c..da86421ddd26c2c91af2814afe4d8c5d6c3b8c28 100644 --- a/sysdeps/generic/math-type-macros.h +++ b/sysdeps/generic/math-type-macros.h @@ -84,7 +84,8 @@ #define M_HYPOT M_SUF (__ieee754_hypot) #define M_LOG M_SUF (__ieee754_log) #define M_SINH M_SUF (__ieee754_sinh) -#define M_SQRT M_SUF (__ieee754_sqrt) +#define M_SQRT M_SUF (__builtin_sqrt) +#define __builtin_sqrtl __ieee754_sqrtl /* Needed to evaluate M_MANT_DIG below. */ #include diff --git a/sysdeps/ieee754/dbl-64/e_acosh.c b/sysdeps/ieee754/dbl-64/e_acosh.c index 51916f221aa3a4babecef05f93d7bc158e9f78cd..fe0c375f00428db93abd5db02be3b3be6940bda5 100644 --- a/sysdeps/ieee754/dbl-64/e_acosh.c +++ b/sysdeps/ieee754/dbl-64/e_acosh.c @@ -58,12 +58,12 @@ __ieee754_acosh (double x) else if (hx > 0x40000000) /* 2**28 > x > 2 */ { t = x * x; - return __ieee754_log (2.0 * x - one / (x + __ieee754_sqrt (t - one))); + return __ieee754_log (2.0 * x - one / (x + sqrt (t - one))); } else /* 1 0x48000000) - z = (invsqrtpi * cc) / __ieee754_sqrt (x); + z = (invsqrtpi * cc) / sqrt (x); else { u = pzero (x); v = qzero (x); - z = invsqrtpi * (u * cc - v * ss) / __ieee754_sqrt (x); + z = invsqrtpi * (u * cc - v * ss) / sqrt (x); } return z; } @@ -200,11 +200,11 @@ __ieee754_y0 (double x) ss = z / cc; } if (ix > 0x48000000) - z = (invsqrtpi * ss) / __ieee754_sqrt (x); + z = (invsqrtpi * ss) / sqrt (x); else { u = pzero (x); v = qzero (x); - z = invsqrtpi * (u * ss + v * cc) / __ieee754_sqrt (x); + z = invsqrtpi * (u * ss + v * cc) / sqrt (x); } return z; } diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c index eb446fd102d91f9ab98f9ed979569e7ede7e876e..b528998b32cde8eacb86c2c79ef5150579450f85 100644 --- a/sysdeps/ieee754/dbl-64/e_j1.c +++ b/sysdeps/ieee754/dbl-64/e_j1.c @@ -112,11 +112,11 @@ __ieee754_j1 (double x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ if (ix > 0x48000000) - z = (invsqrtpi * cc) / __ieee754_sqrt (y); + z = (invsqrtpi * cc) / sqrt (y); else { u = pone (y); v = qone (y); - z = invsqrtpi * (u * cc - v * ss) / __ieee754_sqrt (y); + z = invsqrtpi * (u * cc - v * ss) / sqrt (y); } if (hx < 0) return -z; @@ -203,11 +203,11 @@ __ieee754_y1 (double x) * to compute the worse one. */ if (ix > 0x48000000) - z = (invsqrtpi * ss) / __ieee754_sqrt (x); + z = (invsqrtpi * ss) / sqrt (x); else { u = pone (x); v = qone (x); - z = invsqrtpi * (u * ss + v * cc) / __ieee754_sqrt (x); + z = invsqrtpi * (u * ss + v * cc) / sqrt (x); } return z; } diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c index 3ac91df2b0795855c1f7f38d8812fdd6fb00c561..d829ff7c102812cd7cb78772ff947c7504bb261c 100644 --- a/sysdeps/ieee754/dbl-64/e_jn.c +++ b/sysdeps/ieee754/dbl-64/e_jn.c @@ -107,7 +107,7 @@ __ieee754_jn (int n, double x) case 2: temp = -c - s; break; case 3: temp = c - s; break; } - b = invsqrtpi * temp / __ieee754_sqrt (x); + b = invsqrtpi * temp / sqrt (x); } else { @@ -314,7 +314,7 @@ __ieee754_yn (int n, double x) case 2: temp = -s + c; break; case 3: temp = s + c; break; } - b = invsqrtpi * temp / __ieee754_sqrt (x); + b = invsqrtpi * temp / sqrt (x); } else { diff --git a/sysdeps/ieee754/dbl-64/halfulp.c b/sysdeps/ieee754/dbl-64/halfulp.c index d5f8a010e280bbaf383f80a2b50f04184f58c08f..64ba3474ae5ca42e09fbd71e156b0a03bfdd7a2e 100644 --- a/sysdeps/ieee754/dbl-64/halfulp.c +++ b/sysdeps/ieee754/dbl-64/halfulp.c @@ -113,7 +113,7 @@ __halfulp (double x, double y) /* now treat x */ while (k > 0) { - z = __ieee754_sqrt (x); + z = sqrt (x); EMULV (z, z, u, uu, j1, j2, j3, j4, j5); if (((u - x) + uu) != 0) break; diff --git a/sysdeps/ieee754/dbl-64/s_asinh.c b/sysdeps/ieee754/dbl-64/s_asinh.c index 9193301b5ebbcdd283ab814e9ff930f2a3d35f2f..593f588bee7717a14fab725a70ef311894d7cc92 100644 --- a/sysdeps/ieee754/dbl-64/s_asinh.c +++ b/sysdeps/ieee754/dbl-64/s_asinh.c @@ -54,13 +54,13 @@ __asinh (double x) double xa = fabs (x); if (ix > 0x40000000) /* 2**28 > |x| > 2.0 */ { - w = __ieee754_log (2.0 * xa + one / (__ieee754_sqrt (xa * xa + one) + + w = __ieee754_log (2.0 * xa + one / (sqrt (xa * xa + one) + xa)); } else /* 2.0 > |x| > 2**-28 */ { double t = xa * xa; - w = __log1p (xa + t / (one + __ieee754_sqrt (one + t))); + w = __log1p (xa + t / (one + sqrt (one + t))); } } return __copysign (w, x); diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c index ccccdaf106d0bf5dc90c32fa5c5f873e3893bf42..0af05a02221f8a86cc91265b1edda70b59b7bb30 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_acosh.c @@ -51,13 +51,13 @@ __ieee754_acosh (double x) /* 2**28 > x > 2 */ double t = x * x; - return __ieee754_log (2.0 * x - one / (x + __ieee754_sqrt (t - one))); + return __ieee754_log (2.0 * x - one / (x + sqrt (t - one))); } else if (__glibc_likely (hx > INT64_C (0x3ff0000000000000))) { /* 1 0.5 */ int32_t idf; z = (one-x)*(float)0.5; - s = __ieee754_sqrtf(z); + s = sqrtf(z); df = s; GET_FLOAT_WORD(idf,df); SET_FLOAT_WORD(df,idf&0xfffff000); diff --git a/sysdeps/ieee754/flt-32/e_acoshf.c b/sysdeps/ieee754/flt-32/e_acoshf.c index aabfb85df7d490ac1a8951b99246cd54e9460d27..49e64f3c43f0e5e37232dbcf8a38e7ab0c357453 100644 --- a/sysdeps/ieee754/flt-32/e_acoshf.c +++ b/sysdeps/ieee754/flt-32/e_acoshf.c @@ -40,10 +40,10 @@ float __ieee754_acoshf(float x) return 0.0; /* acosh(1) = 0 */ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ t=x*x; - return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one))); + return __ieee754_logf((float)2.0*x-one/(x+sqrtf(t-one))); } else { /* 1=0x3F79999A) { /* if |x| > 0.975 */ t = pio2_hi-(2.0f*(s+s*p)-pio2_lo); } else { diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c index 83f1a1bf03b9962e34bb0840ada92f4175052240..673d64a2a1999505e5c281b3b7e3d8ede097b056 100644 --- a/sysdeps/ieee754/flt-32/e_gammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c @@ -91,7 +91,7 @@ gammaf_positive (float x, int *exp2_adj) float ret = (__ieee754_powf (x_adj_mant, x_adj) * __ieee754_exp2f (x_adj_log2 * x_adj_frac) * __ieee754_expf (-x_adj) - * __ieee754_sqrtf (2 * (float) M_PI / x_adj) + * sqrtf (2 * (float) M_PI / x_adj) / prod); exp_adj += x_eps * __ieee754_logf (x_adj); float bsum = gamma_coeff[NCOEFF - 1]; diff --git a/sysdeps/ieee754/flt-32/e_hypotf.c b/sysdeps/ieee754/flt-32/e_hypotf.c index fda2651a846815e70631c1f9fe66be1a7561e540..5336876cf4cbb8d684dcd3510b7e8585aef7524a 100644 --- a/sysdeps/ieee754/flt-32/e_hypotf.c +++ b/sysdeps/ieee754/flt-32/e_hypotf.c @@ -40,6 +40,6 @@ __ieee754_hypotf(float x, float y) d_x = (double) x; d_y = (double) y; - return (float) __ieee754_sqrt(d_x * d_x + d_y * d_y); + return (float) sqrt(d_x * d_x + d_y * d_y); } strong_alias (__ieee754_hypotf, __hypotf_finite) diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index b783dd069dded429fa41ce8c4a93df6544797ab6..105965d06cf46ff7de0de45254537cb727595fe6 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -58,10 +58,10 @@ __ieee754_j0f(float x) * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) */ - if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(x); + if(ix>0x48000000) z = (invsqrtpi*cc)/sqrtf(x); else { u = pzerof(x); v = qzerof(x); - z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(x); + z = invsqrtpi*(u*cc-v*ss)/sqrtf(x); } return z; } @@ -131,10 +131,10 @@ __ieee754_y0f(float x) if ((s*c)0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); + if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x); else { u = pzerof(x); v = qzerof(x); - z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); + z = invsqrtpi*(u*ss+v*cc)/sqrtf(x); } return z; } diff --git a/sysdeps/ieee754/flt-32/e_j1f.c b/sysdeps/ieee754/flt-32/e_j1f.c index 805a87d85b732b9d30d3b79464e039df2b8e832b..95f03d15c5a6e558ab7f3e6f1b1869342c5c0b0e 100644 --- a/sysdeps/ieee754/flt-32/e_j1f.c +++ b/sysdeps/ieee754/flt-32/e_j1f.c @@ -61,10 +61,10 @@ __ieee754_j1f(float x) * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) */ - if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(y); + if(ix>0x48000000) z = (invsqrtpi*cc)/sqrtf(y); else { u = ponef(y); v = qonef(y); - z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(y); + z = invsqrtpi*(u*cc-v*ss)/sqrtf(y); } if(hx<0) return -z; else return z; @@ -135,10 +135,10 @@ __ieee754_y1f(float x) * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) * to compute the worse one. */ - if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); + if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x); else { u = ponef(x); v = qonef(x); - z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); + z = invsqrtpi*(u*ss+v*cc)/sqrtf(x); } return z; } diff --git a/sysdeps/ieee754/flt-32/s_asinhf.c b/sysdeps/ieee754/flt-32/s_asinhf.c index da9cafb600b3039084d987db6804b7fd5a7be046..914093a281c2e2c142c1a018d6a10c15b7e2979e 100644 --- a/sysdeps/ieee754/flt-32/s_asinhf.c +++ b/sysdeps/ieee754/flt-32/s_asinhf.c @@ -39,10 +39,10 @@ __asinhf(float x) } else { float xa = fabsf(x); if (ix>0x40000000) { /* 2**14 > |x| > 2.0 */ - w = __ieee754_logf(2.0f*xa+one/(__ieee754_sqrtf(xa*xa+one)+xa)); + w = __ieee754_logf(2.0f*xa+one/(sqrtf(xa*xa+one)+xa)); } else { /* 2.0 > |x| > 2**-14 */ float t = xa*xa; - w =__log1pf(xa+t/(one+__ieee754_sqrtf(one+t))); + w =__log1pf(xa+t/(one+sqrtf(one+t))); } } return __copysignf(w, x); diff --git a/sysdeps/powerpc/fpu/e_hypot.c b/sysdeps/powerpc/fpu/e_hypot.c index 2685ca6ba06441f1ab48aeb78183442686841a97..98319f841ecddb185506f40cddb5d980f1bdab7c 100644 --- a/sysdeps/powerpc/fpu/e_hypot.c +++ b/sysdeps/powerpc/fpu/e_hypot.c @@ -110,7 +110,7 @@ __ieee754_hypot (double x, double y) { x *= twoM600; y *= twoM600; - return __ieee754_sqrt (x * x + y * y) / twoM600; + return sqrt (x * x + y * y) / twoM600; } if (y < twoM500) { @@ -118,7 +118,7 @@ __ieee754_hypot (double x, double y) { x *= two1022; y *= two1022; - double ret = __ieee754_sqrt (x * x + y * y) / two1022; + double ret = sqrt (x * x + y * y) / two1022; math_check_force_underflow_nonneg (ret); return ret; } @@ -126,9 +126,9 @@ __ieee754_hypot (double x, double y) { x *= two600; y *= two600; - return __ieee754_sqrt (x * x + y * y) / two600; + return sqrt (x * x + y * y) / two600; } } - return __ieee754_sqrt (x * x + y * y); + return sqrt (x * x + y * y); } strong_alias (__ieee754_hypot, __hypot_finite) diff --git a/sysdeps/powerpc/fpu/e_hypotf.c b/sysdeps/powerpc/fpu/e_hypotf.c index 8502ca962a307d94dea6e693d50b1eadee11e76c..f09c42a03aab50492ab9effc53968a5fd2472d55 100644 --- a/sysdeps/powerpc/fpu/e_hypotf.c +++ b/sysdeps/powerpc/fpu/e_hypotf.c @@ -71,6 +71,6 @@ __ieee754_hypotf (float x, float y) { TEST_INF_NAN (x, y); - return __ieee754_sqrt ((double) x * x + (double) y * y); + return sqrt ((double) x * x + (double) y * y); } strong_alias (__ieee754_hypotf, __hypotf_finite) diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h index 396fd0562eda2f64bc5858a8e90b94cf5028f28b..f73b6efaa9d1c3f5dec0427965cdf25b1b61b843 100644 --- a/sysdeps/powerpc/fpu/math_private.h +++ b/sysdeps/powerpc/fpu/math_private.h @@ -35,36 +35,6 @@ __ieee754_sqrtf128 (_Float128 __x) } #endif -extern double __slow_ieee754_sqrt (double); -extern __always_inline double -__ieee754_sqrt (double __x) -{ - double __z; - -#ifdef _ARCH_PPCSQ - asm ("fsqrt %0,%1" : "=f" (__z) : "f" (__x)); -#else - __z = __slow_ieee754_sqrt(__x); -#endif - - return __z; -} - -extern float __slow_ieee754_sqrtf (float); -extern __always_inline float -__ieee754_sqrtf (float __x) -{ - float __z; - -#ifdef _ARCH_PPCSQ - asm ("fsqrts %0,%1" : "=f" (__z) : "f" (__x)); -#else - __z = __slow_ieee754_sqrtf(__x); -#endif - - return __z; -} - #if defined _ARCH_PWR5X # ifndef __round diff --git a/sysdeps/s390/fpu/bits/mathinline.h b/sysdeps/s390/fpu/bits/mathinline.h index 52e21db98d51254cee442989190923eef25b1b44..3ccfe44877473afe9eca13741db0f5b7e0a619ed 100644 --- a/sysdeps/s390/fpu/bits/mathinline.h +++ b/sysdeps/s390/fpu/bits/mathinline.h @@ -65,25 +65,6 @@ __NTH (__signbitl (long double __x)) /* This code is used internally in the GNU libc. */ #ifdef __LIBC_INTERNAL_MATH_INLINES - -__MATH_INLINE double -__NTH (__ieee754_sqrt (double x)) -{ - double res; - - __asm__ ( "sqdbr %0,%1" : "=f" (res) : "f" (x) ); - return res; -} - -__MATH_INLINE float -__NTH (__ieee754_sqrtf (float x)) -{ - float res; - - __asm__ ( "sqebr %0,%1" : "=f" (res) : "f" (x) ); - return res; -} - # if !defined __NO_LONG_DOUBLE_MATH __MATH_INLINE long double __NTH (sqrtl (long double __x)) diff --git a/sysdeps/sparc/fpu/bits/mathinline.h b/sysdeps/sparc/fpu/bits/mathinline.h index 60a2028f2ce7484883791c683be1a28586de0c13..83e0d3c882d13d2a755c3e38c8bdcfbcb1cd0c6a 100644 --- a/sysdeps/sparc/fpu/bits/mathinline.h +++ b/sysdeps/sparc/fpu/bits/mathinline.h @@ -230,22 +230,6 @@ sqrtl (long double __x) __THROW /* This code is used internally in the GNU libc. */ # ifdef __LIBC_INTERNAL_MATH_INLINES -__MATH_INLINE double -__ieee754_sqrt (double __x) -{ - register double __r; - __asm ("fsqrtd %1,%0" : "=f" (__r) : "f" (__x)); - return __r; -} - -__MATH_INLINE float -__ieee754_sqrtf (float __x) -{ - register float __r; - __asm ("fsqrts %1,%0" : "=f" (__r) : "f" (__x)); - return __r; -} - # if __WORDSIZE == 64 __MATH_INLINE long double __ieee754_sqrtl (long double __x) diff --git a/sysdeps/x86_64/fpu/math_private.h b/sysdeps/x86_64/fpu/math_private.h index 027a6a3a4d0a68948f19ebaa129bf442a9f4f3e6..aa3577046c2b242b3f406118dba9933ec7da189e 100644 --- a/sysdeps/x86_64/fpu/math_private.h +++ b/sysdeps/x86_64/fpu/math_private.h @@ -48,30 +48,6 @@ #include #include_next -extern __always_inline double -__ieee754_sqrt (double d) -{ - double res; -#if defined __AVX__ || defined SSE2AVX - asm ("vsqrtsd %1, %0, %0" : "=x" (res) : "xm" (d)); -#else - asm ("sqrtsd %1, %0" : "=x" (res) : "xm" (d)); -#endif - return res; -} - -extern __always_inline float -__ieee754_sqrtf (float d) -{ - float res; -#if defined __AVX__ || defined SSE2AVX - asm ("vsqrtss %1, %0, %0" : "=x" (res) : "xm" (d)); -#else - asm ("sqrtss %1, %0" : "=x" (res) : "xm" (d)); -#endif - return res; -} - extern __always_inline long double __ieee754_sqrtl (long double d) {