[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 66/72] softfloat: Use parts_pick_nan in propagateFloatx80NaN
From: |
Peter Maydell |
Subject: |
[PULL 66/72] softfloat: Use parts_pick_nan in propagateFloatx80NaN |
Date: |
Wed, 11 Dec 2024 16:19:58 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Unpacking and repacking the parts may be slightly more work
than we did before, but we get to reuse more code. For a
code path handling exceptional values, this is an improvement.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241203203949.483774-8-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
fpu/softfloat.c | 43 +++++--------------------------------------
1 file changed, 5 insertions(+), 38 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 6ba1cfd32a0..8de8d5f3425 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -4928,48 +4928,15 @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t
*zExpPtr,
floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
{
- bool aIsLargerSignificand;
- FloatClass a_cls, b_cls;
+ FloatParts128 pa, pb, *pr;
- /* This is not complete, but is good enough for pickNaN. */
- a_cls = (!floatx80_is_any_nan(a)
- ? float_class_normal
- : floatx80_is_signaling_nan(a, status)
- ? float_class_snan
- : float_class_qnan);
- b_cls = (!floatx80_is_any_nan(b)
- ? float_class_normal
- : floatx80_is_signaling_nan(b, status)
- ? float_class_snan
- : float_class_qnan);
-
- if (is_snan(a_cls) || is_snan(b_cls)) {
- float_raise(float_flag_invalid, status);
- }
-
- if (status->default_nan_mode) {
+ if (!floatx80_unpack_canonical(&pa, a, status) ||
+ !floatx80_unpack_canonical(&pb, b, status)) {
return floatx80_default_nan(status);
}
- if (a.low < b.low) {
- aIsLargerSignificand = 0;
- } else if (b.low < a.low) {
- aIsLargerSignificand = 1;
- } else {
- aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
- }
-
- if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
- if (is_snan(b_cls)) {
- return floatx80_silence_nan(b, status);
- }
- return b;
- } else {
- if (is_snan(a_cls)) {
- return floatx80_silence_nan(a, status);
- }
- return a;
- }
+ pr = parts_pick_nan(&pa, &pb, status);
+ return floatx80_round_pack_canonical(pr, status);
}
/*----------------------------------------------------------------------------
--
2.34.1
- [PULL 60/72] fpu: Remove default handling for dnan_pattern, (continued)
- [PULL 60/72] fpu: Remove default handling for dnan_pattern, Peter Maydell, 2024/12/11
- [PULL 61/72] softfloat: Inline pickNaNMulAdd, Peter Maydell, 2024/12/11
- [PULL 55/72] target/sparc: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 54/72] target/s390x: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 56/72] target/xtensa: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 58/72] target/riscv: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 63/72] softfloat: Remove which from parts_pick_nan_muladd, Peter Maydell, 2024/12/11
- [PULL 59/72] target/tricore: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 62/72] softfloat: Use goto for default nan case in pick_nan_muladd, Peter Maydell, 2024/12/11
- [PULL 70/72] softfloat: Replace WHICH with RET in parts_pick_nan, Peter Maydell, 2024/12/11
- [PULL 66/72] softfloat: Use parts_pick_nan in propagateFloatx80NaN,
Peter Maydell <=
- [PULL 65/72] softfloat: Move propagateFloatx80NaN to softfloat.c, Peter Maydell, 2024/12/11
- [PULL 68/72] softfloat: Share code between parts_pick_nan cases, Peter Maydell, 2024/12/11
- [PULL 71/72] MAINTAINERS: update email address for Leif Lindholm, Peter Maydell, 2024/12/11
- [PULL 69/72] softfloat: Sink frac_cmp in parts_pick_nan until needed, Peter Maydell, 2024/12/11
- [PULL 57/72] target/hexagon: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 53/72] target/rx: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 64/72] softfloat: Pad array size in pick_nan_muladd, Peter Maydell, 2024/12/11
- [PULL 67/72] softfloat: Inline pickNaN, Peter Maydell, 2024/12/11
- [PULL 72/72] MAINTAINERS: Add correct email address for Vikram Garhwal, Peter Maydell, 2024/12/11
- Re: [PULL 00/72] target-arm queue, Stefan Hajnoczi, 2024/12/12