]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use math_narrow_eval more consistently.
authorJoseph Myers <joseph@codesourcery.com>
Wed, 23 Sep 2015 18:14:57 +0000 (18:14 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 23 Sep 2015 18:14:57 +0000 (18:14 +0000)
Where glibc code needs to avoid excess range and precision in
floating-point arithmetic, code variously uses either asms or volatile
to force the results of that arithmetic to memory; mostly this is
conditional on FLT_EVAL_METHOD, but in the case of lrint / llrint
functions some use of volatile is unconditional (and is present
unnecessarily in versions for long double).  This patch make such code
use the recently-added math_narrow_eval macro consistently, removing
the unnecessary uses of volatile in long double lrint / llrint
implementations completely.

Tested for x86_64, x86, mips64 and powerpc.

* math/s_nexttowardf.c (__nexttowardf): Use math_narrow_eval.
* stdlib/strtod_l.c: Include <math_private.h>.
(overflow_value): Use math_narrow_eval.
(underflow_value): Likewise.
* sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
* sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Likewise.
(__ieee754_gamma_r): Likewise.
* sysdeps/ieee754/dbl-64/gamma_productf.c (__gamma_productf):
Likewise.
* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
Likewise.
* sysdeps/ieee754/dbl-64/lgamma_neg.c (__lgamma_neg): Likewise.
* sysdeps/ieee754/dbl-64/s_erf.c (__erfc): Likewise.
* sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.
* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
(__ieee754_gammaf_r): Likewise.
* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
Likewise.
* sysdeps/ieee754/flt-32/lgamma_negf.c (__lgamma_negf): Likewise.
* sysdeps/ieee754/flt-32/s_erff.c (__erfcf): Likewise.
* sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise.
* sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise.
* sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Do not use
volatile.
* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise.
* sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward): Use
math_narrow_eval.
* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
Likewise.
* sysdeps/ieee754/ldbl-96/gamma_product.c (__gamma_product):
Likewise.
* sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Do not use
volatile.
* sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
* sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Use
math_narrow_eval.
* sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
Likewise.
* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
Likewise.

29 files changed:
ChangeLog
math/s_nexttowardf.c
stdlib/strtod_l.c
sysdeps/i386/fpu/s_nexttoward.c
sysdeps/i386/fpu/s_nexttowardf.c
sysdeps/ieee754/dbl-64/e_gamma_r.c
sysdeps/ieee754/dbl-64/gamma_productf.c
sysdeps/ieee754/dbl-64/k_rem_pio2.c
sysdeps/ieee754/dbl-64/lgamma_neg.c
sysdeps/ieee754/dbl-64/s_erf.c
sysdeps/ieee754/dbl-64/s_llrint.c
sysdeps/ieee754/dbl-64/s_lrint.c
sysdeps/ieee754/flt-32/e_gammaf_r.c
sysdeps/ieee754/flt-32/k_rem_pio2f.c
sysdeps/ieee754/flt-32/lgamma_negf.c
sysdeps/ieee754/flt-32/s_erff.c
sysdeps/ieee754/flt-32/s_llrintf.c
sysdeps/ieee754/flt-32/s_lrintf.c
sysdeps/ieee754/ldbl-128/s_llrintl.c
sysdeps/ieee754/ldbl-128/s_lrintl.c
sysdeps/ieee754/ldbl-128/s_nexttoward.c
sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
sysdeps/ieee754/ldbl-96/gamma_product.c
sysdeps/ieee754/ldbl-96/s_llrintl.c
sysdeps/ieee754/ldbl-96/s_lrintl.c
sysdeps/ieee754/ldbl-96/s_nexttoward.c
sysdeps/ieee754/ldbl-96/s_nexttowardf.c
sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c

