[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 02/15] softfloat: fix {min, max}nummag for same-a
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH v3 02/15] softfloat: fix {min, max}nummag for same-abs-value inputs |
Date: |
Wed, 4 Apr 2018 19:11:02 -0400 |
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 <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
---
fpu/softfloat.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 6e16284..6803279 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.7.4
- [Qemu-devel] [PATCH v3 00/15] fp-test + hardfloat, Emilio G. Cota, 2018/04/04
- [Qemu-devel] [PATCH v3 02/15] softfloat: fix {min, max}nummag for same-abs-value inputs,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v3 01/15] tests: add fp-test, a floating point test suite, Emilio G. Cota, 2018/04/04
- [Qemu-devel] [PATCH v3 04/15] softfloat: add float{32, 64}_is_{de, }normal, Emilio G. Cota, 2018/04/04
- [Qemu-devel] [PATCH v3 03/15] fp-test: add muladd variants, Emilio G. Cota, 2018/04/04
- [Qemu-devel] [PATCH v3 05/15] target/tricore: use float32_is_denormal, Emilio G. Cota, 2018/04/04
- [Qemu-devel] [PATCH v3 07/15] softfloat: rename canonicalize to sf_canonicalize, Emilio G. Cota, 2018/04/04