about summary refs log tree commit diff
path: root/sysdeps/ieee754/flt-32/e_coshf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/flt-32/e_coshf.c')
-rw-r--r--sysdeps/ieee754/flt-32/e_coshf.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/sysdeps/ieee754/flt-32/e_coshf.c b/sysdeps/ieee754/flt-32/e_coshf.c
index 223fbeea20..1887639a6b 100644
--- a/sysdeps/ieee754/flt-32/e_coshf.c
+++ b/sysdeps/ieee754/flt-32/e_coshf.c
@@ -1,5 +1,6 @@
 /* e_coshf.c -- float version of e_cosh.c.
  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ * Optimizations by Ulrich Drepper <drepper@gmail.com>, 2011
  */
 
 /*
@@ -13,26 +14,14 @@
  * ====================================================
  */
 
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_coshf.c,v 1.6 1996/04/08 15:43:41 phil Exp $";
-#endif
-
 #include "math.h"
 #include "math_private.h"
 
-#ifdef __STDC__
 static const float huge = 1.0e30;
 static const float one = 1.0, half=0.5;
-#else
-static float one = 1.0, half=0.5, huge = 1.0e30;
-#endif
 
-#ifdef __STDC__
-	float __ieee754_coshf(float x)
-#else
-	float __ieee754_coshf(x)
-	float x;
-#endif
+float
+__ieee754_coshf (float x)
 {
 	float t,w;
 	int32_t ix;
@@ -40,19 +29,17 @@ static float one = 1.0, half=0.5, huge = 1.0e30;
 	GET_FLOAT_WORD(ix,x);
 	ix &= 0x7fffffff;
 
-    /* x is INF or NaN */
-	if(ix>=0x7f800000) return x*x;
-
-    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
-	if(ix<0x3eb17218) {
-	    t = __expm1f(fabsf(x));
-	    w = one+t;
-	    if (ix<0x24000000) return w;	/* cosh(tiny) = 1 */
-	    return one+(t*t)/(w+w);
-	}
-
-    /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
+    /* |x| in [0,22] */
 	if (ix < 0x41b00000) {
+	    /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
+		if(ix<0x3eb17218) {
+		    t = __expm1f(fabsf(x));
+		    w = one+t;
+		    if (ix<0x24000000) return w;	/* cosh(tiny) = 1 */
+		    return one+(t*t)/(w+w);
+		}
+
+	    /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
 		t = __ieee754_expf(fabsf(x));
 		return half*t+half/t;
 	}
@@ -67,6 +54,10 @@ static float one = 1.0, half=0.5, huge = 1.0e30;
 	    return t*w;
 	}
 
+    /* x is INF or NaN */
+	if(ix>=0x7f800000) return x*x;
+
     /* |x| > overflowthresold, cosh(x) overflow */
 	return huge*huge;
 }
+strong_alias (__ieee754_coshf, __coshf_finite)