index 0ae05c8c48f2a592b50fb90e592e0e85fa30f46b..3a5f03d73898f98c198399a55108c83ba2dfc976 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2015-09-23  Joseph Myers  <joseph@codesourcery.com>
+
+       * math/s_nexttowardf.c (__nexttowardf): Use math_narrow_eval.
+       * stdlib/strtod_l.c: Include <math_private.h>.
+       (overflow_value): Use math_narrow_eval.
+       (underflow_value): Likewise.
+       * sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
+       * sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
+       * sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Likewise.
+       (__ieee754_gamma_r): Likewise.
+       * sysdeps/ieee754/dbl-64/gamma_productf.c (__gamma_productf):
+       Likewise.
+       * sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
+       Likewise.
+       * sysdeps/ieee754/dbl-64/lgamma_neg.c (__lgamma_neg): Likewise.
+       * sysdeps/ieee754/dbl-64/s_erf.c (__erfc): Likewise.
+       * sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.
+       * sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise.
+       * sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
+       (__ieee754_gammaf_r): Likewise.
+       * sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
+       Likewise.
+       * sysdeps/ieee754/flt-32/lgamma_negf.c (__lgamma_negf): Likewise.
+       * sysdeps/ieee754/flt-32/s_erff.c (__erfcf): Likewise.
+       * sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise.
+       * sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise.
+       * sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Do not use
+       volatile.
+       * sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise.
+       * sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward): Use
+       math_narrow_eval.
+       * sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
+       Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
+       Likewise.
+       * sysdeps/ieee754/ldbl-96/gamma_product.c (__gamma_product):
+       Likewise.
+       * sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Do not use
+       volatile.
+       * sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
+       * sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Use
+       math_narrow_eval.
+       * sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
+       Likewise.
+       * sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
+       Likewise.
+
 2015-09-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        * nptl/Versions: Remove ignored symbols.
index e8c4dd1d8d245e9356e2c4cb85e29967cb823576..06e1bb10cbc330b58676c7bb1bc40b3cc50d7cd9 100644 (file)
@@ -59,10 +59,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) {
index e13ab1e7e13bb4090a96f211ab8994b428546468..7950870270a8507aa67ee0675c4ec9ae69d2c3cd 100644 (file)
@@ -57,6 +57,7 @@ extern unsigned long long int ____strtoull_l_internal (const char *, char **,
 #include "../locale/localeinfo.h"
 #include <locale.h>
 #include <math.h>
+#include <math_private.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
@@ -181,10 +182,8 @@ static FLOAT
 overflow_value (int negative)
 {
   __set_errno (ERANGE);
-#if FLT_EVAL_METHOD != 0
-  volatile
-#endif
-  FLOAT result = (negative ? -MAX_VALUE : MAX_VALUE) * MAX_VALUE;
+  FLOAT result = math_narrow_eval ((negative ? -MAX_VALUE : MAX_VALUE)
+                                  * MAX_VALUE);
   return result;
 }
 
@@ -195,10 +194,8 @@ static FLOAT
 underflow_value (int negative)
 {
   __set_errno (ERANGE);
-#if FLT_EVAL_METHOD != 0
-  volatile
-#endif
-  FLOAT result = (negative ? -MIN_VALUE : MIN_VALUE) * MIN_VALUE;
+  FLOAT result = math_narrow_eval ((negative ? -MIN_VALUE : MIN_VALUE)
+                                  * MIN_VALUE);
   return result;
 }
 
index 74147c4f9e307c02e7566b30389e930e4e2ebbb0..be65b8ce2977e557a9f24700dbdf1af3beebb990 100644 (file)
@@ -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) {
index 49651bed6ffc9c8b6577a003716e6026d67a5910..8379eff8b8e472e9603cedbdc3e1663ff05c4994 100644 (file)
@@ -61,10 +61,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) {
index d1acaa6a1281809f5935204ce21011836bb258f3..d3fb8af97e9281d0066d0706cd155ca4576d6408 100644 (file)
@@ -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
index df59e1beeccd55f254c9c9653a58c8583e625654..2d3c73442bc581d86b59c650c45ce831eb5dd3ba 100644 (file)
@@ -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;
index 047c6c2886db474227c11058c371a49b6dd50f7b..e58c9e854cd0eb0a6b99ec5341ef477b6f01f2cf 100644 (file)
@@ -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;
        }
index 8f54a0f98e3d701fab41d459aae3d0cfb20653a0..9544600015affdacd091f30305b0cd81ac86a8b7 100644 (file)
@@ -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;
index ea0a73424ecf325b13595b99741859ae25e7c48f..77cd50d93544722694bd11340c343a99c3b6d7b0 100644 (file)
@@ -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;
index 62acb67c383f1fbaf7b3d832436854a8ac90c9d4..048331e9a716991cc957d044042c192556840f08 100644 (file)
@@ -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;
index 9cce37f3cff751d5b5e9a86e247c1eddd0e8b177..353d5f503b3c429110a0ba10721c40da834f4d90 100644 (file)
@@ -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;
index 250e412aa7be6e9770fceaabd77a9bdf14be39aa..183db1e033c26520e5a74d9d689af8e527356f2c 100644 (file)
@@ -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
index 6f14d5bac792a00c4bcf90d334d51d5d885abb2b..0c7685c3ab097a3f18d0cfd3e7ab22ec01d5dd39 100644 (file)
@@ -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;
                }
