From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, "Emilio G. Cota" <cota@braap.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH v2 1/2] softfloat: fix {min, max}nummag for same-abs-value inputs
Date: Fri, 13 Apr 2018 15:03:33 +0100 [thread overview]
Message-ID: <20180413140334.26622-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20180413140334.26622-1-alex.bennee@linaro.org>
From: "Emilio G. Cota" <cota@braap.org>
Before 8936006 ("fpu/softfloat: re-factor minmax", 2018-02-21),
we used to return +Zero for maxnummag(-Zero,+Zero); after that
commit, we return -Zero.
Fix it by making {min,max}nummag consistent with {min,max}num,
deferring to the latter when the absolute value of the operands
is the same.
With this fix we now pass fp-test.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
fpu/softfloat.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index b46dccc63e..9b99aa6ec8 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1704,7 +1704,6 @@ static FloatParts minmax_floats(FloatParts a, FloatParts b, bool ismin,
return pick_nan(a, b, s);
} else {
int a_exp, b_exp;
- bool a_sign, b_sign;
switch (a.cls) {
case float_class_normal:
@@ -1735,20 +1734,22 @@ static FloatParts minmax_floats(FloatParts a, FloatParts b, bool ismin,
break;
}
- a_sign = a.sign;
- b_sign = b.sign;
- if (ismag) {
- a_sign = b_sign = 0;
+ if (ismag && (a_exp != b_exp || a.frac != b.frac)) {
+ bool a_less = a_exp < b_exp;
+ if (a_exp == b_exp) {
+ a_less = a.frac < b.frac;
+ }
+ return a_less ^ ismin ? b : a;
}
- if (a_sign == b_sign) {
+ if (a.sign == b.sign) {
bool a_less = a_exp < b_exp;
if (a_exp == b_exp) {
a_less = a.frac < b.frac;
}
- return a_sign ^ a_less ^ ismin ? b : a;
+ return a.sign ^ a_less ^ ismin ? b : a;
} else {
- return a_sign ^ ismin ? b : a;
+ return a.sign ^ ismin ? b : a;
}
}
}
--
2.17.0
next prev parent reply other threads:[~2018-04-13 14:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 14:03 [Qemu-devel] [PATCH v2 0/2] Softfloat Fixes for 2.12 Alex Bennée
2018-04-13 14:03 ` Alex Bennée [this message]
2018-04-13 14:03 ` [Qemu-devel] [PATCH v2 2/2] fpu/softfloat: raise float_invalid for NaN/Inf in round_to_int_and_pack Alex Bennée
2018-04-13 14:06 ` Bastian Koppelmann
2018-04-13 14:07 ` Peter Maydell
2018-04-13 15:24 ` Bastian Koppelmann
2018-04-13 15:29 ` Peter Maydell
2018-04-13 16:17 ` Bastian Koppelmann
2018-04-16 12:44 ` Bastian Koppelmann
2018-04-13 14:07 ` Peter Maydell
2018-04-16 9:11 ` [Qemu-devel] [PATCH v2 0/2] Softfloat Fixes for 2.12 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180413140334.26622-2-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=cota@braap.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).