aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kargl <kargl@FreeBSD.org>2024-06-16 23:41:38 +0000
committerEd Maste <emaste@FreeBSD.org>2024-08-06 21:25:10 +0000
commitdc39004bc670fe33ae6759816380c93a37268dd6 (patch)
treebae5b76a05d911b1be0e414ab6d6a311971630d7
parentf06d322e9d925ab56a4aa8210a67637d4d341ab6 (diff)
libm: fma: correct zero sign with small inputs
This is a fixed version of 888796ade284. PR: 277783 Reported by: Victor Stinner Reviewed by: emaste MFC after: 1 week (cherry picked from commit 888796ade2842486d3167067e8034254c38aadd3) (cherry picked from commit e77ad954bb825983b4346b9cc646c9c910b1be24) (cherry picked from commit 34f746cc7f8a8dd261027a8b392b76e70adc8438)
-rw-r--r--lib/msun/src/s_fma.c4
-rw-r--r--lib/msun/src/s_fmal.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c
index 6c889a6a46ca..23a84491dd2a 100644
--- a/lib/msun/src/s_fma.c
+++ b/lib/msun/src/s_fma.c
@@ -260,14 +260,14 @@ fma(double x, double y, double z)
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexp(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {
diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c
index 80c835d09c2b..2fca20610157 100644
--- a/lib/msun/src/s_fmal.c
+++ b/lib/msun/src/s_fmal.c
@@ -241,14 +241,14 @@ fmal(long double x, long double y, long double z)
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexpl(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {