* [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected
@ 2024-11-28 10:42 Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
` (24 more replies)
0 siblings, 25 replies; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
This patchset does the same thing we already did for pickNaN() to
pickNaNMulAdd() -- it replaces the compile-time ifdef ladder that
selected target-specific NaN propagation behaviour with checking some
runtime selectable settings in the float_status. The motivation is:
* this will let us have multiple targets in one QEMU binary
* the Arm FEAT_AFP architectural feature includes letting
the guest select a NaN propagation rule at runtime
The current ifdef ladder merges two different kinds of
implementation-specific behaviour:
* handling of the (inf * zero) + NaN special case
* selection of a NaN to propagate when more than one input is a NaN
The refactoring splits these out into two different settings, because
what a target chose for one of them isn't correlated with its
choice on the other one.
Mostly this series is not intended to have any guest visible behaviour
changes. There is one exception: the "default implementation" at the
bottom of the old ifdef ladder did not raise Invalid for the (0 * inf)
+ NaN case. This is definitely not correct, and basically any targets
using that part of the ifdef ladder had a bug because they didn't
implement their actual correct behaviour. The architectures using the
default case are i386, hppa, sh4 and tricore, and they will now raise
the Invalid exception in this case. (I checked the architecture manuals
for those architectures and they all say it should raise Invalid.)
Fixing this bug in the first patch means we don't need to have runtime
selection of a behaviour that's not actually what these targets do.
(It also means we can reorder the code to avoid calling pickNaNMulAdd()
for any target which sets default_nan_mode, as we do for pickNaN().)
The rest of the patchset is structured like the pickNaN() refactoring
-- introduce the runtime selection field in the float_status word, but
leave the ifdef ladder in place as fallback, then convert each target
one at at time. We do the info-zero-nan setting first, then the NaN
propagation order setting.
Finally, once we're done we can remove the use_first_nan field, which
was an Xtensa-specific way to select the NaN propagation rules at
runtime.
Tested with 'make check-functional' and 'make check-avocado'
and 'make check-tcg'.
thanks
-- PMM
Peter Maydell (25):
fpu: handle raising Invalid for infzero in pick_nan_muladd
fpu: Check for default_nan_mode before calling pickNaNMulAdd
softfloat: Allow runtime choice of inf * 0 + NaN result
tests/fp: Explicitly set inf-zero-nan rule
target/arm: Set FloatInfZeroNaNRule explicitly
target/s390: Set FloatInfZeroNaNRule explicitly
target/ppc: Set FloatInfZeroNaNRule explicitly
target/mips: Set FloatInfZeroNaNRule explicitly
target/sparc: Set FloatInfZeroNaNRule explicitly
target/xtensa: Set FloatInfZeroNaNRule explicitly
target/x86: Set FloatInfZeroNaNRule explicitly
target/loongarch: Set FloatInfZeroNaNRule explicitly
target/hppa: Set FloatInfZeroNaNRule explicitly
softfloat: Allow runtime choice of NaN propagation for muladd
tests/fp: Explicitly set 3-NaN propagation rule
target/arm: Set Float3NaNPropRule explicitly
target/loongarch: Set Float3NaNPropRule explicitly
target/ppc: Set Float3NaNPropRule explicitly
target/s390x: Set Float3NaNPropRule explicitly
target/sparc: Set Float3NaNPropRule explicitly
target/mips: Set Float3NaNPropRule explicitly
target/xtensa: Set Float3NaNPropRule explicitly
target/i386: Set Float3NaNPropRule explicitly
target/hppa: Set Float3NaNPropRule explicitly
fpu: Remove use_first_nan field from float_status
include/fpu/softfloat-helpers.h | 27 +++-
include/fpu/softfloat-types.h | 61 ++++++++-
target/mips/fpu_helper.h | 13 ++
target/arm/cpu.c | 8 ++
target/hppa/fpu_helper.c | 10 ++
target/i386/tcg/fpu_helper.c | 9 ++
target/loongarch/tcg/fpu_helper.c | 6 +
target/mips/msa.c | 7 +
target/ppc/cpu_init.c | 15 +++
target/s390x/cpu.c | 3 +
target/sparc/cpu.c | 4 +
target/xtensa/cpu.c | 2 +
target/xtensa/fpu_helper.c | 3 +-
tests/fp/fp-bench.c | 6 +
tests/fp/fp-test.c | 6 +
fpu/softfloat-parts.c.inc | 19 ++-
fpu/softfloat-specialize.c.inc | 206 ++++++++----------------------
17 files changed, 236 insertions(+), 169 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:07 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
` (23 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
For IEEE fused multiply-add, the (0 * inf) + NaN case should raise
Invalid for the multiplication of 0 by infinity. Currently we handle
this in the per-architecture ifdef ladder in pickNaNMulAdd().
However, since this isn't really architecture specific we can hoist
it up to the generic code.
For the cases where the infzero test in pickNaNMulAdd was
returning 2, we can delete the check entirely and allow the
code to fall into the normal pick-a-NaN handling, because this
will return 2 anyway (input 'c' being the only NaN in this case).
For the cases where infzero was returning 3 to indicate "return
the default NaN", we must retain that "return 3".
For Arm, this looks like it might be a behaviour change because we
used to set float_flag_invalid | float_flag_invalid_imz only if C is
a quiet NaN. However, it is not, because Arm target code never looks
at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we
already raised float_flag_invalid via the "abc_mask &
float_cmask_snan" check in pick_nan_muladd.
For any target architecture using the "default implementation" at the
bottom of the ifdef, this is a behaviour change but will be fixing a
bug (where we failed to raise the Invalid exception for (0 * inf +
QNaN). The architectures using the default case are:
* hppa
* sh4
* tricore
The Tricore and SH4 CPU architecture manuals are clear that this
should have raised Invalid; HPPA is a bit vaguer but still seems
clear enough.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
fpu/softfloat-parts.c.inc | 13 +++++++------
fpu/softfloat-specialize.c.inc | 29 +----------------------------
2 files changed, 8 insertions(+), 34 deletions(-)
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index cc6e06b9761..d63cd957a19 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -66,19 +66,20 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
int ab_mask, int abc_mask)
{
int which;
+ bool infzero = (ab_mask == float_cmask_infzero);
if (unlikely(abc_mask & float_cmask_snan)) {
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
}
- which = pickNaNMulAdd(a->cls, b->cls, c->cls,
- ab_mask == float_cmask_infzero, s);
+ if (infzero) {
+ /* This is (0 * inf) + NaN or (inf * 0) + NaN */
+ 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) {
- /*
- * Note that this check is after pickNaNMulAdd so that function
- * has an opportunity to set the Invalid flag for infzero.
- */
parts_default_nan(a, s);
return a;
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 9bca03c4aed..c557c41b2af 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -480,7 +480,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* the default NaN
*/
if (infzero && is_qnan(c_cls)) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
return 3;
}
@@ -507,7 +506,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* case sets InvalidOp and returns the default NaN
*/
if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
return 3;
}
/* Prefer sNaN over qNaN, in the a, b, c order. */
@@ -529,10 +527,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
* case sets InvalidOp and returns the input value 'c'
*/
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- return 2;
- }
/* Prefer sNaN over qNaN, in the c, a, b order. */
if (is_snan(c_cls)) {
return 2;
@@ -553,10 +547,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
* case sets InvalidOp and returns the input value 'c'
*/
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- return 2;
- }
+
/* Prefer sNaN over qNaN, in the c, a, b order. */
if (is_snan(c_cls)) {
return 2;
@@ -576,10 +567,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* to return an input NaN if we have one (ie c) rather than generating
* a default NaN
*/
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- return 2;
- }
/* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
* otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
@@ -592,14 +579,9 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
return 1;
}
#elif defined(TARGET_RISCV)
- /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- }
return 3; /* default NaN */
#elif defined(TARGET_S390X)
if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
return 3;
}
@@ -617,11 +599,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
return 2;
}
#elif defined(TARGET_SPARC)
- /* For (inf,0,nan) return c. */
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- return 2;
- }
/* Prefer SNaN over QNaN, order C, B, A. */
if (is_snan(c_cls)) {
return 2;
@@ -641,10 +618,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns
* an input NaN if we have one (ie c).
*/
- if (infzero) {
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
- return 2;
- }
if (status->use_first_nan) {
if (is_nan(a_cls)) {
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
` (22 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
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>
---
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
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
` (21 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
IEEE 758 does not define a fixed rule for what NaN to return in
the case of a fused multiply-add of inf * 0 + NaN. Different
architectures thus do different things:
* some return the default NaN
* some return the input NaN
* Arm returns the default NaN if the input NaN is quiet,
and the input NaN if it is signalling
We want to make this logic be runtime selected rather than
hardcoded into the binary, because:
* this will let us have multiple targets in one QEMU binary
* the Arm FEAT_AFP architectural feature includes letting
the guest select a NaN propagation rule at runtime
In this commit we add an enum for the propagation rule, the field in
float_status, and the corresponding getters and setters. We change
pickNaNMulAdd to honour this, but because all targets still leave
this field at its default 0 value, the fallback logic will pick the
rule type with the old ifdef ladder.
Note that four architectures both use the muladd softfloat functions
and did not have a branch of the ifdef ladder to specify their
behaviour (and so were ending up with the "default" case, probably
wrongly): i386, HPPA, SH4 and Tricore. SH4 and Tricore both set
default_nan_mode, and so will never get into pickNaNMulAdd(). For
HPPA and i386 we retain the same behaviour as the old default-case,
which is to not ever return the default NaN. This might not be
correct but it is not a behaviour change.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/fpu/softfloat-helpers.h | 11 ++++
include/fpu/softfloat-types.h | 23 +++++++++
fpu/softfloat-specialize.c.inc | 91 ++++++++++++++++++++++-----------
3 files changed, 95 insertions(+), 30 deletions(-)
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
index 453188de70b..0bf44dc6087 100644
--- a/include/fpu/softfloat-helpers.h
+++ b/include/fpu/softfloat-helpers.h
@@ -81,6 +81,12 @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
status->float_2nan_prop_rule = rule;
}
+static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
+ float_status *status)
+{
+ status->float_infzeronan_rule = rule;
+}
+
static inline void set_flush_to_zero(bool val, float_status *status)
{
status->flush_to_zero = val;
@@ -137,6 +143,11 @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
return status->float_2nan_prop_rule;
}
+static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
+{
+ return status->float_infzeronan_rule;
+}
+
static inline bool get_flush_to_zero(float_status *status)
{
return status->flush_to_zero;
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 8f39691dfd0..27a1c96754d 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -207,6 +207,28 @@ typedef enum __attribute__((__packed__)) {
float_2nan_prop_x87,
} Float2NaNPropRule;
+/*
+ * Rule for result of fused multiply-add 0 * Inf + NaN.
+ * This must be a NaN, but implementations differ on whether this
+ * is the input NaN or the default NaN.
+ *
+ * You don't need to set this if default_nan_mode is enabled.
+ * When not in default-NaN mode, it is an error for the target
+ * not to set the rule in float_status if it uses muladd, and we
+ * will assert if we need to handle an input NaN and no rule was
+ * selected.
+ */
+typedef enum __attribute__((__packed__)) {
+ /* No propagation rule specified */
+ float_infzeronan_none = 0,
+ /* Result is never the default NaN (so always the input NaN) */
+ float_infzeronan_dnan_never = 0,
+ /* Result is always the default NaN */
+ float_infzeronan_dnan_always,
+ /* Result is the default NaN if the input NaN is quiet */
+ float_infzeronan_dnan_if_qnan,
+} FloatInfZeroNaNRule;
+
/*
* Floating Point Status. Individual architectures may maintain
* several versions of float_status for different functions. The
@@ -219,6 +241,7 @@ typedef struct float_status {
FloatRoundMode float_rounding_mode;
FloatX80RoundPrec floatx80_rounding_precision;
Float2NaNPropRule float_2nan_prop_rule;
+ FloatInfZeroNaNRule float_infzeronan_rule;
bool tininess_before_rounding;
/* should denormalised results go to zero and set the inexact flag? */
bool flush_to_zero;
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 81a67eb67b5..f5b422e07b5 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -475,6 +475,8 @@ 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)
{
+ FloatInfZeroNaNRule rule = status->float_infzeronan_rule;
+
/*
* We guarantee not to require the target to tell us how to
* pick a NaN if we're always returning the default NaN.
@@ -482,14 +484,68 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* specify.
*/
assert(!status->default_nan_mode);
+
+ if (rule == float_infzeronan_none) {
+ /*
+ * Temporarily fall back to ifdef ladder
+ */
#if defined(TARGET_ARM)
- /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
- * the default NaN
- */
- if (infzero && is_qnan(c_cls)) {
- return 3;
+ /*
+ * For ARM, the (inf,zero,qnan) case returns the default NaN,
+ * but (inf,zero,snan) returns the input NaN.
+ */
+ rule = float_infzeronan_dnan_if_qnan;
+#elif defined(TARGET_MIPS)
+ if (snan_bit_is_one(status)) {
+ /*
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
+ * case sets InvalidOp and returns the default NaN
+ */
+ rule = float_infzeronan_dnan_always;
+ } else {
+ /*
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'
+ */
+ rule = float_infzeronan_dnan_never;
+ }
+#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \
+ defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
+ defined(TARGET_I386) || defined(TARGET_LOONGARCH)
+ /*
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'
+ */
+ /*
+ * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
+ * to return an input NaN if we have one (ie c) rather than generating
+ * a default NaN
+ */
+ rule = float_infzeronan_dnan_never;
+#elif defined(TARGET_S390X)
+ rule = float_infzeronan_dnan_always;
+#endif
}
+ if (infzero) {
+ /*
+ * Inf * 0 + NaN -- some implementations return the default NaN here,
+ * and some return the input NaN.
+ */
+ switch (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();
+ }
+ }
+
+#if defined(TARGET_ARM)
+
/* This looks different from the ARM ARM pseudocode, because the ARM ARM
* puts the operands to a fused mac operation (a*b)+c in the order c,a,b.
*/
@@ -508,13 +564,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
#elif defined(TARGET_MIPS)
if (snan_bit_is_one(status)) {
- /*
- * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
- * case sets InvalidOp and returns the default NaN
- */
- if (infzero) {
- return 3;
- }
/* Prefer sNaN over qNaN, in the a, b, c order. */
if (is_snan(a_cls)) {
return 0;
@@ -530,10 +579,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
return 2;
}
} else {
- /*
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
- * case sets InvalidOp and returns the input value 'c'
- */
/* Prefer sNaN over qNaN, in the c, a, b order. */
if (is_snan(c_cls)) {
return 2;
@@ -550,11 +595,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
}
#elif defined(TARGET_LOONGARCH64)
- /*
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
- * case sets InvalidOp and returns the input value 'c'
- */
-
/* Prefer sNaN over qNaN, in the c, a, b order. */
if (is_snan(c_cls)) {
return 2;
@@ -570,11 +610,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
return 1;
}
#elif defined(TARGET_PPC)
- /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
- * to return an input NaN if we have one (ie c) rather than generating
- * a default NaN
- */
-
/* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
* otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
*/
@@ -586,10 +621,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
return 1;
}
#elif defined(TARGET_S390X)
- if (infzero) {
- return 3;
- }
-
if (is_snan(a_cls)) {
return 0;
} else if (is_snan(b_cls)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (2 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
` (20 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Explicitly set a rule in the softfloat tests for the inf-zero-nan
muladd special case. In meson.build we put -DTARGET_ARM in fpcflags,
and so we should select here the Arm rule of
float_infzeronan_dnan_if_qnan.
---
tests/fp/fp-bench.c | 5 +++++
tests/fp/fp-test.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
index 75c07d5d1f1..fde64836194 100644
--- a/tests/fp/fp-bench.c
+++ b/tests/fp/fp-bench.c
@@ -488,7 +488,12 @@ static void run_bench(void)
{
bench_func_t f;
+ /*
+ * These implementation-defined choices for various things IEEE
+ * doesn't specify match those used by the Arm architecture.
+ */
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
f = bench_funcs[operation][precision];
g_assert(f);
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 5f6f25c8821..251c278ede9 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -935,7 +935,12 @@ void run_test(void)
{
unsigned int i;
+ /*
+ * These implementation-defined choices for various things IEEE
+ * doesn't specify match those used by the Arm architecture.
+ */
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
genCases_setLevel(test_level);
verCases_maxErrorCount = n_max_errors;
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (3 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:27 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
` (19 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the Arm target,
so we can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/cpu.c | 3 +++
fpu/softfloat-specialize.c.inc | 8 +-------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 6938161b954..ead39793985 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -173,11 +173,14 @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
* * tininess-before-rounding
* * 2-input NaN propagation prefers SNaN over QNaN, and then
* operand A over operand B (see FPProcessNaNs() pseudocode)
+ * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
+ * and the input NaN if it is signalling
*/
static void arm_set_default_fp_behaviours(float_status *s)
{
set_float_detect_tininess(float_tininess_before_rounding, s);
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
}
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index f5b422e07b5..b3ffa54f368 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -489,13 +489,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
/*
* Temporarily fall back to ifdef ladder
*/
-#if defined(TARGET_ARM)
- /*
- * For ARM, the (inf,zero,qnan) case returns the default NaN,
- * but (inf,zero,snan) returns the input NaN.
- */
- rule = float_infzeronan_dnan_if_qnan;
-#elif defined(TARGET_MIPS)
+#if defined(TARGET_MIPS)
if (snan_bit_is_one(status)) {
/*
* For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 06/25] target/s390: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (4 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
` (18 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for s390, so we
can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/s390x/cpu.c | 2 ++
fpu/softfloat-specialize.c.inc | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 514c70f3010..d5941b5b9df 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -206,6 +206,8 @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
set_float_detect_tininess(float_tininess_before_rounding,
&env->fpu_status);
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status);
+ set_float_infzeronan_rule(float_infzeronan_dnan_always,
+ &env->fpu_status);
/* fall through */
case RESET_TYPE_S390_CPU_NORMAL:
env->psw.mask &= ~PSW_MASK_RI;
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index b3ffa54f368..db914ddbb1c 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -516,8 +516,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* a default NaN
*/
rule = float_infzeronan_dnan_never;
-#elif defined(TARGET_S390X)
- rule = float_infzeronan_dnan_always;
#endif
}
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 07/25] target/ppc: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (5 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
` (17 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the PPC target,
so we can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/ppc/cpu_init.c | 7 +++++++
fpu/softfloat-specialize.c.inc | 7 +------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index efcb80d1c25..f18908a643a 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7270,6 +7270,13 @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
*/
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status);
+ /*
+ * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
+ * to return an input NaN if we have one (ie c) rather than generating
+ * a default NaN
+ */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status);
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
ppc_spr_t *spr = &env->spr_cb[i];
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index db914ddbb1c..2023b2bd632 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -503,18 +503,13 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
*/
rule = float_infzeronan_dnan_never;
}
-#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \
+#elif defined(TARGET_SPARC) || \
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
/*
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
* case sets InvalidOp and returns the input value 'c'
*/
- /*
- * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
- * to return an input NaN if we have one (ie c) rather than generating
- * a default NaN
- */
rule = float_infzeronan_dnan_never;
#endif
}
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 08/25] target/mips: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (6 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:29 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
` (16 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the MIPS target,
so we can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/mips/fpu_helper.h | 9 +++++++++
target/mips/msa.c | 4 ++++
fpu/softfloat-specialize.c.inc | 16 +---------------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
index 7c3c7897b45..be66f2f813a 100644
--- a/target/mips/fpu_helper.h
+++ b/target/mips/fpu_helper.h
@@ -28,6 +28,7 @@ static inline void restore_flush_mode(CPUMIPSState *env)
static inline void restore_snan_bit_mode(CPUMIPSState *env)
{
bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
+ FloatInfZeroNaNRule izn_rule;
/*
* With nan2008, SNaNs are silenced in the usual way.
@@ -35,6 +36,14 @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
*/
set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status);
set_default_nan_mode(!nan2008, &env->active_fpu.fp_status);
+ /*
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
+ * case sets InvalidOp and returns the default NaN.
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'.
+ */
+ izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always;
+ set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
}
static inline void restore_fp_status(CPUMIPSState *env)
diff --git a/target/mips/msa.c b/target/mips/msa.c
index 9dffc428f5c..cc152db27f9 100644
--- a/target/mips/msa.c
+++ b/target/mips/msa.c
@@ -74,4 +74,8 @@ void msa_reset(CPUMIPSState *env)
/* set proper signanling bit meaning ("1" means "quiet") */
set_snan_bit_is_one(0, &env->active_tc.msa_fp_status);
+
+ /* Inf * 0 + NaN returns the input NaN */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never,
+ &env->active_tc.msa_fp_status);
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 2023b2bd632..db9a466e05b 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -489,21 +489,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
/*
* Temporarily fall back to ifdef ladder
*/
-#if defined(TARGET_MIPS)
- if (snan_bit_is_one(status)) {
- /*
- * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
- * case sets InvalidOp and returns the default NaN
- */
- rule = float_infzeronan_dnan_always;
- } else {
- /*
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
- * case sets InvalidOp and returns the input value 'c'
- */
- rule = float_infzeronan_dnan_never;
- }
-#elif defined(TARGET_SPARC) || \
+#if defined(TARGET_SPARC) || \
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 09/25] target/sparc: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (7 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
` (15 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the SPARC target,
so we can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/sparc/cpu.c | 2 ++
fpu/softfloat-specialize.c.inc | 3 +--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index dd7af86de73..61f2d3fbf23 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -814,6 +814,8 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
* the CPU state struct so it won't get zeroed on reset.
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
+ /* For inf * 0 + NaN, return the input NaN */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
cpu_exec_realizefn(cs, &local_err);
if (local_err != NULL) {
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index db9a466e05b..7e57e85348b 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -489,8 +489,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
/*
* Temporarily fall back to ifdef ladder
*/
-#if defined(TARGET_SPARC) || \
- defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
+#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
/*
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 10/25] target/xtensa: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (8 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
` (14 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the xtensa target,
so we can remove the ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/xtensa/cpu.c | 2 ++
fpu/softfloat-specialize.c.inc | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 6f9039abaee..3163b758235 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -133,6 +133,8 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
reset_mmu(env);
cs->halted = env->runstall;
#endif
+ /* For inf * 0 + NaN, return the input NaN */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
set_no_signaling_nans(!dfpu, &env->fp_status);
xtensa_use_first_nan(env, !dfpu);
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 7e57e85348b..3062d19402d 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -489,7 +489,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
/*
* Temporarily fall back to ifdef ladder
*/
-#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
+#if defined(TARGET_HPPA) || \
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
/*
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 11/25] target/x86: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (9 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 14:04 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
` (13 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the x86 target.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/i386/tcg/fpu_helper.c | 7 +++++++
fpu/softfloat-specialize.c.inc | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index 53b49bb2977..e9de084a96d 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -173,6 +173,13 @@ void cpu_init_fp_statuses(CPUX86State *env)
*/
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status);
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status);
+ /*
+ * Only SSE has multiply-add instructions.
+ * TODO: this might be wrong, as we never implemented any x86-specific
+ * handling for the NaN case for multiply-add. This needs to be checked
+ * against the manual.
+ */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
}
static inline uint8_t save_exception_flags(CPUX86State *env)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 3062d19402d..ad4f7096d09 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -490,7 +490,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
* Temporarily fall back to ifdef ladder
*/
#if defined(TARGET_HPPA) || \
- defined(TARGET_I386) || defined(TARGET_LOONGARCH)
+ defined(TARGET_LOONGARCH)
/*
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
* case sets InvalidOp and returns the input value 'c'
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 12/25] target/loongarch: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (10 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 14:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
` (12 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the loongarch target.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/loongarch/tcg/fpu_helper.c | 5 +++++
fpu/softfloat-specialize.c.inc | 7 +------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
index 21bc3b04a96..6a2c4b5b1db 100644
--- a/target/loongarch/tcg/fpu_helper.c
+++ b/target/loongarch/tcg/fpu_helper.c
@@ -32,6 +32,11 @@ void restore_fp_status(CPULoongArchState *env)
&env->fp_status);
set_flush_to_zero(0, &env->fp_status);
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
+ /*
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'
+ */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
}
int ieee_ex_to_loongarch(int xcpt)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index ad4f7096d09..05dec2fcb4c 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -489,12 +489,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
/*
* Temporarily fall back to ifdef ladder
*/
-#if defined(TARGET_HPPA) || \
- defined(TARGET_LOONGARCH)
- /*
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
- * case sets InvalidOp and returns the input value 'c'
- */
+#if defined(TARGET_HPPA)
rule = float_infzeronan_dnan_never;
#endif
}
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 13/25] target/hppa: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (11 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 14:10 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
` (11 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the FloatInfZeroNaNRule explicitly for the HPPA target,
so we can remove the ifdef from pickNaNMulAdd().
As this is the last target to be converted to explicitly setting
the rule, we can remove the fallback code in pickNaNMulAdd()
entirely.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/hppa/fpu_helper.c | 2 ++
fpu/softfloat-specialize.c.inc | 13 +------------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
index 0e44074ba82..393cae33bf9 100644
--- a/target/hppa/fpu_helper.c
+++ b/target/hppa/fpu_helper.c
@@ -55,6 +55,8 @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
* HPPA does note implement a CPU reset method at all...
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
+ /* For inf * 0 + NaN, return the input NaN */
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
}
void cpu_hppa_loaded_fr0(CPUHPPAState *env)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 05dec2fcb4c..3e4ec938b25 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -475,8 +475,6 @@ 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)
{
- FloatInfZeroNaNRule rule = status->float_infzeronan_rule;
-
/*
* We guarantee not to require the target to tell us how to
* pick a NaN if we're always returning the default NaN.
@@ -485,21 +483,12 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
*/
assert(!status->default_nan_mode);
- if (rule == float_infzeronan_none) {
- /*
- * Temporarily fall back to ifdef ladder
- */
-#if defined(TARGET_HPPA)
- rule = float_infzeronan_dnan_never;
-#endif
- }
-
if (infzero) {
/*
* Inf * 0 + NaN -- some implementations return the default NaN here,
* and some return the input NaN.
*/
- switch (rule) {
+ switch (status->float_infzeronan_rule) {
case float_infzeronan_dnan_never:
return 2;
case float_infzeronan_dnan_always:
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (12 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
@ 2024-11-28 10:42 ` Peter Maydell
2024-11-28 17:49 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
` (10 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
IEEE 758 does not define a fixed rule for which NaN to pick as the
result if both operands of a 3-operand fused multiply-add operation
are NaNs. As a result different architectures have ended up with
different rules for propagating NaNs.
QEMU currently hardcodes the NaN propagation logic into the binary
because pickNaNMulAdd() has an ifdef ladder for different targets.
We want to make the propagation rule instead be selectable at
runtime, because:
* this will let us have multiple targets in one QEMU binary
* the Arm FEAT_AFP architectural feature includes letting
the guest select a NaN propagation rule at runtime
In this commit we add an enum for the propagation rule, the field in
float_status, and the corresponding getters and setters. We change
pickNaNMulAdd to honour this, but because all targets still leave
this field at its default 0 value, the fallback logic will pick the
rule type with the old ifdef ladder.
It's valid not to set a propagation rule if default_nan_mode is
enabled, because in that case there's no need to pick a NaN; all the
callers of pickNaNMulAdd() catch this case and skip calling it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/fpu/softfloat-helpers.h | 11 +++
include/fpu/softfloat-types.h | 37 ++++++++
fpu/softfloat-specialize.c.inc | 160 +++++++++++++-------------------
3 files changed, 112 insertions(+), 96 deletions(-)
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
index 0bf44dc6087..cf06b4e16bf 100644
--- a/include/fpu/softfloat-helpers.h
+++ b/include/fpu/softfloat-helpers.h
@@ -81,6 +81,12 @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
status->float_2nan_prop_rule = rule;
}
+static inline void set_float_3nan_prop_rule(Float3NaNPropRule rule,
+ float_status *status)
+{
+ status->float_3nan_prop_rule = rule;
+}
+
static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
float_status *status)
{
@@ -143,6 +149,11 @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
return status->float_2nan_prop_rule;
}
+static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status)
+{
+ return status->float_3nan_prop_rule;
+}
+
static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
{
return status->float_infzeronan_rule;
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 27a1c96754d..79220f8c67f 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -207,6 +207,42 @@ typedef enum __attribute__((__packed__)) {
float_2nan_prop_x87,
} Float2NaNPropRule;
+/*
+ * 3-input NaN propagation rule, for fused multiply-add. Individual
+ * architectures have different rules for which input NaN is
+ * propagated to the output when there is more than one NaN on the
+ * input.
+ *
+ * If default_nan_mode is enabled then it is valid not to set a NaN
+ * propagation rule, because the softfloat code guarantees not to try
+ * to pick a NaN to propagate in default NaN mode. When not in
+ * default-NaN mode, it is an error for the target not to set the rule
+ * in float_status if it uses a muladd, and we will assert if we need
+ * to handle an input NaN and no rule was selected.
+ *
+ * For QEMU, the multiply-add operation is A * B + C.
+ *
+ * NB: we don't list all 12 possibilities here or implement them
+ * in pickNaNMulAdd; if your architecture needs one of the missing
+ * combinations you should add it.
+ */
+typedef enum __attribute__((__packed__)) {
+ /* No propagation rule specified */
+ float_3nan_prop_none = 0,
+ /* Prefer SNaN over QNaN, then operand A over B over C */
+ float_3nan_prop_s_abc,
+ /* Prefer SNaN over QNaN, then operand C over A over B */
+ float_3nan_prop_s_cab,
+ /* Prefer SNaN over QNaN, then operand C over B over A */
+ float_3nan_prop_s_cba,
+ /* Prefer A over B over C regardless of SNaN vs QNaN */
+ float_3nan_prop_abc,
+ /* Prefer A over C over B regardless of SNaN vs QNaN */
+ float_3nan_prop_acb,
+ /* Prefer C over B over A regardless of SNaN vs QNaN */
+ float_3nan_prop_cba,
+} Float3NaNPropRule;
+
/*
* Rule for result of fused multiply-add 0 * Inf + NaN.
* This must be a NaN, but implementations differ on whether this
@@ -241,6 +277,7 @@ typedef struct float_status {
FloatRoundMode float_rounding_mode;
FloatX80RoundPrec floatx80_rounding_precision;
Float2NaNPropRule float_2nan_prop_rule;
+ Float3NaNPropRule float_3nan_prop_rule;
FloatInfZeroNaNRule float_infzeronan_rule;
bool tininess_before_rounding;
/* should denormalised results go to zero and set the inexact flag? */
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 3e4ec938b25..d7c0c90ea65 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -475,6 +475,7 @@ 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)
{
+ Float3NaNPropRule rule = status->float_3nan_prop_rule;
/*
* We guarantee not to require the target to tell us how to
* pick a NaN if we're always returning the default NaN.
@@ -500,27 +501,44 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
}
+ if (rule == float_3nan_prop_none) {
#if defined(TARGET_ARM)
-
- /* This looks different from the ARM ARM pseudocode, because the ARM ARM
- * puts the operands to a fused mac operation (a*b)+c in the order c,a,b.
- */
- if (is_snan(c_cls)) {
- return 2;
- } else if (is_snan(a_cls)) {
- return 0;
- } else if (is_snan(b_cls)) {
- return 1;
- } else if (is_qnan(c_cls)) {
- return 2;
- } else if (is_qnan(a_cls)) {
- return 0;
- } else {
- return 1;
- }
+ /*
+ * This looks different from the ARM ARM pseudocode, because the ARM ARM
+ * puts the operands to a fused mac operation (a*b)+c in the order c,a,b
+ */
+ rule = float_3nan_prop_s_cab;
#elif defined(TARGET_MIPS)
- if (snan_bit_is_one(status)) {
- /* Prefer sNaN over qNaN, in the a, b, c order. */
+ if (snan_bit_is_one(status)) {
+ rule = float_3nan_prop_s_abc;
+ } else {
+ rule = float_3nan_prop_s_cab;
+ }
+#elif defined(TARGET_LOONGARCH64)
+ rule = float_3nan_prop_s_cab;
+#elif defined(TARGET_PPC)
+ /*
+ * If fRA is a NaN return it; otherwise if fRB is a NaN return it;
+ * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
+ */
+ rule = float_3nan_prop_acb;
+#elif defined(TARGET_S390X)
+ rule = float_3nan_prop_s_abc;
+#elif defined(TARGET_SPARC)
+ rule = float_3nan_prop_s_cba;
+#elif defined(TARGET_XTENSA)
+ if (status->use_first_nan) {
+ rule = float_3nan_prop_abc;
+ } else {
+ rule = float_3nan_prop_cba;
+ }
+#else
+ rule = float_3nan_prop_abc;
+#endif
+ }
+
+ switch (rule) {
+ case float_3nan_prop_s_abc:
if (is_snan(a_cls)) {
return 0;
} else if (is_snan(b_cls)) {
@@ -534,8 +552,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
return 2;
}
- } else {
- /* Prefer sNaN over qNaN, in the c, a, b order. */
+ case float_3nan_prop_s_cab:
if (is_snan(c_cls)) {
return 2;
} else if (is_snan(a_cls)) {
@@ -549,68 +566,21 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
return 1;
}
- }
-#elif defined(TARGET_LOONGARCH64)
- /* Prefer sNaN over qNaN, in the c, a, b order. */
- if (is_snan(c_cls)) {
- return 2;
- } else if (is_snan(a_cls)) {
- return 0;
- } else if (is_snan(b_cls)) {
- return 1;
- } else if (is_qnan(c_cls)) {
- return 2;
- } else if (is_qnan(a_cls)) {
- return 0;
- } else {
- return 1;
- }
-#elif defined(TARGET_PPC)
- /* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
- * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
- */
- if (is_nan(a_cls)) {
- return 0;
- } else if (is_nan(c_cls)) {
- return 2;
- } else {
- return 1;
- }
-#elif defined(TARGET_S390X)
- if (is_snan(a_cls)) {
- return 0;
- } else if (is_snan(b_cls)) {
- return 1;
- } else if (is_snan(c_cls)) {
- return 2;
- } else if (is_qnan(a_cls)) {
- return 0;
- } else if (is_qnan(b_cls)) {
- return 1;
- } else {
- return 2;
- }
-#elif defined(TARGET_SPARC)
- /* Prefer SNaN over QNaN, order C, B, A. */
- if (is_snan(c_cls)) {
- return 2;
- } else if (is_snan(b_cls)) {
- return 1;
- } else if (is_snan(a_cls)) {
- return 0;
- } else if (is_qnan(c_cls)) {
- return 2;
- } else if (is_qnan(b_cls)) {
- return 1;
- } else {
- return 0;
- }
-#elif defined(TARGET_XTENSA)
- /*
- * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns
- * an input NaN if we have one (ie c).
- */
- if (status->use_first_nan) {
+ case float_3nan_prop_s_cba:
+ if (is_snan(c_cls)) {
+ return 2;
+ } else if (is_snan(b_cls)) {
+ return 1;
+ } else if (is_snan(a_cls)) {
+ return 0;
+ } else if (is_qnan(c_cls)) {
+ return 2;
+ } else if (is_qnan(b_cls)) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case float_3nan_prop_abc:
if (is_nan(a_cls)) {
return 0;
} else if (is_nan(b_cls)) {
@@ -618,7 +588,15 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
return 2;
}
- } else {
+ case float_3nan_prop_acb:
+ if (is_nan(a_cls)) {
+ return 0;
+ } else if (is_nan(c_cls)) {
+ return 2;
+ } else {
+ return 1;
+ }
+ case float_3nan_prop_cba:
if (is_nan(c_cls)) {
return 2;
} else if (is_nan(b_cls)) {
@@ -626,19 +604,9 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
return 0;
}
+ default:
+ g_assert_not_reached();
}
-#else
- /* A default implementation: prefer a to b to c.
- * This is unlikely to actually match any real implementation.
- */
- if (is_nan(a_cls)) {
- return 0;
- } else if (is_nan(b_cls)) {
- return 1;
- } else {
- return 2;
- }
-#endif
}
/*----------------------------------------------------------------------------
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (13 preceding siblings ...)
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:49 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
` (9 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Explicitly set a rule in the softfloat tests for propagating NaNs in
the muladd case. In meson.build we put -DTARGET_ARM in fpcflags, and
so we should select here the Arm rule of float_3nan_prop_s_cab.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
tests/fp/fp-bench.c | 1 +
tests/fp/fp-test.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
index fde64836194..39d80c9038f 100644
--- a/tests/fp/fp-bench.c
+++ b/tests/fp/fp-bench.c
@@ -493,6 +493,7 @@ static void run_bench(void)
* doesn't specify match those used by the Arm architecture.
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status);
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
f = bench_funcs[operation][precision];
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 251c278ede9..f290d523ab1 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -940,6 +940,7 @@ void run_test(void)
* doesn't specify match those used by the Arm architecture.
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf);
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
genCases_setLevel(test_level);
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (14 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:51 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
` (8 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for Arm, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/cpu.c | 5 +++++
fpu/softfloat-specialize.c.inc | 8 +-------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index ead39793985..c81f6df3fca 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -173,6 +173,10 @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
* * tininess-before-rounding
* * 2-input NaN propagation prefers SNaN over QNaN, and then
* operand A over operand B (see FPProcessNaNs() pseudocode)
+ * * 3-input NaN propagation prefers SNaN over QNaN, and then
+ * operand C over A over B (see FPProcessNaNs3() pseudocode,
+ * but note that for QEMU muladd is a * b + c, whereas for
+ * the pseudocode function the arguments are in the order c, a, b.
* * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
* and the input NaN if it is signalling
*/
@@ -180,6 +184,7 @@ static void arm_set_default_fp_behaviours(float_status *s)
{
set_float_detect_tininess(float_tininess_before_rounding, s);
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, s);
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index d7c0c90ea65..9b5243c9529 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -502,13 +502,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
if (rule == float_3nan_prop_none) {
-#if defined(TARGET_ARM)
- /*
- * This looks different from the ARM ARM pseudocode, because the ARM ARM
- * puts the operands to a fused mac operation (a*b)+c in the order c,a,b
- */
- rule = float_3nan_prop_s_cab;
-#elif defined(TARGET_MIPS)
+#if defined(TARGET_MIPS)
if (snan_bit_is_one(status)) {
rule = float_3nan_prop_s_abc;
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 17/25] target/loongarch: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (15 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:52 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
` (7 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for loongarch, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/loongarch/tcg/fpu_helper.c | 1 +
fpu/softfloat-specialize.c.inc | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
index 6a2c4b5b1db..37a48599366 100644
--- a/target/loongarch/tcg/fpu_helper.c
+++ b/target/loongarch/tcg/fpu_helper.c
@@ -37,6 +37,7 @@ void restore_fp_status(CPULoongArchState *env)
* case sets InvalidOp and returns the input value 'c'
*/
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status);
}
int ieee_ex_to_loongarch(int xcpt)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 9b5243c9529..32edb493776 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -508,8 +508,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
rule = float_3nan_prop_s_cab;
}
-#elif defined(TARGET_LOONGARCH64)
- rule = float_3nan_prop_s_cab;
#elif defined(TARGET_PPC)
/*
* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 18/25] target/ppc: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (16 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
` (6 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for PPC, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/ppc/cpu_init.c | 8 ++++++++
fpu/softfloat-specialize.c.inc | 6 ------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index f18908a643a..eb9d7b13701 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7270,6 +7270,14 @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
*/
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status);
+ /*
+ * NaN propagation for fused multiply-add:
+ * if fRA is a NaN return it; otherwise if fRB is a NaN return it;
+ * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
+ * whereas QEMU labels the operands as (a * b) + c.
+ */
+ set_float_3nan_prop_rule(float_3nan_prop_acb, &env->fp_status);
+ set_float_3nan_prop_rule(float_3nan_prop_acb, &env->vec_status);
/*
* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
* to return an input NaN if we have one (ie c) rather than generating
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 32edb493776..d89ef62b38a 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -508,12 +508,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
rule = float_3nan_prop_s_cab;
}
-#elif defined(TARGET_PPC)
- /*
- * If fRA is a NaN return it; otherwise if fRB is a NaN return it;
- * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
- */
- rule = float_3nan_prop_acb;
#elif defined(TARGET_S390X)
rule = float_3nan_prop_s_abc;
#elif defined(TARGET_SPARC)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 19/25] target/s390x: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (17 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
` (5 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for s390x, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/s390x/cpu.c | 1 +
fpu/softfloat-specialize.c.inc | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index d5941b5b9df..e74055bad79 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -206,6 +206,7 @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
set_float_detect_tininess(float_tininess_before_rounding,
&env->fpu_status);
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status);
+ set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status);
set_float_infzeronan_rule(float_infzeronan_dnan_always,
&env->fpu_status);
/* fall through */
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index d89ef62b38a..31b23ddb9bb 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -508,8 +508,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
rule = float_3nan_prop_s_cab;
}
-#elif defined(TARGET_S390X)
- rule = float_3nan_prop_s_abc;
#elif defined(TARGET_SPARC)
rule = float_3nan_prop_s_cba;
#elif defined(TARGET_XTENSA)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 20/25] target/sparc: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (18 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
` (4 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for SPARC, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/sparc/cpu.c | 2 ++
fpu/softfloat-specialize.c.inc | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 61f2d3fbf23..0f2997a85e6 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -814,6 +814,8 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
* the CPU state struct so it won't get zeroed on reset.
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
+ /* For fused-multiply add, prefer SNaN over QNaN, then C->B->A */
+ set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status);
/* For inf * 0 + NaN, return the input NaN */
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 31b23ddb9bb..565790b1834 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -508,8 +508,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
rule = float_3nan_prop_s_cab;
}
-#elif defined(TARGET_SPARC)
- rule = float_3nan_prop_s_cba;
#elif defined(TARGET_XTENSA)
if (status->use_first_nan) {
rule = float_3nan_prop_abc;
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 21/25] target/mips: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (19 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:54 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
` (3 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for Arm, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/mips/fpu_helper.h | 4 ++++
target/mips/msa.c | 3 +++
fpu/softfloat-specialize.c.inc | 8 +-------
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
index be66f2f813a..8ca0ca7ea39 100644
--- a/target/mips/fpu_helper.h
+++ b/target/mips/fpu_helper.h
@@ -29,6 +29,7 @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
{
bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
FloatInfZeroNaNRule izn_rule;
+ Float3NaNPropRule nan3_rule;
/*
* With nan2008, SNaNs are silenced in the usual way.
@@ -44,6 +45,9 @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
*/
izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always;
set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
+ nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc;
+ set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status);
+
}
static inline void restore_fp_status(CPUMIPSState *env)
diff --git a/target/mips/msa.c b/target/mips/msa.c
index cc152db27f9..93a9a87d76d 100644
--- a/target/mips/msa.c
+++ b/target/mips/msa.c
@@ -66,6 +66,9 @@ void msa_reset(CPUMIPSState *env)
set_float_2nan_prop_rule(float_2nan_prop_s_ab,
&env->active_tc.msa_fp_status);
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab,
+ &env->active_tc.msa_fp_status);
+
/* clear float_status exception flags */
set_float_exception_flags(0, &env->active_tc.msa_fp_status);
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 565790b1834..2d029de7baa 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -502,13 +502,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
if (rule == float_3nan_prop_none) {
-#if defined(TARGET_MIPS)
- if (snan_bit_is_one(status)) {
- rule = float_3nan_prop_s_abc;
- } else {
- rule = float_3nan_prop_s_cab;
- }
-#elif defined(TARGET_XTENSA)
+#if defined(TARGET_XTENSA)
if (status->use_first_nan) {
rule = float_3nan_prop_abc;
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 22/25] target/xtensa: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (20 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:55 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
` (2 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for xtensa, and remove the
ifdef from pickNaNMulAdd().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/xtensa/fpu_helper.c | 2 ++
fpu/softfloat-specialize.c.inc | 8 --------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c
index f2d212d05df..4b1b021d824 100644
--- a/target/xtensa/fpu_helper.c
+++ b/target/xtensa/fpu_helper.c
@@ -62,6 +62,8 @@ void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
set_use_first_nan(use_first, &env->fp_status);
set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba,
&env->fp_status);
+ set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba,
+ &env->fp_status);
}
void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v)
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 2d029de7baa..60de68012e1 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -502,15 +502,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
if (rule == float_3nan_prop_none) {
-#if defined(TARGET_XTENSA)
- if (status->use_first_nan) {
- rule = float_3nan_prop_abc;
- } else {
- rule = float_3nan_prop_cba;
- }
-#else
rule = float_3nan_prop_abc;
-#endif
}
switch (rule) {
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 23/25] target/i386: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (21 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:56 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for i386. We had no
i386-specific behaviour in the old ifdef ladder, so we were using the
default "prefer a then b then c" fallback. This is very likely wrong
for i386, but in this refactoring we don't want to make a behaviour
change, so we leave a TODO note.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/i386/tcg/fpu_helper.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index e9de084a96d..b62719dead1 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -180,6 +180,8 @@ void cpu_init_fp_statuses(CPUX86State *env)
* against the manual.
*/
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
+ /* Similarly the NaN propagation rule is likely wrong. */
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status);
}
static inline uint8_t save_exception_flags(CPUX86State *env)
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 24/25] target/hppa: Set Float3NaNPropRule explicitly
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (22 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:57 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
Set the Float3NaNPropRule explicitly for HPPA, and remove the
ifdef from pickNaNMulAdd().
HPPA is the only target that was using the default branch of the
ifdef ladder (other targets either do not use muladd or set
default_nan_mode), so we can remove the ifdef fallback entirely now
(allowing the "rule not set" case to fall into the default of the
switch statement and assert).
We add a TODO note that the HPPA rule is probably wrong; this is
not a behavioural change for this refactoring.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/hppa/fpu_helper.c | 8 ++++++++
fpu/softfloat-specialize.c.inc | 7 +------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
index 393cae33bf9..69c4ce37835 100644
--- a/target/hppa/fpu_helper.c
+++ b/target/hppa/fpu_helper.c
@@ -55,6 +55,14 @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
* HPPA does note implement a CPU reset method at all...
*/
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
+ /*
+ * TODO: The HPPA architecture reference only documents its NaN
+ * propagation rule for 2-operand operations. Testing on real hardware
+ * might be necessary to confirm whether this order for muladd is correct.
+ * Not preferring the SNaN is almost certainly incorrect as it diverges
+ * from the documented rules for 2-operand operations.
+ */
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status);
/* For inf * 0 + NaN, return the input NaN */
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
}
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
index 60de68012e1..353b524d2de 100644
--- a/fpu/softfloat-specialize.c.inc
+++ b/fpu/softfloat-specialize.c.inc
@@ -475,7 +475,6 @@ 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)
{
- Float3NaNPropRule rule = status->float_3nan_prop_rule;
/*
* We guarantee not to require the target to tell us how to
* pick a NaN if we're always returning the default NaN.
@@ -501,11 +500,7 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
}
}
- if (rule == float_3nan_prop_none) {
- rule = float_3nan_prop_abc;
- }
-
- switch (rule) {
+ switch (status->float_3nan_prop_rule) {
case float_3nan_prop_s_abc:
if (is_snan(a_cls)) {
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
` (23 preceding siblings ...)
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
@ 2024-11-28 10:43 ` Peter Maydell
2024-11-28 17:58 ` Richard Henderson
24 siblings, 1 reply; 51+ messages in thread
From: Peter Maydell @ 2024-11-28 10:43 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-ppc, qemu-s390x, Alex Bennée,
Richard Henderson, Paolo Bonzini, Eduardo Habkost, Song Gao,
Philippe Mathieu-Daudé, Jiaxun Yang, Aleksandar Rikalo,
Nicholas Piggin, Daniel Henrique Barboza, David Hildenbrand,
Ilya Leoshkevich, Thomas Huth, Mark Cave-Ayland, Artyom Tarasenko,
Max Filippov
The use_first_nan field in float_status was an xtensa-specific way to
select at runtime from two different NaN propagation rules. Now that
xtensa is using the target-agnostic NaN propagation rule selection
that we've just added, we can remove use_first_nan, because there is
no longer any code that reads it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/fpu/softfloat-helpers.h | 5 -----
include/fpu/softfloat-types.h | 1 -
target/xtensa/fpu_helper.c | 1 -
3 files changed, 7 deletions(-)
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
index cf06b4e16bf..10a6763532c 100644
--- a/include/fpu/softfloat-helpers.h
+++ b/include/fpu/softfloat-helpers.h
@@ -113,11 +113,6 @@ static inline void set_snan_bit_is_one(bool val, float_status *status)
status->snan_bit_is_one = val;
}
-static inline void set_use_first_nan(bool val, float_status *status)
-{
- status->use_first_nan = val;
-}
-
static inline void set_no_signaling_nans(bool val, float_status *status)
{
status->no_signaling_nans = val;
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 79220f8c67f..e2db92c72fa 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -291,7 +291,6 @@ typedef struct float_status {
* softfloat-specialize.inc.c)
*/
bool snan_bit_is_one;
- bool use_first_nan;
bool no_signaling_nans;
/* should overflowed results subtract re_bias to its exponent? */
bool rebias_overflow;
diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c
index 4b1b021d824..53fc7cfd2af 100644
--- a/target/xtensa/fpu_helper.c
+++ b/target/xtensa/fpu_helper.c
@@ -59,7 +59,6 @@ static const struct {
void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
{
- set_use_first_nan(use_first, &env->fp_status);
set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba,
&env->fp_status);
set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba,
--
2.34.1
^ permalink raw reply related [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
@ 2024-11-28 13:07 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:07 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> For IEEE fused multiply-add, the (0 * inf) + NaN case should raise
> Invalid for the multiplication of 0 by infinity. Currently we handle
> this in the per-architecture ifdef ladder in pickNaNMulAdd().
> However, since this isn't really architecture specific we can hoist
> it up to the generic code.
>
> For the cases where the infzero test in pickNaNMulAdd was
> returning 2, we can delete the check entirely and allow the
> code to fall into the normal pick-a-NaN handling, because this
> will return 2 anyway (input 'c' being the only NaN in this case).
> For the cases where infzero was returning 3 to indicate "return
> the default NaN", we must retain that "return 3".
>
> For Arm, this looks like it might be a behaviour change because we
> used to set float_flag_invalid | float_flag_invalid_imz only if C is
> a quiet NaN. However, it is not, because Arm target code never looks
> at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we
> already raised float_flag_invalid via the "abc_mask &
> float_cmask_snan" check in pick_nan_muladd.
>
> For any target architecture using the "default implementation" at the
> bottom of the ifdef, this is a behaviour change but will be fixing a
> bug (where we failed to raise the Invalid exception for (0 * inf +
> QNaN). The architectures using the default case are:
> * hppa
> * sh4
> * tricore
>
> The Tricore and SH4 CPU architecture manuals are clear that this
> should have raised Invalid; HPPA is a bit vaguer but still seems
> clear enough.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> fpu/softfloat-parts.c.inc | 13 +++++++------
> fpu/softfloat-specialize.c.inc | 29 +----------------------------
> 2 files changed, 8 insertions(+), 34 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
@ 2024-11-28 13:09 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:09 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> 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>
> ---
> fpu/softfloat-parts.c.inc | 8 ++++++--
> fpu/softfloat-specialize.c.inc | 9 +++++++--
> 2 files changed, 13 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
@ 2024-11-28 13:26 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:26 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> +/*
> + * Rule for result of fused multiply-add 0 * Inf + NaN.
> + * This must be a NaN, but implementations differ on whether this
> + * is the input NaN or the default NaN.
> + *
> + * You don't need to set this if default_nan_mode is enabled.
> + * When not in default-NaN mode, it is an error for the target
> + * not to set the rule in float_status if it uses muladd, and we
> + * will assert if we need to handle an input NaN and no rule was
> + * selected.
> + */
> +typedef enum __attribute__((__packed__)) {
> + /* No propagation rule specified */
> + float_infzeronan_none = 0,
> + /* Result is never the default NaN (so always the input NaN) */
> + float_infzeronan_dnan_never = 0,
Both 0?
Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
@ 2024-11-28 13:26 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:26 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Explicitly set a rule in the softfloat tests for the inf-zero-nan
> muladd special case. In meson.build we put -DTARGET_ARM in fpcflags,
> and so we should select here the Arm rule of
> float_infzeronan_dnan_if_qnan.
> ---
> tests/fp/fp-bench.c | 5 +++++
> tests/fp/fp-test.c | 5 +++++
> 2 files changed, 10 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
@ 2024-11-28 13:27 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:27 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the Arm target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/arm/cpu.c | 3 +++
> fpu/softfloat-specialize.c.inc | 8 +-------
> 2 files changed, 4 insertions(+), 7 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 06/25] target/s390: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
@ 2024-11-28 13:28 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:28 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for s390, so we
> can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/s390x/cpu.c | 2 ++
> fpu/softfloat-specialize.c.inc | 2 --
> 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 07/25] target/ppc: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
@ 2024-11-28 13:28 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:28 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the PPC target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/ppc/cpu_init.c | 7 +++++++
> fpu/softfloat-specialize.c.inc | 7 +------
> 2 files changed, 8 insertions(+), 6 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 08/25] target/mips: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
@ 2024-11-28 13:29 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:29 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the MIPS target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/mips/fpu_helper.h | 9 +++++++++
> target/mips/msa.c | 4 ++++
> fpu/softfloat-specialize.c.inc | 16 +---------------
> 3 files changed, 14 insertions(+), 15 deletions(-)
Lovely.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 09/25] target/sparc: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
@ 2024-11-28 13:30 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:30 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the SPARC target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/sparc/cpu.c | 2 ++
> fpu/softfloat-specialize.c.inc | 3 +--
> 2 files changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 10/25] target/xtensa: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
@ 2024-11-28 13:30 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 13:30 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the xtensa target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/xtensa/cpu.c | 2 ++
> fpu/softfloat-specialize.c.inc | 2 +-
> 2 files changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 11/25] target/x86: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
@ 2024-11-28 14:04 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 14:04 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the x86 target.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/i386/tcg/fpu_helper.c | 7 +++++++
> fpu/softfloat-specialize.c.inc | 2 +-
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
> index 53b49bb2977..e9de084a96d 100644
> --- a/target/i386/tcg/fpu_helper.c
> +++ b/target/i386/tcg/fpu_helper.c
> @@ -173,6 +173,13 @@ void cpu_init_fp_statuses(CPUX86State *env)
> */
> set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status);
> set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status);
> + /*
> + * Only SSE has multiply-add instructions.
> + * TODO: this might be wrong, as we never implemented any x86-specific
> + * handling for the NaN case for multiply-add. This needs to be checked
> + * against the manual.
> + */
> + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
This is correct.
Section 14.5.2 Fused-Multiply-ADD (FMA) Numeric Behavior has table 14-17 FMA Numeric
Behavior. It boils down to selecting the first NaN from A * B + C. Row 3 specifically
documents C as the result for A and B both in {0, Finite, Inf}, which includes the infzero
case.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 12/25] target/loongarch: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
@ 2024-11-28 14:09 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 14:09 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the loongarch target.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/loongarch/tcg/fpu_helper.c | 5 +++++
> fpu/softfloat-specialize.c.inc | 7 +------
> 2 files changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 13/25] target/hppa: Set FloatInfZeroNaNRule explicitly
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
@ 2024-11-28 14:10 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 14:10 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> Set the FloatInfZeroNaNRule explicitly for the HPPA target,
> so we can remove the ifdef from pickNaNMulAdd().
>
> As this is the last target to be converted to explicitly setting
> the rule, we can remove the fallback code in pickNaNMulAdd()
> entirely.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/hppa/fpu_helper.c | 2 ++
> fpu/softfloat-specialize.c.inc | 13 +------------
> 2 files changed, 3 insertions(+), 12 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
@ 2024-11-28 17:49 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:49 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:42, Peter Maydell wrote:
> +/*
> + * 3-input NaN propagation rule, for fused multiply-add. Individual
> + * architectures have different rules for which input NaN is
> + * propagated to the output when there is more than one NaN on the
> + * input.
> + *
> + * If default_nan_mode is enabled then it is valid not to set a NaN
> + * propagation rule, because the softfloat code guarantees not to try
> + * to pick a NaN to propagate in default NaN mode. When not in
> + * default-NaN mode, it is an error for the target not to set the rule
> + * in float_status if it uses a muladd, and we will assert if we need
> + * to handle an input NaN and no rule was selected.
> + *
> + * For QEMU, the multiply-add operation is A * B + C.
> + *
> + * NB: we don't list all 12 possibilities here or implement them
> + * in pickNaNMulAdd; if your architecture needs one of the missing
> + * combinations you should add it.
> + */
> +typedef enum __attribute__((__packed__)) {
> + /* No propagation rule specified */
> + float_3nan_prop_none = 0,
> + /* Prefer SNaN over QNaN, then operand A over B over C */
> + float_3nan_prop_s_abc,
> + /* Prefer SNaN over QNaN, then operand C over A over B */
> + float_3nan_prop_s_cab,
> + /* Prefer SNaN over QNaN, then operand C over B over A */
> + float_3nan_prop_s_cba,
> + /* Prefer A over B over C regardless of SNaN vs QNaN */
> + float_3nan_prop_abc,
> + /* Prefer A over C over B regardless of SNaN vs QNaN */
> + float_3nan_prop_acb,
> + /* Prefer C over B over A regardless of SNaN vs QNaN */
> + float_3nan_prop_cba,
> +} Float3NaNPropRule;
Oof. I was imagining a bit more data driven solution, rather than explicitly enumerating.
For instance:
FIELD(3NAN, 1ST, 0, 2)
FIELD(3NAN, 2ND, 2, 2)
FIELD(3NAN, 3RD, 4, 2)
FIELD(3NAN, SNAN, 6, 1)
float_3nan_prop_abc = (0 << R_3NAN_1ST_SHIFT)
| (1 << R_3NAN_2ND_SHIFT)
| (2 << R_3NAN_3RD_SHIFT),
float_3nan_prop_s_abc = float_3nan_prop_abc | R_3NAN_SNAN_MASK,
FloatClass cls[3] = { a_cls, b_cls, c_cls };
if (rule & R_3NAN_SNAN_MASK && abc_mask & float_cmask_snan) {
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;
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
@ 2024-11-28 17:49 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:49 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Explicitly set a rule in the softfloat tests for propagating NaNs in
> the muladd case. In meson.build we put -DTARGET_ARM in fpcflags, and
> so we should select here the Arm rule of float_3nan_prop_s_cab.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> tests/fp/fp-bench.c | 1 +
> tests/fp/fp-test.c | 1 +
> 2 files changed, 2 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
@ 2024-11-28 17:51 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:51 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for Arm, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/arm/cpu.c | 5 +++++
> fpu/softfloat-specialize.c.inc | 8 +-------
> 2 files changed, 6 insertions(+), 7 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 17/25] target/loongarch: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
@ 2024-11-28 17:52 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:52 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for loongarch, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/loongarch/tcg/fpu_helper.c | 1 +
> fpu/softfloat-specialize.c.inc | 2 --
> 2 files changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 18/25] target/ppc: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
@ 2024-11-28 17:53 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:53 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for PPC, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/ppc/cpu_init.c | 8 ++++++++
> fpu/softfloat-specialize.c.inc | 6 ------
> 2 files changed, 8 insertions(+), 6 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 19/25] target/s390x: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
@ 2024-11-28 17:53 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:53 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for s390x, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/s390x/cpu.c | 1 +
> fpu/softfloat-specialize.c.inc | 2 --
> 2 files changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 20/25] target/sparc: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
@ 2024-11-28 17:53 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:53 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for SPARC, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/sparc/cpu.c | 2 ++
> fpu/softfloat-specialize.c.inc | 2 --
> 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 21/25] target/mips: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
@ 2024-11-28 17:54 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:54 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for Arm, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/mips/fpu_helper.h | 4 ++++
> target/mips/msa.c | 3 +++
> fpu/softfloat-specialize.c.inc | 8 +-------
> 3 files changed, 8 insertions(+), 7 deletions(-)
Yay.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 22/25] target/xtensa: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
@ 2024-11-28 17:55 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:55 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for xtensa, and remove the
> ifdef from pickNaNMulAdd().
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/xtensa/fpu_helper.c | 2 ++
> fpu/softfloat-specialize.c.inc | 8 --------
> 2 files changed, 2 insertions(+), 8 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 23/25] target/i386: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
@ 2024-11-28 17:56 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:56 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for i386. We had no
> i386-specific behaviour in the old ifdef ladder, so we were using the
> default "prefer a then b then c" fallback. This is very likely wrong
> for i386, but in this refactoring we don't want to make a behaviour
> change, so we leave a TODO note.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/i386/tcg/fpu_helper.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
> index e9de084a96d..b62719dead1 100644
> --- a/target/i386/tcg/fpu_helper.c
> +++ b/target/i386/tcg/fpu_helper.c
> @@ -180,6 +180,8 @@ void cpu_init_fp_statuses(CPUX86State *env)
> * against the manual.
> */
> set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
> + /* Similarly the NaN propagation rule is likely wrong. */
> + set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status);
Per my response to patch 11, this is correct.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 24/25] target/hppa: Set Float3NaNPropRule explicitly
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
@ 2024-11-28 17:57 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:57 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> Set the Float3NaNPropRule explicitly for HPPA, and remove the
> ifdef from pickNaNMulAdd().
>
> HPPA is the only target that was using the default branch of the
> ifdef ladder (other targets either do not use muladd or set
> default_nan_mode), so we can remove the ifdef fallback entirely now
> (allowing the "rule not set" case to fall into the default of the
> switch statement and assert).
>
> We add a TODO note that the HPPA rule is probably wrong; this is
> not a behavioural change for this refactoring.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> target/hppa/fpu_helper.c | 8 ++++++++
> fpu/softfloat-specialize.c.inc | 7 +------
> 2 files changed, 9 insertions(+), 6 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
@ 2024-11-28 17:58 ` Richard Henderson
0 siblings, 0 replies; 51+ messages in thread
From: Richard Henderson @ 2024-11-28 17:58 UTC (permalink / raw)
To: Peter Maydell, qemu-devel
On 11/28/24 04:43, Peter Maydell wrote:
> The use_first_nan field in float_status was an xtensa-specific way to
> select at runtime from two different NaN propagation rules. Now that
> xtensa is using the target-agnostic NaN propagation rule selection
> that we've just added, we can remove use_first_nan, because there is
> no longer any code that reads it.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> include/fpu/softfloat-helpers.h | 5 -----
> include/fpu/softfloat-types.h | 1 -
> target/xtensa/fpu_helper.c | 1 -
> 3 files changed, 7 deletions(-)
Yay!
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 51+ messages in thread
end of thread, other threads:[~2024-11-28 17:58 UTC | newest]
Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
2024-11-28 13:07 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
2024-11-28 13:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
2024-11-28 13:27 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
2024-11-28 13:29 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
2024-11-28 14:04 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
2024-11-28 14:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
2024-11-28 14:10 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
2024-11-28 17:49 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
2024-11-28 17:49 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
2024-11-28 17:51 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
2024-11-28 17:52 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
2024-11-28 17:54 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
2024-11-28 17:55 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
2024-11-28 17:56 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
2024-11-28 17:57 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
2024-11-28 17:58 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).