index ed9659801ed3c82822bc4a079ea70ba36de3f2f4..68bee8572a620384980f07bb09fe6cd7eff2c9e4 100644 (file)
@@ -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
index 2be44cc40cbdc84c8d4f09535959399741e718dd..1aabce5cb8b68013b34c1171de3b5f3562d1c72f 100644 (file)
@@ -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;
index ac8c1a22162fdd4653fce592634ef8fa32749075..d7588d04cf3561f6c9ae51073a8d59d22687b8e5 100644 (file)
@@ -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;
index 7581a8d286610a32563fa803083952abcc17e8cc..bc60fd23118150d9f1392fc83c48734bcc2391d3 100644 (file)
@@ -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;
index 27196c95a44679c6c34dca84c6709b57854e1d8d..77eb2d67e9aca59549c9b9dd8924af5a08285351 100644 (file)
@@ -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;
index dc678d585dd08a440bc0a139c3146edced5cb0b5..b0e0cfc16b7d953997915df8b48f6a326324be9c 100644 (file)
@@ -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;
index 2cd2e5839128187754852eda758b9751436c95ad..e62ca3fef8341a6babd891e6caeba62311c325dd 100644 (file)
@@ -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) {
index b40cf167f39d3996857e1a1c772427d95a8d72ba..85140c1d02824b5a2765b4117f9e84cff0393c04 100644 (file)
@@ -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) {
index 19522f4762f6a75b01fb3d6d35ff3992fc76ca81..b27f0bb380a97d131cafef45f25dc6417ccc8943 100644 (file)
@@ -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 */
index e113e237238861ea8cbd986e8c398cd7dfaa005a..ff95b733855098b45b9a35f087dc28ea53fa8ee7 100644 (file)
@@ -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;
index 070246cb6a2bb0dcf05db875b3770b57705401cf..c73741e53e005614eca9caaa07349d909a257f09 100644 (file)
@@ -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;
 
index 96c6a5ea7dfb8c32f3c7212a2734891d0b5ad759..598423b90ba344e756187770331e5ababba7fc5b 100644 (file)
@@ -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;
 
index f7a8b2165adf6c1eda2e10cbedfbfd3305751a43..b972a3eb3a7de06aedb6d95e9b5e489b88d3a1e1 100644 (file)
@@ -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) {
index a96f9da2c2d4671f637ffd6999980a16e026cfe1..f1fe4e7ca7110f6d909830a20363caedb18bfb2e 100644 (file)
@@ -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) {
index 7eca12170195bcb30ebcb17ca72a2d4313710de7..782e1a33401f85a60707b04422dbf3cf81e1a69e 100644 (file)
@@ -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) {