@@ -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),)
@@ -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
@@ -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
@@ -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)
@@ -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)
@@ -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)
{
@@ -21,30 +21,4 @@
#include_next <math_private.h>
-#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 */
@@ -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 <float.h>
@@ -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<x<2 */
{
t = x - one;
- return __log1p (t + __ieee754_sqrt (2.0 * t + t * t));
+ return __log1p (t + sqrt (2.0 * t + t * t));
}
}
strong_alias (__ieee754_acosh, __acosh_finite)
@@ -98,7 +98,7 @@ gamma_positive (double x, int *exp2_adj)
double ret = (__ieee754_pow (x_adj_mant, x_adj)
* __ieee754_exp2 (x_adj_log2 * x_adj_frac)
* __ieee754_exp (-x_adj)
- * __ieee754_sqrt (2 * M_PI / x_adj)
+ * sqrt (2 * M_PI / x_adj)
/ prod);
exp_adj += x_eps * __ieee754_log (x_adj);
double bsum = gamma_coeff[NCOEFF - 1];
@@ -132,7 +132,7 @@ __ieee754_hypot (double x, double y)
t1 = 0;
SET_HIGH_WORD (t1, ha);
t2 = a - t1;
- w = __ieee754_sqrt (t1 * t1 - (b * (-b) - t2 * (a + t1)));
+ w = sqrt (t1 * t1 - (b * (-b) - t2 * (a + t1)));
}
else
{
@@ -143,7 +143,7 @@ __ieee754_hypot (double x, double y)
t1 = 0;
SET_HIGH_WORD (t1, ha + 0x00100000);
t2 = a - t1;
- w = __ieee754_sqrt (t1 * y1 - (w * (-w) - (t1 * y2 + t2 * b)));
+ w = sqrt (t1 * y1 - (w * (-w) - (t1 * y2 + t2 * b)));
}
if (k != 0)
{
@@ -109,11 +109,11 @@ __ieee754_j0 (double x)
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
*/
if (ix > 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;
}
@@ -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;
}
@@ -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
{
@@ -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;
@@ -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);
@@ -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<x<2 */
double t = x - one;
- return __log1p (t + __ieee754_sqrt (2.0 * t + t * t));
+ return __log1p (t + sqrt (2.0 * t + t * t));
}
else if (__glibc_likely (hx == INT64_C (0x3ff0000000000000)))
return 0.0; /* acosh(1) = 0 */
@@ -56,14 +56,14 @@ __ieee754_acosf(float x)
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- s = __ieee754_sqrtf(z);
+ s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 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);
@@ -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<x<2 */
t = x-one;
- return __log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t));
+ return __log1pf(t+sqrtf((float)2.0*t+t*t));
}
}
strong_alias (__ieee754_acoshf, __acoshf_finite)
@@ -85,7 +85,7 @@ float __ieee754_asinf(float x)
w = one-fabsf(x);
t = w*0.5f;
p = t * (p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))));
- s = __ieee754_sqrtf(t);
+ s = sqrtf(t);
if(ix>=0x3F79999A) { /* if |x| > 0.975 */
t = pio2_hi-(2.0f*(s+s*p)-pio2_lo);
} else {
@@ -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];
@@ -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)
@@ -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)<zero) cc = z/ss;
else ss = z/cc;
}
- if(ix>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;
}
@@ -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;
}
@@ -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);
@@ -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)
@@ -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)
@@ -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
@@ -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))
@@ -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)
@@ -48,30 +48,6 @@
#include <sysdeps/i386/fpu/fenv_private.h>
#include_next <math_private.h>
-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)
{