From owner-svn-src-head@FreeBSD.ORG Sun Jul 13 15:45:46 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C51F5542; Sun, 13 Jul 2014 15:45:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A65DE20BA; Sun, 13 Jul 2014 15:45:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6DFjkv2039756; Sun, 13 Jul 2014 15:45:46 GMT (envelope-from kargl@svn.freebsd.org) Received: (from kargl@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6DFjkKU039754; Sun, 13 Jul 2014 15:45:46 GMT (envelope-from kargl@svn.freebsd.org) Message-Id: <201407131545.s6DFjkKU039754@svn.freebsd.org> From: Steve Kargl Date: Sun, 13 Jul 2014 15:45:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268588 - head/lib/msun/src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jul 2014 15:45:47 -0000 Author: kargl Date: Sun Jul 13 15:45:45 2014 New Revision: 268588 URL: http://svnweb.freebsd.org/changeset/base/268588 Log: * Use the volatile qualifier for 'tiny' to prevent compilers from erronously constant folding expressions of the form '1 - tiny'. This allows erf[f](x) to raise INEXACT. * Use 0.5, 1, and 2, which are exactly representable in radix-2 floating point formats. This reduces diffs between s_erf[fl].c. * While here, add a comment about efx and efx8. Modified: head/lib/msun/src/s_erf.c head/lib/msun/src/s_erff.c Modified: head/lib/msun/src/s_erf.c ============================================================================== --- head/lib/msun/src/s_erf.c Sun Jul 13 15:15:51 2014 (r268587) +++ head/lib/msun/src/s_erf.c Sun Jul 13 15:45:45 2014 (r268588) @@ -111,13 +111,20 @@ __FBSDID("$FreeBSD$"); #include "math.h" #include "math_private.h" +/* XXX Prevent compilers from erroneously constant folding: */ +static const volatile double tiny= 1e-300; + static const double -tiny = 1e-300, -half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ +half= 0.5, +one = 1, +two = 2, /* c = (float)0.84506291151 */ erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ +/* + * In the domain [0, 2**-28], only the first term in the power series + * expansion of erf(x) is used. The magnitude of the first neglected + * terms is less than 2**-84. + */ efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */ efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ /* Modified: head/lib/msun/src/s_erff.c ============================================================================== --- head/lib/msun/src/s_erff.c Sun Jul 13 15:15:51 2014 (r268587) +++ head/lib/msun/src/s_erff.c Sun Jul 13 15:45:45 2014 (r268588) @@ -19,13 +19,18 @@ __FBSDID("$FreeBSD$"); #include "math.h" #include "math_private.h" +/* XXX Prevent compilers from erroneously constant folding: */ +static const volatile float tiny = 1e-30; + static const float -tiny = 1e-30, -half= 5.0000000000e-01, /* 0x3F000000 */ -one = 1.0000000000e+00, /* 0x3F800000 */ -two = 2.0000000000e+00, /* 0x40000000 */ +half= 0.5, +one = 1, +two = 2, +erx = 8.42697144e-01, /* 0x3f57bb00 */ /* - * Coefficients for approximation to erf on [0,0.84375] + * In the domain [0, 2**-14], only the first term in the power series + * expansion of erf(x) is used. The magnitude of the first neglected + * terms is less than 2**-42. */ efx = 1.2837916613e-01, /* 0x3e0375d4 */ efx8= 1.0270333290e+00, /* 0x3f8375d4 */ @@ -43,7 +48,6 @@ qq3 = -1.98859419e-03F, /* -0x1.04a626p * Domain [0.84375, 1.25], range ~[-1.953e-11,1.940e-11]: * |(erf(x) - erx) - p(x)/q(x)| < 2**-36. */ -erx = 8.42697144e-01F, /* 0x1.af7600p-1. erf(1) rounded to 16 bits. */ pa0 = 3.64939137e-06F, /* 0x1.e9d022p-19 */ pa1 = 4.15109694e-01F, /* 0x1.a91284p-2 */ pa2 = -1.65179938e-01F, /* -0x1.5249dcp-3 */