Commit 6967da87c6 for qemu.org
commit 6967da87c63009b00b166012e1cf2ec79cbef1ae
Author: Richard Henderson <richard.henderson@linaro.org>
Date: Fri May 1 20:15:49 2026 +1000
fpu: Use {get,set}_flush_inputs_to_zero everywhere
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 0e5311b50f..6a67e6af2c 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -218,7 +218,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status,
if (unlikely(p->exp == 0)) {
if (likely(fracN(eqz)(p))) {
p->cls = float_class_zero;
- } else if (status->flush_inputs_to_zero) {
+ } else if (get_flush_inputs_to_zero(status)) {
float_raise(float_flag_input_denormal_flushed, status);
p->cls = float_class_zero;
fracN(clear)(p);
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index dcae5b3be2..be6b02d866 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -141,7 +141,7 @@ GEN_INPUT_FLUSH__NOCHECK(float64_input_flush__nocheck, float64)
#define GEN_INPUT_FLUSH1(name, soft_t) \
static inline void name(soft_t *a, float_status *s) \
{ \
- if (likely(!s->flush_inputs_to_zero)) { \
+ if (likely(!get_flush_inputs_to_zero(s))) { \
return; \
} \
soft_t ## _input_flush__nocheck(a, s); \
@@ -154,7 +154,7 @@ GEN_INPUT_FLUSH1(float64_input_flush1, float64)
#define GEN_INPUT_FLUSH2(name, soft_t) \
static inline void name(soft_t *a, soft_t *b, float_status *s) \
{ \
- if (likely(!s->flush_inputs_to_zero)) { \
+ if (likely(!get_flush_inputs_to_zero(s))) { \
return; \
} \
soft_t ## _input_flush__nocheck(a, s); \
@@ -168,7 +168,7 @@ GEN_INPUT_FLUSH2(float64_input_flush2, float64)
#define GEN_INPUT_FLUSH3(name, soft_t) \
static inline void name(soft_t *a, soft_t *b, soft_t *c, float_status *s) \
{ \
- if (likely(!s->flush_inputs_to_zero)) { \
+ if (likely(!get_flush_inputs_to_zero(s))) { \
return; \
} \
soft_t ## _input_flush__nocheck(a, s); \
@@ -4764,7 +4764,7 @@ static bool parts_squash_denormal(FloatParts64 p, float_status *status)
float16 float16_squash_input_denormal(float16 a, float_status *status)
{
- if (status->flush_inputs_to_zero) {
+ if (get_flush_inputs_to_zero(status)) {
FloatParts64 p = unpack_raw64(&float16_params, a);
if (parts_squash_denormal(p, status)) {
@@ -4776,7 +4776,7 @@ float16 float16_squash_input_denormal(float16 a, float_status *status)
float32 float32_squash_input_denormal(float32 a, float_status *status)
{
- if (status->flush_inputs_to_zero) {
+ if (get_flush_inputs_to_zero(status)) {
FloatParts64 p = unpack_raw64(&float32_params, a);
if (parts_squash_denormal(p, status)) {
@@ -4788,7 +4788,7 @@ float32 float32_squash_input_denormal(float32 a, float_status *status)
float64 float64_squash_input_denormal(float64 a, float_status *status)
{
- if (status->flush_inputs_to_zero) {
+ if (get_flush_inputs_to_zero(status)) {
FloatParts64 p = unpack_raw64(&float64_params, a);
if (parts_squash_denormal(p, status)) {
@@ -4800,7 +4800,7 @@ float64 float64_squash_input_denormal(float64 a, float_status *status)
bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status)
{
- if (status->flush_inputs_to_zero) {
+ if (get_flush_inputs_to_zero(status)) {
FloatParts64 p = unpack_raw64(&bfloat16_params, a);
if (parts_squash_denormal(p, status)) {
diff --git a/target/alpha/fpu_helper.c b/target/alpha/fpu_helper.c
index 0ced53c54e..5b7e4bd5eb 100644
--- a/target/alpha/fpu_helper.c
+++ b/target/alpha/fpu_helper.c
@@ -151,7 +151,7 @@ void helper_ieee_input_cmp(CPUAlphaState *env, uint64_t val)
void helper_ieee_input_s(CPUAlphaState *env, uint64_t val)
{
if (unlikely(2 * val - 1 < 0x1fffffffffffffull)
- && !env->fp_status.flush_inputs_to_zero) {
+ && !get_flush_inputs_to_zero(&env->fp_status)) {
arith_excp(env, GETPC(), EXC_M_INV | EXC_M_SWC, 0);
}
}
diff --git a/target/alpha/helper.c b/target/alpha/helper.c
index 33fed0c746..2abf07c191 100644
--- a/target/alpha/helper.c
+++ b/target/alpha/helper.c
@@ -24,6 +24,7 @@
#include "exec/page-protection.h"
#include "exec/target_page.h"
#include "fpu/softfloat-types.h"
+#include "fpu/softfloat-helpers.h"
#include "exec/helper-proto.h"
#include "qemu/qemu-print.h"
#include "system/memory.h"
@@ -80,7 +81,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)
env->fpcr_exc_enable = ~t & FPCR_STATUS_MASK;
env->fpcr_dyn_round = rm_map[(fpcr & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT];
- env->fp_status.flush_inputs_to_zero = (fpcr & FPCR_DNZ) != 0;
+ set_flush_inputs_to_zero(fpcr & FPCR_DNZ, &env->fp_status);
t = (fpcr & FPCR_UNFD) && (fpcr & FPCR_UNDZ);
#ifdef CONFIG_USER_ONLY
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
index ccc561b578..c53d6e4b34 100644
--- a/tests/fp/fp-bench.c
+++ b/tests/fp/fp-bench.c
@@ -672,7 +672,7 @@ static void parse_args(int argc, char *argv[])
tester = val;
break;
case 'z':
- soft_status.flush_inputs_to_zero = 1;
+ set_flush_inputs_to_zero(true, &soft_status);
break;
case 'Z':
set_flush_to_zero(true, &soft_status);