git: 34f746cc7f8a - main - libm: fma: correct zero sign with small inputs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 28 Jul 2024 21:38:12 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=34f746cc7f8a8dd261027a8b392b76e70adc8438
commit 34f746cc7f8a8dd261027a8b392b76e70adc8438
Author: Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2024-06-16 23:41:38 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-07-28 21:37:45 +0000
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
---
lib/msun/src/s_fma.c | 4 ++--
lib/msun/src/s_fmal.c | 4 ++--
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) {