From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, alex.bennee@linaro.org,
Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Subject: [Qemu-devel] [PATCH 1/2] fpu: Check for inf/x before x/0
Date: Mon, 16 Apr 2018 16:53:27 -1000 [thread overview]
Message-ID: <20180417025328.25431-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180417025328.25431-1-richard.henderson@linaro.org>
The re-factoring of div_floats changed the order of checking meaning
an operation like -inf/0 erroneously raises the divbyzero flag.
IEEE-754 (2008) specifies this should only occur for operations
on finite operands.
We fix this by moving the check on the dividend being Inf/0 to
before the divisor is zero check.
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index fb8663f59e..ba6e654050 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1146,15 +1146,20 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s)
a.cls = float_class_dnan;
return a;
}
- /* Div 0 => Inf */
+ /* Inf / x */
+ if (a.cls == float_class_inf) {
+ a.sign = sign;
+ return a;
+ }
+ /* x / 0 => Inf */
if (b.cls == float_class_zero) {
s->float_exception_flags |= float_flag_divbyzero;
a.cls = float_class_inf;
a.sign = sign;
return a;
}
- /* Inf / x or 0 / x */
- if (a.cls == float_class_inf || a.cls == float_class_zero) {
+ /* 0 / x */
+ if (a.cls == float_class_zero) {
a.sign = sign;
return a;
}
--
2.14.3
next prev parent reply other threads:[~2018-04-17 2:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 2:53 [Qemu-devel] [PATCH for-2.12 0/2] softfloat fixes Richard Henderson
2018-04-17 2:53 ` Richard Henderson [this message]
2018-04-17 9:02 ` [Qemu-devel] [PATCH 1/2] fpu: Check for inf/x before x/0 Peter Maydell
2018-04-17 2:53 ` [Qemu-devel] [PATCH 2/2] fpu: Bound increment for scalbn Richard Henderson
2018-04-17 9:53 ` Peter Maydell
2018-04-17 13:51 ` Alex Bennée
2018-04-17 13:53 ` 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=20180417025328.25431-2-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=kbastian@mail.uni-paderborn.de \
--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).