[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 70/72] softfloat: Replace WHICH with RET in parts_pick_nan
From: |
Peter Maydell |
Subject: |
[PULL 70/72] softfloat: Replace WHICH with RET in parts_pick_nan |
Date: |
Wed, 11 Dec 2024 16:20:02 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Replace the "index" selecting between A and B with a result variable
of the proper type. This improves clarity within the function.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-12-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
fpu/softfloat-parts.c.inc | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index abe24aeaa00..ba8de7be76e 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -40,7 +40,8 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a,
FloatPartsN *b,
float_status *s)
{
bool have_snan = false;
- int cmp, which;
+ FloatPartsN *ret;
+ int cmp;
if (is_snan(a->cls) || is_snan(b->cls)) {
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
@@ -55,21 +56,21 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a,
FloatPartsN *b,
switch (s->float_2nan_prop_rule) {
case float_2nan_prop_s_ab:
if (have_snan) {
- which = is_snan(a->cls) ? 0 : 1;
+ ret = is_snan(a->cls) ? a : b;
break;
}
/* fall through */
case float_2nan_prop_ab:
- which = is_nan(a->cls) ? 0 : 1;
+ ret = is_nan(a->cls) ? a : b;
break;
case float_2nan_prop_s_ba:
if (have_snan) {
- which = is_snan(b->cls) ? 1 : 0;
+ ret = is_snan(b->cls) ? b : a;
break;
}
/* fall through */
case float_2nan_prop_ba:
- which = is_nan(b->cls) ? 1 : 0;
+ ret = is_nan(b->cls) ? b : a;
break;
case float_2nan_prop_x87:
/*
@@ -85,35 +86,32 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a,
FloatPartsN *b,
*/
if (is_snan(a->cls)) {
if (!is_snan(b->cls)) {
- which = is_qnan(b->cls) ? 1 : 0;
+ ret = is_qnan(b->cls) ? b : a;
break;
}
} else if (is_qnan(a->cls)) {
if (is_snan(b->cls) || !is_qnan(b->cls)) {
- which = 0;
+ ret = a;
break;
}
} else {
- which = 1;
+ ret = b;
break;
}
cmp = frac_cmp(a, b);
if (cmp == 0) {
cmp = a->sign < b->sign;
}
- which = cmp > 0 ? 0 : 1;
+ ret = cmp > 0 ? a : b;
break;
default:
g_assert_not_reached();
}
- if (which) {
- a = b;
+ if (is_snan(ret->cls)) {
+ parts_silence_nan(ret, s);
}
- if (is_snan(a->cls)) {
- parts_silence_nan(a, s);
- }
- return a;
+ return ret;
}
static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
--
2.34.1
- [PULL 52/72] target/sh4: Set default NaN pattern explicitly, (continued)
- [PULL 52/72] target/sh4: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [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 <=
- [PULL 66/72] softfloat: Use parts_pick_nan in propagateFloatx80NaN, Peter Maydell, 2024/12/11
- [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