target/sparc: Explicitly set 2-NaN propagation rule

Set the NaN propagation rule explicitly in the float_status
words we use.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241025141254.2141506-13-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2024-11-05 10:09:55 +00:00
parent 65c1c039cd
commit 4482f32dcd
3 changed files with 18 additions and 6 deletions

View File

@ -404,11 +404,9 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
|| defined(TARGET_RISCV) || defined(TARGET_SH4) \ || defined(TARGET_RISCV) || defined(TARGET_SH4) \
|| defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \ || defined(TARGET_TRICORE) || defined(TARGET_ARM) || defined(TARGET_MIPS) \
|| defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \ || defined(TARGET_LOONGARCH64) || defined(TARGET_HPPA) \
|| defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) || defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_M68K) \
|| defined(TARGET_SPARC)
g_assert_not_reached(); g_assert_not_reached();
#elif defined(TARGET_SPARC)
/* Prefer SNaN over QNaN, order B then A. */
rule = float_2nan_prop_s_ba;
#elif defined(TARGET_XTENSA) #elif defined(TARGET_XTENSA)
/* /*
* Xtensa has two NaN propagation modes. * Xtensa has two NaN propagation modes.

View File

@ -26,6 +26,7 @@
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "qapi/visitor.h" #include "qapi/visitor.h"
#include "tcg/tcg.h" #include "tcg/tcg.h"
#include "fpu/softfloat.h"
//#define DEBUG_FEATURES //#define DEBUG_FEATURES
@ -807,6 +808,13 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
env->version |= env->def.nwindows - 1; env->version |= env->def.nwindows - 1;
#endif #endif
/*
* Prefer SNaN over QNaN, order B then A. It's OK to do this in realize
* rather than reset, because fp_status is after 'end_reset_fields' in
* 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);
cpu_exec_realizefn(cs, &local_err); cpu_exec_realizefn(cs, &local_err);
if (local_err != NULL) { if (local_err != NULL) {
error_propagate(errp, local_err); error_propagate(errp, local_err);

View File

@ -497,7 +497,10 @@ uint32_t helper_flcmps(float32 src1, float32 src2)
* Perform the comparison with a dummy fp environment. * Perform the comparison with a dummy fp environment.
*/ */
float_status discard = { }; float_status discard = { };
FloatRelation r = float32_compare_quiet(src1, src2, &discard); FloatRelation r;
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
r = float32_compare_quiet(src1, src2, &discard);
switch (r) { switch (r) {
case float_relation_equal: case float_relation_equal:
@ -518,7 +521,10 @@ uint32_t helper_flcmps(float32 src1, float32 src2)
uint32_t helper_flcmpd(float64 src1, float64 src2) uint32_t helper_flcmpd(float64 src1, float64 src2)
{ {
float_status discard = { }; float_status discard = { };
FloatRelation r = float64_compare_quiet(src1, src2, &discard); FloatRelation r;
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
r = float64_compare_quiet(src1, src2, &discard);
switch (r) { switch (r) {
case float_relation_equal: case float_relation_equal: