diff options
Diffstat (limited to 'sysdeps/ieee754')
24 files changed, 54 insertions, 138 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_gamma_r.c b/sysdeps/ieee754/dbl-64/e_gamma_r.c index d1acaa6a12..d3fb8af97e 100644 --- a/sysdeps/ieee754/dbl-64/e_gamma_r.c +++ b/sysdeps/ieee754/dbl-64/e_gamma_r.c @@ -76,11 +76,7 @@ gamma_positive (double x, int *exp2_adj) /* Adjust into the range for applying Stirling's approximation. */ double n = __ceil (12.0 - x); -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double x_tmp = x + n; - x_adj = x_tmp; + x_adj = math_narrow_eval (x + n); x_eps = (x - (x_adj - n)); prod = __gamma_product (x_adj - n, x_eps, n, &eps); } @@ -119,9 +115,6 @@ __ieee754_gamma_r (double x, int *signgamp) { int32_t hx; u_int32_t lx; -#if FLT_EVAL_METHOD != 0 - volatile -#endif double ret; EXTRACT_WORDS (hx, lx, x); @@ -157,7 +150,7 @@ __ieee754_gamma_r (double x, int *signgamp) { /* Overflow. */ *signgamp = 0; - ret = DBL_MAX * DBL_MAX; + ret = math_narrow_eval (DBL_MAX * DBL_MAX); return ret; } else @@ -201,27 +194,28 @@ __ieee754_gamma_r (double x, int *signgamp) } } } + ret = math_narrow_eval (ret); } if (isinf (ret) && x != 0) { if (*signgamp < 0) { - ret = -__copysign (DBL_MAX, ret) * DBL_MAX; + ret = math_narrow_eval (-__copysign (DBL_MAX, ret) * DBL_MAX); ret = -ret; } else - ret = __copysign (DBL_MAX, ret) * DBL_MAX; + ret = math_narrow_eval (__copysign (DBL_MAX, ret) * DBL_MAX); return ret; } else if (ret == 0) { if (*signgamp < 0) { - ret = -__copysign (DBL_MIN, ret) * DBL_MIN; + ret = math_narrow_eval (-__copysign (DBL_MIN, ret) * DBL_MIN); ret = -ret; } else - ret = __copysign (DBL_MIN, ret) * DBL_MIN; + ret = math_narrow_eval (__copysign (DBL_MIN, ret) * DBL_MIN); return ret; } else diff --git a/sysdeps/ieee754/dbl-64/gamma_productf.c b/sysdeps/ieee754/dbl-64/gamma_productf.c index df59e1beec..2d3c73442b 100644 --- a/sysdeps/ieee754/dbl-64/gamma_productf.c +++ b/sysdeps/ieee754/dbl-64/gamma_productf.c @@ -36,10 +36,7 @@ __gamma_productf (float x, float x_eps, int n, float *eps) for (int i = 1; i < n; i++) ret *= x_full + i; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - float fret = ret; + float fret = math_narrow_eval ((float) ret); *eps = (ret - fret) / fret; return fret; diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c index 047c6c2886..e58c9e854c 100644 --- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c +++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c @@ -315,34 +315,25 @@ recompute: break; case 1: case 2:; -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif double fv = 0.0; for (i = jz; i >= 0; i--) - fv += fq[i]; + fv = math_narrow_eval (fv + fq[i]); y[0] = (ih == 0) ? fv : -fv; - fv = fq[0] - fv; + fv = math_narrow_eval (fq[0] - fv); for (i = 1; i <= jz; i++) - fv += fq[i]; + fv = math_narrow_eval (fv + fq[i]); y[1] = (ih == 0) ? fv : -fv; break; case 3: /* painful */ for (i = jz; i > 0; i--) { -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif - double fv = (double) (fq[i - 1] + fq[i]); + double fv = math_narrow_eval (fq[i - 1] + fq[i]); fq[i] += fq[i - 1] - fv; fq[i - 1] = fv; } for (i = jz; i > 1; i--) { -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif - double fv = (double) (fq[i - 1] + fq[i]); + double fv = math_narrow_eval (fq[i - 1] + fq[i]); fq[i] += fq[i - 1] - fv; fq[i - 1] = fv; } diff --git a/sysdeps/ieee754/dbl-64/lgamma_neg.c b/sysdeps/ieee754/dbl-64/lgamma_neg.c index 8f54a0f98e..9544600015 100644 --- a/sysdeps/ieee754/dbl-64/lgamma_neg.c +++ b/sysdeps/ieee754/dbl-64/lgamma_neg.c @@ -330,17 +330,9 @@ __lgamma_neg (double x, int *signgamp) } double log_gamma_ratio; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double y0_tmp = 1 - x0_hi; - double y0 = y0_tmp; + double y0 = math_narrow_eval (1 - x0_hi); double y0_eps = -x0_hi + (1 - y0) - x0_lo; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double y_tmp = 1 - x; - double y = y_tmp; + double y = math_narrow_eval (1 - x); double y_eps = -x + (1 - y); /* We now wish to compute LOG_GAMMA_RATIO = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF @@ -353,19 +345,11 @@ __lgamma_neg (double x, int *signgamp) { int n_up = (7 - i) / 2; double ny0, ny0_eps, ny, ny_eps; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double y0_tmp = y0 + n_up; - ny0 = y0_tmp; + ny0 = math_narrow_eval (y0 + n_up); ny0_eps = y0 - (ny0 - n_up) + y0_eps; y0 = ny0; y0_eps = ny0_eps; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double y_tmp = y + n_up; - ny = y_tmp; + ny = math_narrow_eval (y + n_up); ny_eps = y - (ny - n_up) + y_eps; y = ny; y_eps = ny_eps; diff --git a/sysdeps/ieee754/dbl-64/s_erf.c b/sysdeps/ieee754/dbl-64/s_erf.c index ea0a73424e..77cd50d935 100644 --- a/sysdeps/ieee754/dbl-64/s_erf.c +++ b/sysdeps/ieee754/dbl-64/s_erf.c @@ -402,10 +402,7 @@ __erfc (double x) __ieee754_exp ((z - x) * (z + x) + R / S); if (hx > 0) { -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double ret = r / x; + double ret = math_narrow_eval (r / x); if (ret == 0) __set_errno (ERANGE); return ret; diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c index 62acb67c38..048331e9a7 100644 --- a/sysdeps/ieee754/dbl-64/s_llrint.c +++ b/sysdeps/ieee754/dbl-64/s_llrint.c @@ -35,7 +35,7 @@ __llrint (double x) int32_t j0; u_int32_t i1, i0; long long int result; - volatile double w; + double w; double t; int sx; @@ -47,7 +47,7 @@ __llrint (double x) if (j0 < 20) { - w = two52[sx] + x; + w = math_narrow_eval (two52[sx] + x); t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; @@ -62,7 +62,7 @@ __llrint (double x) result = (((long long int) i0 << 32) | i1) << (j0 - 52); else { - w = two52[sx] + x; + w = math_narrow_eval (two52[sx] + x); t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c index 9cce37f3cf..353d5f503b 100644 --- a/sysdeps/ieee754/dbl-64/s_lrint.c +++ b/sysdeps/ieee754/dbl-64/s_lrint.c @@ -34,7 +34,7 @@ __lrint (double x) { int32_t j0; u_int32_t i0, i1; - volatile double w; + double w; double t; long int result; int sx; @@ -47,7 +47,7 @@ __lrint (double x) if (j0 < 20) { - w = two52[sx] + x; + w = math_narrow_eval (two52[sx] + x); t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; @@ -62,7 +62,7 @@ __lrint (double x) result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52)); else { - w = two52[sx] + x; + w = math_narrow_eval (two52[sx] + x); t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c index 250e412aa7..183db1e033 100644 --- a/sysdeps/ieee754/flt-32/e_gammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c @@ -69,11 +69,7 @@ gammaf_positive (float x, int *exp2_adj) /* Adjust into the range for applying Stirling's approximation. */ float n = __ceilf (4.0f - x); -#if FLT_EVAL_METHOD != 0 - volatile -#endif - float x_tmp = x + n; - x_adj = x_tmp; + x_adj = math_narrow_eval (x + n); x_eps = (x - (x_adj - n)); prod = __gamma_productf (x_adj - n, x_eps, n, &eps); } @@ -111,9 +107,6 @@ float __ieee754_gammaf_r (float x, int *signgamp) { int32_t hx; -#if FLT_EVAL_METHOD != 0 - volatile -#endif float ret; GET_FLOAT_WORD (hx, x); @@ -149,7 +142,7 @@ __ieee754_gammaf_r (float x, int *signgamp) { /* Overflow. */ *signgamp = 0; - ret = FLT_MAX * FLT_MAX; + ret = math_narrow_eval (FLT_MAX * FLT_MAX); return ret; } else @@ -193,27 +186,28 @@ __ieee754_gammaf_r (float x, int *signgamp) } } } + ret = math_narrow_eval (ret); } if (isinf (ret) && x != 0) { if (*signgamp < 0) { - ret = -__copysignf (FLT_MAX, ret) * FLT_MAX; + ret = math_narrow_eval (-__copysignf (FLT_MAX, ret) * FLT_MAX); ret = -ret; } else - ret = __copysignf (FLT_MAX, ret) * FLT_MAX; + ret = math_narrow_eval (__copysignf (FLT_MAX, ret) * FLT_MAX); return ret; } else if (ret == 0) { if (*signgamp < 0) { - ret = -__copysignf (FLT_MIN, ret) * FLT_MIN; + ret = math_narrow_eval (-__copysignf (FLT_MIN, ret) * FLT_MIN); ret = -ret; } else - ret = __copysignf (FLT_MIN, ret) * FLT_MIN; + ret = math_narrow_eval (__copysignf (FLT_MIN, ret) * FLT_MIN); return ret; } else diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c index 6f14d5bac7..0c7685c3ab 100644 --- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c +++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c @@ -167,30 +167,21 @@ recompute: break; case 1: case 2:; -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif float fv = 0.0; - for (i=jz;i>=0;i--) fv += fq[i]; + for (i=jz;i>=0;i--) fv = math_narrow_eval (fv + fq[i]); y[0] = (ih==0)? fv: -fv; - fv = fq[0]-fv; - for (i=1;i<=jz;i++) fv += fq[i]; + fv = math_narrow_eval (fq[0]-fv); + for (i=1;i<=jz;i++) fv = math_narrow_eval (fv + fq[i]); y[1] = (ih==0)? fv: -fv; break; case 3: /* painful */ for (i=jz;i>0;i--) { -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif - float fv = fq[i-1]+fq[i]; + float fv = math_narrow_eval (fq[i-1]+fq[i]); fq[i] += fq[i-1]-fv; fq[i-1] = fv; } for (i=jz;i>1;i--) { -#if __FLT_EVAL_METHOD__ != 0 - volatile -#endif - float fv = fq[i-1]+fq[i]; + float fv = math_narrow_eval (fq[i-1]+fq[i]); fq[i] += fq[i-1]-fv; fq[i-1] = fv; } diff --git a/sysdeps/ieee754/flt-32/lgamma_negf.c b/sysdeps/ieee754/flt-32/lgamma_negf.c index ed9659801e..68bee8572a 100644 --- a/sysdeps/ieee754/flt-32/lgamma_negf.c +++ b/sysdeps/ieee754/flt-32/lgamma_negf.c @@ -245,17 +245,9 @@ __lgamma_negf (float x, int *signgamp) } float log_gamma_ratio; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - float y0_tmp = 1 - x0_hi; - float y0 = y0_tmp; + float y0 = math_narrow_eval (1 - x0_hi); float y0_eps = -x0_hi + (1 - y0) - x0_lo; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - float y_tmp = 1 - x; - float y = y_tmp; + float y = math_narrow_eval (1 - x); float y_eps = -x + (1 - y); /* We now wish to compute LOG_GAMMA_RATIO = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF diff --git a/sysdeps/ieee754/flt-32/s_erff.c b/sysdeps/ieee754/flt-32/s_erff.c index 2be44cc40c..1aabce5cb8 100644 --- a/sysdeps/ieee754/flt-32/s_erff.c +++ b/sysdeps/ieee754/flt-32/s_erff.c @@ -213,10 +213,7 @@ float __erfcf(float x) r = __ieee754_expf(-z*z-(float)0.5625)* __ieee754_expf((z-x)*(z+x)+R/S); if(hx>0) { -#if FLT_EVAL_METHOD != 0 - volatile -#endif - float ret = r/x; + float ret = math_narrow_eval (r/x); if (ret == 0) __set_errno (ERANGE); return ret; diff --git a/sysdeps/ieee754/flt-32/s_llrintf.c b/sysdeps/ieee754/flt-32/s_llrintf.c index ac8c1a2216..d7588d04cf 100644 --- a/sysdeps/ieee754/flt-32/s_llrintf.c +++ b/sysdeps/ieee754/flt-32/s_llrintf.c @@ -34,7 +34,7 @@ __llrintf (float x) { int32_t j0; u_int32_t i0; - volatile float w; + float w; float t; long long int result; int sx; @@ -52,7 +52,7 @@ __llrintf (float x) result = (long long int) i0 << (j0 - 23); else { - w = two23[sx] + x; + w = math_narrow_eval (two23[sx] + x); t = w - two23[sx]; GET_FLOAT_WORD (i0, t); j0 = ((i0 >> 23) & 0xff) - 0x7f; diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c index 7581a8d286..bc60fd2311 100644 --- a/sysdeps/ieee754/flt-32/s_lrintf.c +++ b/sysdeps/ieee754/flt-32/s_lrintf.c @@ -34,7 +34,7 @@ __lrintf (float x) { int32_t j0; u_int32_t i0; - volatile float w; + float w; float t; long int result; int sx; @@ -52,7 +52,7 @@ __lrintf (float x) result = (long int) i0 << (j0 - 23); else { - w = two23[sx] + x; + w = math_narrow_eval (two23[sx] + x); t = w - two23[sx]; GET_FLOAT_WORD (i0, t); j0 = ((i0 >> 23) & 0xff) - 0x7f; diff --git a/sysdeps/ieee754/ldbl-128/s_llrintl.c b/sysdeps/ieee754/ldbl-128/s_llrintl.c index 27196c95a4..77eb2d67e9 100644 --- a/sysdeps/ieee754/ldbl-128/s_llrintl.c +++ b/sysdeps/ieee754/ldbl-128/s_llrintl.c @@ -34,7 +34,7 @@ __llrintl (long double x) { int32_t j0; u_int64_t i0,i1; - volatile long double w; + long double w; long double t; long long int result; int sx; diff --git a/sysdeps/ieee754/ldbl-128/s_lrintl.c b/sysdeps/ieee754/ldbl-128/s_lrintl.c index dc678d585d..b0e0cfc16b 100644 --- a/sysdeps/ieee754/ldbl-128/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-128/s_lrintl.c @@ -34,7 +34,7 @@ __lrintl (long double x) { int32_t j0; u_int64_t i0,i1; - volatile long double w; + long double w; long double t; long int result; int sx; diff --git a/sysdeps/ieee754/ldbl-128/s_nexttoward.c b/sysdeps/ieee754/ldbl-128/s_nexttoward.c index 2cd2e58391..e62ca3fef8 100644 --- a/sysdeps/ieee754/ldbl-128/s_nexttoward.c +++ b/sysdeps/ieee754/ldbl-128/s_nexttoward.c @@ -73,10 +73,7 @@ double __nexttoward(double x, long double y) } hy = hx&0x7ff00000; if(hy>=0x7ff00000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1) - /* Force conversion to double. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00100000) { diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c index b40cf167f3..85140c1d02 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c @@ -74,10 +74,7 @@ double __nexttoward(double x, long double y) } hy = hx&0x7ff00000; if(hy>=0x7ff00000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1) - /* Force conversion to double. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00100000) { diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c index 19522f4762..b27f0bb380 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c @@ -63,10 +63,7 @@ float __nexttowardf(float x, long double y) } hy = hx&0x7f800000; if(hy>=0x7f800000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0) - /* Force conversion to float. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00800000) { /* underflow */ diff --git a/sysdeps/ieee754/ldbl-96/gamma_product.c b/sysdeps/ieee754/ldbl-96/gamma_product.c index e113e23723..ff95b73385 100644 --- a/sysdeps/ieee754/ldbl-96/gamma_product.c +++ b/sysdeps/ieee754/ldbl-96/gamma_product.c @@ -36,10 +36,7 @@ __gamma_product (double x, double x_eps, int n, double *eps) for (int i = 1; i < n; i++) ret *= x_full + i; -#if FLT_EVAL_METHOD != 0 - volatile -#endif - double fret = ret; + double fret = math_narrow_eval ((double) ret); *eps = (ret - fret) / fret; return fret; diff --git a/sysdeps/ieee754/ldbl-96/s_llrintl.c b/sysdeps/ieee754/ldbl-96/s_llrintl.c index 070246cb6a..c73741e53e 100644 --- a/sysdeps/ieee754/ldbl-96/s_llrintl.c +++ b/sysdeps/ieee754/ldbl-96/s_llrintl.c @@ -35,7 +35,7 @@ __llrintl (long double x) int32_t se,j0; u_int32_t i0, i1; long long int result; - volatile long double w; + long double w; long double t; int sx; diff --git a/sysdeps/ieee754/ldbl-96/s_lrintl.c b/sysdeps/ieee754/ldbl-96/s_lrintl.c index 96c6a5ea7d..598423b90b 100644 --- a/sysdeps/ieee754/ldbl-96/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-96/s_lrintl.c @@ -35,7 +35,7 @@ __lrintl (long double x) int32_t se,j0; u_int32_t i0, i1; long int result; - volatile long double w; + long double w; long double t; int sx; diff --git a/sysdeps/ieee754/ldbl-96/s_nexttoward.c b/sysdeps/ieee754/ldbl-96/s_nexttoward.c index f7a8b2165a..b972a3eb3a 100644 --- a/sysdeps/ieee754/ldbl-96/s_nexttoward.c +++ b/sysdeps/ieee754/ldbl-96/s_nexttoward.c @@ -70,10 +70,7 @@ double __nexttoward(double x, long double y) } hy = hx&0x7ff00000; if(hy>=0x7ff00000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1) - /* Force conversion to double. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00100000) { diff --git a/sysdeps/ieee754/ldbl-96/s_nexttowardf.c b/sysdeps/ieee754/ldbl-96/s_nexttowardf.c index a96f9da2c2..f1fe4e7ca7 100644 --- a/sysdeps/ieee754/ldbl-96/s_nexttowardf.c +++ b/sysdeps/ieee754/ldbl-96/s_nexttowardf.c @@ -58,10 +58,7 @@ float __nexttowardf(float x, long double y) } hy = hx&0x7f800000; if(hy>=0x7f800000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0) - /* Force conversion to float. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00800000) { diff --git a/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c b/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c index 7eca121701..782e1a3340 100644 --- a/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c +++ b/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c @@ -62,10 +62,7 @@ float __nldbl_nexttowardf(float x, double y) } hy = hx&0x7f800000; if(hy>=0x7f800000) { - x = x+x; /* overflow */ - if (FLT_EVAL_METHOD != 0) - /* Force conversion to float. */ - asm ("" : "+m"(x)); + x = math_narrow_eval (x+x); /* overflow */ return x; } if(hy<0x00800000) { |