From owner-svn-src-all@FreeBSD.ORG Fri Oct 21 06:28:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E9B5106564A; Fri, 21 Oct 2011 06:28:48 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1E088FC19; Fri, 21 Oct 2011 06:28:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9L6Sldq009853; Fri, 21 Oct 2011 06:28:47 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9L6SlID009848; Fri, 21 Oct 2011 06:28:47 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201110210628.p9L6SlID009848@svn.freebsd.org> From: David Schultz Date: Fri, 21 Oct 2011 06:28:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226598 - head/lib/msun/src X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2011 06:28:48 -0000 Author: das Date: Fri Oct 21 06:28:47 2011 New Revision: 226598 URL: http://svn.freebsd.org/changeset/base/226598 Log: Use __ldexp_exp() to simplify things and improve accuracy for x near the overflow threshold. Modified: head/lib/msun/src/e_cosh.c head/lib/msun/src/e_coshf.c head/lib/msun/src/e_sinh.c head/lib/msun/src/e_sinhf.c Modified: head/lib/msun/src/e_cosh.c ============================================================================== --- head/lib/msun/src/e_cosh.c Fri Oct 21 06:27:56 2011 (r226597) +++ head/lib/msun/src/e_cosh.c Fri Oct 21 06:28:47 2011 (r226598) @@ -45,7 +45,6 @@ __ieee754_cosh(double x) { double t,w; int32_t ix; - u_int32_t lx; /* High word of |x|. */ GET_HIGH_WORD(ix,x); @@ -72,13 +71,8 @@ __ieee754_cosh(double x) if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x)); /* |x| in [log(maxdouble), overflowthresold] */ - GET_LOW_WORD(lx,x); - if (ix<0x408633CE || - ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) { - w = __ieee754_exp(half*fabs(x)); - t = half*w; - return t*w; - } + if (ix<=0x408633CE) + return __ldexp_exp(fabs(x), -1); /* |x| > overflowthresold, cosh(x) overflow */ return huge*huge; Modified: head/lib/msun/src/e_coshf.c ============================================================================== --- head/lib/msun/src/e_coshf.c Fri Oct 21 06:27:56 2011 (r226597) +++ head/lib/msun/src/e_coshf.c Fri Oct 21 06:28:47 2011 (r226598) @@ -51,11 +51,8 @@ __ieee754_coshf(float x) if (ix < 0x42b17217) return half*__ieee754_expf(fabsf(x)); /* |x| in [log(maxfloat), overflowthresold] */ - if (ix<=0x42b2d4fc) { - w = __ieee754_expf(half*fabsf(x)); - t = half*w; - return t*w; - } + if (ix<=0x42b2d4fc) + return __ldexp_expf(fabsf(x), -1); /* |x| > overflowthresold, cosh(x) overflow */ return huge*huge; Modified: head/lib/msun/src/e_sinh.c ============================================================================== --- head/lib/msun/src/e_sinh.c Fri Oct 21 06:27:56 2011 (r226597) +++ head/lib/msun/src/e_sinh.c Fri Oct 21 06:28:47 2011 (r226598) @@ -40,9 +40,8 @@ static const double one = 1.0, shuge = 1 double __ieee754_sinh(double x) { - double t,w,h; + double t,h; int32_t ix,jx; - u_int32_t lx; /* High word of |x|. */ GET_HIGH_WORD(jx,x); @@ -66,12 +65,8 @@ __ieee754_sinh(double x) if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x)); /* |x| in [log(maxdouble), overflowthresold] */ - GET_LOW_WORD(lx,x); - if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) { - w = __ieee754_exp(0.5*fabs(x)); - t = h*w; - return t*w; - } + if (ix<=0x408633CE) + return h*2.0*__ldexp_exp(fabs(x), -1); /* |x| > overflowthresold, sinh(x) overflow */ return x*shuge; Modified: head/lib/msun/src/e_sinhf.c ============================================================================== --- head/lib/msun/src/e_sinhf.c Fri Oct 21 06:27:56 2011 (r226597) +++ head/lib/msun/src/e_sinhf.c Fri Oct 21 06:28:47 2011 (r226598) @@ -24,7 +24,7 @@ static const float one = 1.0, shuge = 1. float __ieee754_sinhf(float x) { - float t,w,h; + float t,h; int32_t ix,jx; GET_FLOAT_WORD(jx,x); @@ -48,11 +48,8 @@ __ieee754_sinhf(float x) if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x)); /* |x| in [logf(maxfloat), overflowthresold] */ - if (ix<=0x42b2d4fc) { - w = __ieee754_expf((float)0.5*fabsf(x)); - t = h*w; - return t*w; - } + if (ix<=0x42b2d4fc) + return h*2.0F*__ldexp_expf(fabsf(x), -1); /* |x| > overflowthresold, sinh(x) overflow */ return x*shuge;