[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 68/72] softfloat: Share code between parts_pick_nan cases
From: |
Peter Maydell |
Subject: |
[PULL 68/72] softfloat: Share code between parts_pick_nan cases |
Date: |
Wed, 11 Dec 2024 16:20:00 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Remember if there was an SNaN, and use that to simplify
float_2nan_prop_s_{ab,ba} to only the snan component.
Then, fall through to the corresponding
float_2nan_prop_{ab,ba} case to handle any remaining
nans, which must be quiet.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20241203203949.483774-10-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
fpu/softfloat-parts.c.inc | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index a1b148e90b9..3c77dcbb154 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -39,10 +39,12 @@ static void partsN(return_nan)(FloatPartsN *a, float_status
*s)
static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
float_status *s)
{
+ bool have_snan = false;
int cmp, which;
if (is_snan(a->cls) || is_snan(b->cls)) {
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
+ have_snan = true;
}
if (s->default_nan_mode) {
@@ -57,30 +59,20 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a,
FloatPartsN *b,
switch (s->float_2nan_prop_rule) {
case float_2nan_prop_s_ab:
- if (is_snan(a->cls)) {
- which = 0;
- } else if (is_snan(b->cls)) {
- which = 1;
- } else if (is_qnan(a->cls)) {
- which = 0;
- } else {
- which = 1;
+ if (have_snan) {
+ which = is_snan(a->cls) ? 0 : 1;
+ break;
}
- break;
- case float_2nan_prop_s_ba:
- if (is_snan(b->cls)) {
- which = 1;
- } else if (is_snan(a->cls)) {
- which = 0;
- } else if (is_qnan(b->cls)) {
- which = 1;
- } else {
- which = 0;
- }
- break;
+ /* fall through */
case float_2nan_prop_ab:
which = is_nan(a->cls) ? 0 : 1;
break;
+ case float_2nan_prop_s_ba:
+ if (have_snan) {
+ which = is_snan(b->cls) ? 1 : 0;
+ break;
+ }
+ /* fall through */
case float_2nan_prop_ba:
which = is_nan(b->cls) ? 1 : 0;
break;
--
2.34.1
- [PULL 55/72] target/sparc: Set default NaN pattern explicitly, (continued)
- [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, 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 <=
- [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