aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/flt-32/e_jnf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-10-12 11:27:51 -0400
committerUlrich Drepper <drepper@gmail.com>2011-10-12 11:27:51 -0400
commit0ac5ae2335292908f39031b1ea9fe8edce433c0f (patch)
treef9d26c8abc0de39d18d4c13e70f6022cdc6b461f /sysdeps/ieee754/flt-32/e_jnf.c
parenta843a204a3e8a0dd53584dad3668771abaec84ac (diff)
downloadglibc-0ac5ae2335292908f39031b1ea9fe8edce433c0f.tar
glibc-0ac5ae2335292908f39031b1ea9fe8edce433c0f.tar.gz
glibc-0ac5ae2335292908f39031b1ea9fe8edce433c0f.tar.bz2
glibc-0ac5ae2335292908f39031b1ea9fe8edce433c0f.zip
Optimize libm
libm is now somewhat integrated with gcc's -ffinite-math-only option and lots of the wrapper functions have been optimized.
Diffstat (limited to 'sysdeps/ieee754/flt-32/e_jnf.c')
-rw-r--r--sysdeps/ieee754/flt-32/e_jnf.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/sysdeps/ieee754/flt-32/e_jnf.c b/sysdeps/ieee754/flt-32/e_jnf.c
index dd3d551a39..1e55485b02 100644
--- a/sysdeps/ieee754/flt-32/e_jnf.c
+++ b/sysdeps/ieee754/flt-32/e_jnf.c
@@ -13,33 +13,17 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_jnf.c,v 1.5 1995/05/10 20:45:37 jtc Exp $";
-#endif
-
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const float
-#else
-static float
-#endif
two = 2.0000000000e+00, /* 0x40000000 */
one = 1.0000000000e+00; /* 0x3F800000 */
-#ifdef __STDC__
static const float zero = 0.0000000000e+00;
-#else
-static float zero = 0.0000000000e+00;
-#endif
-#ifdef __STDC__
- float __ieee754_jnf(int n, float x)
-#else
- float __ieee754_jnf(n,x)
- int n; float x;
-#endif
+float
+__ieee754_jnf(int n, float x)
{
int32_t i,hx,ix, sgn;
float a, b, temp, di;
@@ -51,7 +35,7 @@ static float zero = 0.0000000000e+00;
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
/* if J(n,NaN) is NaN */
- if(ix>0x7f800000) return x+x;
+ if(__builtin_expect(ix>0x7f800000, 0)) return x+x;
if(n<0){
n = -n;
x = -x;
@@ -61,7 +45,7 @@ static float zero = 0.0000000000e+00;
if(n==1) return(__ieee754_j1f(x));
sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */
x = fabsf(x);
- if(ix==0||ix>=0x7f800000) /* if x is 0 or inf */
+ if(__builtin_expect(ix==0||ix>=0x7f800000, 0)) /* if x is 0 or inf */
b = zero;
else if((float)n<=x) {
/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */
@@ -106,7 +90,7 @@ static float zero = 0.0000000000e+00;
* 1
* w - -----------------
* 1
- * w+h - ---------
+ * w+h - ---------
* w+2h - ...
*
* To determine how many terms needed, let
@@ -144,18 +128,18 @@ static float zero = 0.0000000000e+00;
tmp = tmp*__ieee754_logf(fabsf(v*tmp));
if(tmp<(float)8.8721679688e+01) {
for(i=n-1,di=(float)(i+i);i>0;i--){
- temp = b;
+ temp = b;
b *= di;
b = b/x - a;
- a = temp;
+ a = temp;
di -= two;
}
} else {
for(i=n-1,di=(float)(i+i);i>0;i--){
- temp = b;
+ temp = b;
b *= di;
b = b/x - a;
- a = temp;
+ a = temp;
di -= two;
/* scale b to avoid spurious overflow */
if(b>(float)1e10) {
@@ -179,13 +163,10 @@ static float zero = 0.0000000000e+00;
}
if(sgn==1) return -b; else return b;
}
+strong_alias (__ieee754_jnf, __jnf_finite)
-#ifdef __STDC__
- float __ieee754_ynf(int n, float x)
-#else
- float __ieee754_ynf(n,x)
- int n; float x;
-#endif
+float
+__ieee754_ynf(int n, float x)
{
int32_t i,hx,ix;
u_int32_t ib;
@@ -195,9 +176,10 @@ static float zero = 0.0000000000e+00;
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
/* if Y(n,NaN) is NaN */
- if(ix>0x7f800000) return x+x;
- if(ix==0) return -HUGE_VALF+x; /* -inf and overflow exception. */
- if(hx<0) return zero/(zero*x);
+ if(__builtin_expect(ix>0x7f800000, 0)) return x+x;
+ if(__builtin_expect(ix==0, 0))
+ return -HUGE_VALF+x; /* -inf and overflow exception. */
+ if(__builtin_expect(hx<0, 0)) return zero/(zero*x);
sign = 1;
if(n<0){
n = -n;
@@ -205,7 +187,7 @@ static float zero = 0.0000000000e+00;
}
if(n==0) return(__ieee754_y0f(x));
if(n==1) return(sign*__ieee754_y1f(x));
- if(ix==0x7f800000) return zero;
+ if(__builtin_expect(ix==0x7f800000, 0)) return zero;
a = __ieee754_y0f(x);
b = __ieee754_y1f(x);
@@ -219,3 +201,4 @@ static float zero = 0.0000000000e+00;
}
if(sign>0) return b; else return -b;
}
+strong_alias (__ieee754_ynf, __ynf_finite)