diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2024-12-11 15:31:08 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2024-12-11 15:31:08 +0000 |
commit | 1b34f934ddefc3bdc4322694c2726ddc4d9ebd45 (patch) | |
tree | 6bd6e3186f6d78f3909eb5c74f1e5165092bfe23 | |
parent | 313938c105946dacfc886217b47310adb01194c3 (diff) | |
download | qemu-1b34f934ddefc3bdc4322694c2726ddc4d9ebd45.zip qemu-1b34f934ddefc3bdc4322694c2726ddc4d9ebd45.tar.gz qemu-1b34f934ddefc3bdc4322694c2726ddc4d9ebd45.tar.bz2 |
softfloat: Use parts_pick_nan in propagateFloatx80NaN
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>
-rw-r--r-- | fpu/softfloat.c | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6ba1cfd..8de8d5f 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; - - /* 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) { - return floatx80_default_nan(status); - } + FloatParts128 pa, pb, *pr; - if (a.low < b.low) { - aIsLargerSignificand = 0; - } else if (b.low < a.low) { - aIsLargerSignificand = 1; - } else { - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; + if (!floatx80_unpack_canonical(&pa, a, status) || + !floatx80_unpack_canonical(&pb, b, status)) { + return floatx80_default_nan(status); } - 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); } /*---------------------------------------------------------------------------- |