qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fpu/softfloat: check for Inf / x or 0 / x before /0
@ 2018-04-16 13:54 Alex Bennée
  2018-04-16 14:16 ` Bastian Koppelmann
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Alex Bennée @ 2018-04-16 13:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Alex Bennée, Bastian Koppelmann,
	Aurelien Jarno

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.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 fpu/softfloat.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index b46dccc63e..a7d0f3ff56 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1146,6 +1146,11 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s)
         a.cls = float_class_dnan;
         return a;
     }
+    /* Inf / x or 0 / x */
+    if (a.cls == float_class_inf || a.cls == float_class_zero) {
+        a.sign = sign;
+        return a;
+    }
     /* Div 0 => Inf */
     if (b.cls == float_class_zero) {
         s->float_exception_flags |= float_flag_divbyzero;
@@ -1153,11 +1158,6 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s)
         a.sign = sign;
         return a;
     }
-    /* Inf / x or 0 / x */
-    if (a.cls == float_class_inf || a.cls == float_class_zero) {
-        a.sign = sign;
-        return a;
-    }
     /* Div by Inf */
     if (b.cls == float_class_inf) {
         a.cls = float_class_zero;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-04-20  8:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-16 13:54 [Qemu-devel] [PATCH] fpu/softfloat: check for Inf / x or 0 / x before /0 Alex Bennée
2018-04-16 14:16 ` Bastian Koppelmann
2018-04-16 14:42   ` Alex Bennée
2018-04-16 14:45     ` Peter Maydell
2018-04-16 19:39 ` Richard Henderson
2018-04-17  8:56   ` Peter Maydell
2018-04-17  8:57 ` Peter Maydell
2018-04-17 19:04 ` Emilio G. Cota
2018-04-17 20:54   ` Peter Maydell
2018-04-17 21:27     ` Emilio G. Cota
2018-04-17 21:45       ` Peter Maydell
2018-04-17 22:38         ` Emilio G. Cota
2018-04-17 22:49           ` Richard Henderson
2018-04-17 23:01             ` Peter Maydell
2018-04-17 23:08               ` Peter Maydell
2018-04-19 19:06                 ` Richard Henderson
2018-04-19 19:12                   ` Richard Henderson
2018-04-19 19:23                     ` Peter Maydell
2018-04-20  8:20                   ` Alex Bennée

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).