diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-10-25 10:52:45 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-10-25 10:52:45 -0400 |
commit | d7826aa149d2e85128a7ecf8fadc950ab9fe7a22 (patch) | |
tree | 9aff1638197c1f9b2ed99c8d666bd1a0b42517cb /sysdeps/ieee754/flt-32 | |
parent | 31ea014d8b09e6aa4f07cdb86c94ce50f1b92c2a (diff) | |
download | glibc-d7826aa149d2e85128a7ecf8fadc950ab9fe7a22.tar.gz glibc-d7826aa149d2e85128a7ecf8fadc950ab9fe7a22.tar.xz glibc-d7826aa149d2e85128a7ecf8fadc950ab9fe7a22.zip |
Use math_force_eval in more places
Diffstat (limited to 'sysdeps/ieee754/flt-32')
-rw-r--r-- | sysdeps/ieee754/flt-32/e_atanhf.c | 7 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/e_j0f.c | 7 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_ceilf.c | 14 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_expm1f.c | 52 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_floorf.c | 16 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_log1pf.c | 42 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_roundf.c | 24 |
7 files changed, 65 insertions, 97 deletions
diff --git a/sysdeps/ieee754/flt-32/e_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c index ddd18ab300..d98a11ed67 100644 --- a/sysdeps/ieee754/flt-32/e_atanhf.c +++ b/sysdeps/ieee754/flt-32/e_atanhf.c @@ -49,8 +49,11 @@ __ieee754_atanhf (float x) float t; if (xa < 0.5f) { - if (__builtin_expect (xa < 0x1.0p-28f, 0) && (huge + x) > 0.0f) - return x; + if (__builtin_expect (xa < 0x1.0p-28f, 0)) + { + math_force_eval (huge + x); + return x; + } t = xa + xa; t = 0.5f * __log1pf (t + t * xa / (1.0f - xa)); diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index d2da43f929..181c2e46d4 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -66,10 +66,9 @@ __ieee754_j0f(float x) return z; } if(ix<0x39000000) { /* |x| < 2**-13 */ - if(huge+x>one) { /* raise inexact if x != 0 */ - if(ix<0x32000000) return one; /* |x|<2**-27 */ - else return one - (float)0.25*x*x; - } + math_force_eval(huge+x>one); /* raise inexact if x != 0 */ + if(ix<0x32000000) return one; /* |x|<2**-27 */ + else return one - (float)0.25*x*x; } z = x*x; r = z*(R02+z*(R03+z*(R04+z*R05))); diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c index 8a83201c15..af926600b0 100644 --- a/sysdeps/ieee754/flt-32/s_ceilf.c +++ b/sysdeps/ieee754/flt-32/s_ceilf.c @@ -29,17 +29,15 @@ __ceilf(float x) j0 = ((i0>>23)&0xff)-0x7f; if(j0<23) { if(j0<0) { /* raise inexact if x != 0 */ - if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ - if(i0<0) {i0=0x80000000;} - else if(i0!=0) { i0=0x3f800000;} - } + math_force_eval(huge+x);/* return 0*sign(x) if |x|<1 */ + if(i0<0) {i0=0x80000000;} + else if(i0!=0) { i0=0x3f800000;} } else { i = (0x007fffff)>>j0; if((i0&i)==0) return x; /* x is integral */ - if(huge+x>(float)0.0) { /* raise inexact flag */ - if(i0>0) i0 += (0x00800000)>>j0; - i0 &= (~i); - } + math_force_eval(huge+x); /* raise inexact flag */ + if(i0>0) i0 += (0x00800000)>>j0; + i0 &= (~i); } } else { if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */ diff --git a/sysdeps/ieee754/flt-32/s_expm1f.c b/sysdeps/ieee754/flt-32/s_expm1f.c index 3f4536b906..1d707120b0 100644 --- a/sysdeps/ieee754/flt-32/s_expm1f.c +++ b/sysdeps/ieee754/flt-32/s_expm1f.c @@ -13,22 +13,14 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_expm1f.c,v 1.5 1995/05/10 20:47:11 jtc Exp $"; -#endif - #include <errno.h> #include "math.h" #include "math_private.h" -static const volatile float huge = 1.0e+30; -static const volatile float tiny = 1.0e-30; +static const float huge = 1.0e+30; +static const float tiny = 1.0e-30; -#ifdef __STDC__ static const float -#else -static float -#endif one = 1.0, o_threshold = 8.8721679688e+01,/* 0x42b17180 */ ln2_hi = 6.9313812256e-01,/* 0x3f317180 */ @@ -41,12 +33,8 @@ Q3 = -7.9365076090e-05, /* 0xb8a670cd */ Q4 = 4.0082177293e-06, /* 0x36867e54 */ Q5 = -2.0109921195e-07; /* 0xb457edbb */ -#ifdef __STDC__ - float __expm1f(float x) -#else - float __expm1f(x) - float x; -#endif +float +__expm1f(float x) { float y,hi,lo,c,t,e,hxs,hfx,r1; int32_t k,xsb; @@ -60,17 +48,17 @@ Q5 = -2.0109921195e-07; /* 0xb457edbb */ /* filter out huge and non-finite argument */ if(hx >= 0x4195b844) { /* if |x|>=27*ln2 */ if(hx >= 0x42b17218) { /* if |x|>=88.721... */ - if(hx>0x7f800000) - return x+x; /* NaN */ + if(hx>0x7f800000) + return x+x; /* NaN */ if(hx==0x7f800000) return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ - if(x > o_threshold) { + if(x > o_threshold) { __set_errno (ERANGE); return huge*huge; /* overflow */ } } if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */ - if(x+tiny<(float)0.0) /* raise inexact */ + math_force_eval(x+tiny);/* raise inexact */ return tiny-one; /* return -1 */ } } @@ -91,7 +79,7 @@ Q5 = -2.0109921195e-07; /* 0xb457edbb */ x = hi - lo; c = (hi-x)-lo; } - else if(hx < 0x33000000) { /* when |x|<2**-25, return x */ + else if(hx < 0x33000000) { /* when |x|<2**-25, return x */ t = huge+x; /* return x with inexact flags when x!=0 */ return x - (t-(huge+x)); } @@ -109,28 +97,28 @@ Q5 = -2.0109921195e-07; /* 0xb457edbb */ e -= hxs; if(k== -1) return (float)0.5*(x-e)-(float)0.5; if(k==1) { - if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5)); - else return one+(float)2.0*(x-e); + if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5)); + else return one+(float)2.0*(x-e); } if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ - int32_t i; - y = one-(e-x); + int32_t i; + y = one-(e-x); GET_FLOAT_WORD(i,y); SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ - return y-one; + return y-one; } t = one; if(k<23) { - int32_t i; - SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */ - y = t-(e-x); + int32_t i; + SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */ + y = t-(e-x); GET_FLOAT_WORD(i,y); SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ } else { - int32_t i; + int32_t i; SET_FLOAT_WORD(t,((0x7f-k)<<23)); /* 2^-k */ - y = x-(e+t); - y += one; + y = x-(e+t); + y += one; GET_FLOAT_WORD(i,y); SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ } diff --git a/sysdeps/ieee754/flt-32/s_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c index dd19c6bc56..de160d2114 100644 --- a/sysdeps/ieee754/flt-32/s_floorf.c +++ b/sysdeps/ieee754/flt-32/s_floorf.c @@ -36,18 +36,16 @@ __floorf(float x) j0 = ((i0>>23)&0xff)-0x7f; if(j0<23) { if(j0<0) { /* raise inexact if x != 0 */ - if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ - if(i0>=0) {i0=0;} - else if((i0&0x7fffffff)!=0) - { i0=0xbf800000;} - } + math_force_eval(huge+x);/* return 0*sign(x) if |x|<1 */ + if(i0>=0) {i0=0;} + else if((i0&0x7fffffff)!=0) + { i0=0xbf800000;} } else { i = (0x007fffff)>>j0; if((i0&i)==0) return x; /* x is integral */ - if(huge+x>(float)0.0) { /* raise inexact flag */ - if(i0<0) i0 += (0x00800000)>>j0; - i0 &= (~i); - } + math_force_eval(huge+x); /* raise inexact flag */ + if(i0<0) i0 += (0x00800000)>>j0; + i0 &= (~i); } } else { if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */ diff --git a/sysdeps/ieee754/flt-32/s_log1pf.c b/sysdeps/ieee754/flt-32/s_log1pf.c index bd3d57635c..9e555ed570 100644 --- a/sysdeps/ieee754/flt-32/s_log1pf.c +++ b/sysdeps/ieee754/flt-32/s_log1pf.c @@ -13,18 +13,10 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_log1pf.c,v 1.4 1995/05/10 20:47:48 jtc Exp $"; -#endif - #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const float -#else -static float -#endif ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ two25 = 3.355443200e+07, /* 0x4c000000 */ @@ -36,18 +28,10 @@ Lp5 = 1.8183572590e-01, /* 3E3A3325 */ Lp6 = 1.5313838422e-01, /* 3E1CD04F */ Lp7 = 1.4798198640e-01; /* 3E178897 */ -#ifdef __STDC__ static const float zero = 0.0; -#else -static float zero = 0.0; -#endif -#ifdef __STDC__ - float __log1pf(float x) -#else - float __log1pf(x) - float x; -#endif +float +__log1pf(float x) { float hfsq,f,c,s,z,R,u; int32_t k,hx,hu,ax; @@ -62,8 +46,8 @@ static float zero = 0.0; else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ } if(ax<0x31000000) { /* |x| < 2**-29 */ - if(two25+x>zero /* raise inexact */ - &&ax<0x24800000) /* |x| < 2**-54 */ + math_force_eval(two25+x); /* raise inexact */ + if (ax<0x24800000) /* |x| < 2**-54 */ return x; else return x - x*x*(float)0.5; @@ -76,37 +60,37 @@ static float zero = 0.0; if(hx<0x5a000000) { u = (float)1.0+x; GET_FLOAT_WORD(hu,u); - k = (hu>>23)-127; + k = (hu>>23)-127; /* correction term */ - c = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0); + c = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0); c /= u; } else { u = x; GET_FLOAT_WORD(hu,u); - k = (hu>>23)-127; + k = (hu>>23)-127; c = 0; } hu &= 0x007fffff; if(hu<0x3504f7) { - SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */ + SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */ } else { - k += 1; + k += 1; SET_FLOAT_WORD(u,hu|0x3f000000); /* normalize u/2 */ - hu = (0x00800000-hu)>>2; + hu = (0x00800000-hu)>>2; } f = u-(float)1.0; } hfsq=(float)0.5*f*f; if(hu==0) { /* |f| < 2**-20 */ if(f==zero) { - if(k==0) return zero; + if(k==0) return zero; else {c += k*ln2_lo; return k*ln2_hi+c;} } R = hfsq*((float)1.0-(float)0.66666666666666666*f); if(k==0) return f-R; else - return k*ln2_hi-((R-(k*ln2_lo+c))-f); + return k*ln2_hi-((R-(k*ln2_lo+c))-f); } - s = f/((float)2.0+f); + s = f/((float)2.0+f); z = s*s; R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7)))))); if(k==0) return f-(hfsq-s*(hfsq+R)); else diff --git a/sysdeps/ieee754/flt-32/s_roundf.c b/sysdeps/ieee754/flt-32/s_roundf.c index 0b24987792..09b38cdc2a 100644 --- a/sysdeps/ieee754/flt-32/s_roundf.c +++ b/sysdeps/ieee754/flt-32/s_roundf.c @@ -1,5 +1,5 @@ /* Round float to integer away from zero. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -37,12 +37,11 @@ __roundf (float x) { if (j0 < 0) { - if (huge + x > 0.0F) - { - i0 &= 0x80000000; - if (j0 == -1) - i0 |= 0x3f800000; - } + math_force_eval (huge + x > 0.0F); + + i0 &= 0x80000000; + if (j0 == -1) + i0 |= 0x3f800000; } else { @@ -50,12 +49,11 @@ __roundf (float x) if ((i0 & i) == 0) /* X is integral. */ return x; - if (huge + x > 0.0F) - { - /* Raise inexact if x != 0. */ - i0 += 0x00400000 >> j0; - i0 &= ~i; - } + math_force_eval (huge + x > 0.0F); + + /* Raise inexact if x != 0. */ + i0 += 0x00400000 >> j0; + i0 &= ~i; } } else |