[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 61/72] softfloat: Inline pickNaNMulAdd
From: |
Peter Maydell |
Subject: |
[PULL 61/72] softfloat: Inline pickNaNMulAdd |
Date: |
Wed, 11 Dec 2024 16:19:53 +0000 |
From: Richard Henderson <richard.henderson@linaro.org>
Inline pickNaNMulAdd into its only caller. This makes
one assert redundant with the immediately preceding IF.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-3-richard.henderson@linaro.org
[PMM: keep comment from old code in new location]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++-
fpu/softfloat-specialize.c.inc | 54 ----------------------------------
2 files changed, 40 insertions(+), 55 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 655b7d9da51..c1a97c35b20 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -79,9 +79,48 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a,
FloatPartsN *b,
}
if (s->default_nan_mode) {
+ /*
+ * We guarantee not to require the target to tell us how to
+ * pick a NaN if we're always returning the default NaN.
+ * But if we're not in default-NaN mode then the target must
+ * specify.
+ */
which = 3;
+ } else if (infzero) {
+ /*
+ * Inf * 0 + NaN -- some implementations return the
+ * default NaN here, and some return the input NaN.
+ */
+ switch (s->float_infzeronan_rule) {
+ case float_infzeronan_dnan_never:
+ which = 2;
+ break;
+ case float_infzeronan_dnan_always:
+ which = 3;
+ break;
+ case float_infzeronan_dnan_if_qnan:
+ which = is_qnan(c->cls) ? 3 : 2;
+ break;
+ default:
+ g_assert_not_reached();
+ }
} else {
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s);
+ FloatClass cls[3] = { a->cls, b->cls, c->cls };
+ Float3NaNPropRule rule = s->float_3nan_prop_rule;
+
+ assert(rule != float_3nan_prop_none);
+ if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
+ /* We have at least one SNaN input and should prefer it */
+ do {
+ which = rule & R_3NAN_1ST_MASK;
+ rule >>= R_3NAN_1ST_LENGTH;
+ } while (!is_snan(cls[which]));
+ } else {
+ do {
+ which = rule & R_3NAN_1ST_MASK;
+ rule >>= R_3NAN_1ST_LENGTH;
+ } while (!is_nan(cls[which]));
+ }
}
if (which == 3) {
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index e075c47889a..f26458eaa31 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -448,60 +448,6 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
}
}
-/*----------------------------------------------------------------------------
-| Select which NaN to propagate for a three-input operation.
-| For the moment we assume that no CPU needs the 'larger significand'
-| information.
-| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN
-*----------------------------------------------------------------------------*/
-static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
- bool infzero, bool have_snan, float_status *status)
-{
- FloatClass cls[3] = { a_cls, b_cls, c_cls };
- Float3NaNPropRule rule = status->float_3nan_prop_rule;
- int which;
-
- /*
- * We guarantee not to require the target to tell us how to
- * pick a NaN if we're always returning the default NaN.
- * But if we're not in default-NaN mode then the target must
- * specify.
- */
- assert(!status->default_nan_mode);
-
- if (infzero) {
- /*
- * Inf * 0 + NaN -- some implementations return the default NaN here,
- * and some return the input NaN.
- */
- switch (status->float_infzeronan_rule) {
- case float_infzeronan_dnan_never:
- return 2;
- case float_infzeronan_dnan_always:
- return 3;
- case float_infzeronan_dnan_if_qnan:
- return is_qnan(c_cls) ? 3 : 2;
- default:
- g_assert_not_reached();
- }
- }
-
- assert(rule != float_3nan_prop_none);
- if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
- /* We have at least one SNaN input and should prefer it */
- do {
- which = rule & R_3NAN_1ST_MASK;
- rule >>= R_3NAN_1ST_LENGTH;
- } while (!is_snan(cls[which]));
- } else {
- do {
- which = rule & R_3NAN_1ST_MASK;
- rule >>= R_3NAN_1ST_LENGTH;
- } while (!is_nan(cls[which]));
- }
- return which;
-}
-
/*----------------------------------------------------------------------------
| Returns 1 if the double-precision floating-point value `a' is a quiet
| NaN; otherwise returns 0.
--
2.34.1
- [PULL 44/72] target/hppa: Set default NaN pattern explicitly, (continued)
- [PULL 44/72] target/hppa: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 45/72] target/alpha: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 46/72] target/arm: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 47/72] target/loongarch: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 48/72] target/m68k: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 50/72] target/openrisc: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 49/72] target/mips: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [PULL 51/72] target/ppc: Set default NaN pattern explicitly, Peter Maydell, 2024/12/11
- [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 <=
- [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