[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 for-10.0 02/54] fpu: Check for default_nan_mode before calling
From: |
Peter Maydell |
Subject: |
[PATCH v2 for-10.0 02/54] fpu: Check for default_nan_mode before calling pickNaNMulAdd |
Date: |
Mon, 2 Dec 2024 13:12:55 +0000 |
If the target sets default_nan_mode then we're always going to return
the default NaN, and pickNaNMulAdd() no longer has any side effects.
For consistency with pickNaN(), check for default_nan_mode before
calling pickNaNMulAdd().
When we convert pickNaNMulAdd() to allow runtime selection of the NaN
propagation rule, this means we won't have to make the targets which
use default_nan_mode also set a propagation rule.
Since RiscV always uses default_nan_mode, this allows us to remove
its ifdef case from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat-parts.c.inc | 8 ++++++--
fpu/softfloat-specialize.c.inc | 9 +++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index d63cd957a19..aac1f9cd28c 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -77,9 +77,13 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a,
FloatPartsN *b,
float_raise(float_flag_invalid | float_flag_invalid_imz, s);
}
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
+ if (s->default_nan_mode) {
+ which = 3;
+ } else {
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
+ }
- if (s->default_nan_mode || which == 3) {
+ if (which == 3) {
parts_default_nan(a, s);
return a;
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index c557c41b2af..81a67eb67b5 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -475,6 +475,13 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
bool infzero, float_status *status)
{
+ /*
+ * 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 defined(TARGET_ARM)
/* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
* the default NaN
@@ -578,8 +585,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass
b_cls, FloatClass c_cls,
} else {
return 1;
}
-#elif defined(TARGET_RISCV)
- return 3; /* default NaN */
#elif defined(TARGET_S390X)
if (infzero) {
return 3;
--
2.34.1
- [PATCH v2 for-10.0 00/54] fpu: Remove pickNaNMulAdd, default-NaN ifdefs, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 01/54] fpu: handle raising Invalid for infzero in pick_nan_muladd, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 02/54] fpu: Check for default_nan_mode before calling pickNaNMulAdd,
Peter Maydell <=
- [PATCH v2 for-10.0 03/54] softfloat: Allow runtime choice of inf * 0 + NaN result, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 05/54] target/arm: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 04/54] tests/fp: Explicitly set inf-zero-nan rule, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 14/54] softfloat: Pass have_snan to pickNaNMulAdd, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 09/54] target/sparc: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 06/54] target/s390: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 20/54] target/s390x: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 15/54] softfloat: Allow runtime choice of NaN propagation for muladd, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 10/54] target/xtensa: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 17/54] target/arm: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02