From owner-dev-commits-src-all@freebsd.org Mon Mar 8 09:44:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3EB1C56BEC0; Mon, 8 Mar 2021 09:44:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DvD216r2fz3tYM; Mon, 8 Mar 2021 09:44:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8676269FC; Mon, 8 Mar 2021 09:44:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1289i9ke024249; Mon, 8 Mar 2021 09:44:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1289i9R8024248; Mon, 8 Mar 2021 09:44:09 GMT (envelope-from git) Date: Mon, 8 Mar 2021 09:44:09 GMT Message-Id: <202103080944.1289i9R8024248@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 221622ec0c8e - main - lib/msun: Avoid FE_INEXACT for x86 log2l/log10l MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 221622ec0c8e184dd1ea7e1f77fb45d2d32cb6e2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 09:44:11 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=221622ec0c8e184dd1ea7e1f77fb45d2d32cb6e2 commit 221622ec0c8e184dd1ea7e1f77fb45d2d32cb6e2 Author: Alex Richardson AuthorDate: 2021-03-08 09:39:29 +0000 Commit: Alex Richardson CommitDate: 2021-03-08 09:39:32 +0000 lib/msun: Avoid FE_INEXACT for x86 log2l/log10l This fixes tests/lib/msun/logarithm_test after compiling the test with -fno-builtin (D28577). Adding invln10_lo + invln10_10 results in FE_INEXACT (for all inputs) and the same for the log2l invln2_lo + invln2_hi. This patch avoids FE_INEXACT (for exact results such as 0) by defining a constant and using that. Reviewed By: dim Differential Revision: https://reviews.freebsd.org/D28786 --- lib/msun/ld128/s_logl.c | 18 +++++++++--------- lib/msun/ld80/s_logl.c | 9 ++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/msun/ld128/s_logl.c b/lib/msun/ld128/s_logl.c index 93a2a7c35ff5..4774a271e7ad 100644 --- a/lib/msun/ld128/s_logl.c +++ b/lib/msun/ld128/s_logl.c @@ -697,14 +697,15 @@ invln10_hi = 4.3429448176175356e-1, /* 0x1bcb7b15000000.0p-54 */ invln2_hi = 1.4426950402557850e0; /* 0x17154765000000.0p-52 */ static const long double invln10_lo = 1.41498268538580090791605082294397000e-10L, /* 0x137287195355baaafad33dc323ee3.0p-145L */ -invln2_lo = 6.33178418956604368501892137426645911e-10L; /* 0x15c17f0bbbe87fed0691d3e88eb57.0p-143L */ +invln2_lo = 6.33178418956604368501892137426645911e-10L, /* 0x15c17f0bbbe87fed0691d3e88eb57.0p-143L */ +invln10_lo_plus_hi = invln10_lo + invln10_hi, +invln2_lo_plus_hi = invln2_lo + invln2_hi; long double log10l(long double x) { struct ld r; - long double lo; - float hi; + long double hi, lo; ENTERI(); DOPRINT_START(&x); @@ -712,18 +713,17 @@ log10l(long double x) if (!r.lo_set) RETURNPI(r.hi); _2sumF(r.hi, r.lo); - hi = r.hi; + hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln10_hi * hi, - (invln10_lo + invln10_hi) * lo + invln10_lo * hi); + invln10_lo_plus_hi * lo + invln10_lo * hi); } long double log2l(long double x) { struct ld r; - long double lo; - float hi; + long double hi, lo; ENTERI(); DOPRINT_START(&x); @@ -731,10 +731,10 @@ log2l(long double x) if (!r.lo_set) RETURNPI(r.hi); _2sumF(r.hi, r.lo); - hi = r.hi; + hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln2_hi * hi, - (invln2_lo + invln2_hi) * lo + invln2_lo * hi); + invln2_lo_plus_hi * lo + invln2_lo * hi); } #endif /* STRUCT_RETURN */ diff --git a/lib/msun/ld80/s_logl.c b/lib/msun/ld80/s_logl.c index 0a220f2a2403..d787b953fedb 100644 --- a/lib/msun/ld80/s_logl.c +++ b/lib/msun/ld80/s_logl.c @@ -677,8 +677,11 @@ logl(long double x) static const double invln10_hi = 4.3429448190317999e-1, /* 0x1bcb7b1526e000.0p-54 */ invln10_lo = 7.1842412889749798e-14, /* 0x1438ca9aadd558.0p-96 */ +invln10_lo_plus_hi = invln10_lo + invln10_hi, invln2_hi = 1.4426950408887933e0, /* 0x171547652b8000.0p-52 */ -invln2_lo = 1.7010652264631490e-13; /* 0x17f0bbbe87fed0.0p-95 */ +invln2_lo = 1.7010652264631490e-13, /* 0x17f0bbbe87fed0.0p-95 */ +invln2_lo_plus_hi = invln2_lo + invln2_hi; + long double log10l(long double x) @@ -695,7 +698,7 @@ log10l(long double x) hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln10_hi * hi, - (invln10_lo + invln10_hi) * lo + invln10_lo * hi); + invln10_lo_plus_hi * lo + invln10_lo * hi); } long double @@ -713,7 +716,7 @@ log2l(long double x) hi = (float)r.hi; lo = r.lo + (r.hi - hi); RETURN2PI(invln2_hi * hi, - (invln2_lo + invln2_hi) * lo + invln2_lo * hi); + invln2_lo_plus_hi * lo + invln2_lo * hi); } #endif /* STRUCT_RETURN */