Re: [PATCH 14/18] fpu: Use {get,set}_flush_inputs_to_zero everywhere

2026-05-08 Thread Philippe Mathieu-Daudé

On 8/5/26 00:17, Richard Henderson wrote:

Signed-off-by: Richard Henderson 
---
  fpu/softfloat.c   | 14 +++---
  target/alpha/fpu_helper.c |  2 +-
  target/alpha/helper.c |  3 ++-
  tests/fp/fp-bench.c   |  2 +-
  fpu/softfloat-parts.c.inc |  2 +-
  5 files changed, 12 insertions(+), 11 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 



[PATCH 14/18] fpu: Use {get,set}_flush_inputs_to_zero everywhere

2026-05-07 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 fpu/softfloat.c   | 14 +++---
 target/alpha/fpu_helper.c |  2 +-
 target/alpha/helper.c |  3 ++-
 tests/fp/fp-bench.c   |  2 +-
 fpu/softfloat-parts.c.inc |  2 +-
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 98cb0623ac..92918df89a 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);  \
@@ -4752,7 +4752,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)) {
@@ -4764,7 +4764,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)) {
@@ -4776,7 +4776,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)) {
@@ -4788,7 +4788,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 < 0x1full)
-&& !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 179dc2dc7a..b7eb13d0d2 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;
+