[PATCH 06/11] target/rx: Handle the FPSW.DN bit in helper_set_fpsw

Richard Henderson posted 11 patches 4 years, 8 months ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, "Alex Bennée" <alex.bennee@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Eduardo Habkost <ehabkost@redhat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
[PATCH 06/11] target/rx: Handle the FPSW.DN bit in helper_set_fpsw
Posted by Richard Henderson 4 years, 8 months ago
Both input and output denormals flush to zero when DN is set.

Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/rx/op_helper.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c
index ef904eb5f9..2139def3b2 100644
--- a/target/rx/op_helper.c
+++ b/target/rx/op_helper.c
@@ -127,13 +127,20 @@ void helper_set_fpsw(CPURXState *env, uint32_t val)
         float_round_down,
     };
     uint32_t fpsw = env->fpsw;
+    bool dn;
+
     fpsw |= 0x7fffff03;
     val &= ~0x80000000;
     fpsw &= val;
     FIELD_DP32(fpsw, FPSW, FS, FIELD_EX32(fpsw, FPSW, FLAGS) != 0);
     env->fpsw = fpsw;
-    set_float_rounding_mode(roundmode[FIELD_EX32(env->fpsw, FPSW, RM)],
+
+    set_float_rounding_mode(roundmode[FIELD_EX32(fpsw, FPSW, RM)],
                             &env->fp_status);
+
+    dn = FIELD_EX32(env->fpsw, FPSW, DN);
+    set_flush_to_zero(dn, &env->fp_status);
+    set_flush_inputs_to_zero(dn, &env->fp_status);
 }
 
 #define FLOATOP(op, func)                                           \
-- 
2.25.1


Re: [PATCH 06/11] target/rx: Handle the FPSW.DN bit in helper_set_fpsw
Posted by Yoshinori Sato 4 years, 8 months ago
On Thu, 27 May 2021 13:14:00 +0900,
Richard Henderson wrote:
> 
> Both input and output denormals flush to zero when DN is set.
> 
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewd-by: Yoshinori Sato <ysato@users.sourceforge.jp>

> ---
>  target/rx/op_helper.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c
> index ef904eb5f9..2139def3b2 100644
> --- a/target/rx/op_helper.c
> +++ b/target/rx/op_helper.c
> @@ -127,13 +127,20 @@ void helper_set_fpsw(CPURXState *env, uint32_t val)
>          float_round_down,
>      };
>      uint32_t fpsw = env->fpsw;
> +    bool dn;
> +
>      fpsw |= 0x7fffff03;
>      val &= ~0x80000000;
>      fpsw &= val;
>      FIELD_DP32(fpsw, FPSW, FS, FIELD_EX32(fpsw, FPSW, FLAGS) != 0);
>      env->fpsw = fpsw;
> -    set_float_rounding_mode(roundmode[FIELD_EX32(env->fpsw, FPSW, RM)],
> +
> +    set_float_rounding_mode(roundmode[FIELD_EX32(fpsw, FPSW, RM)],
>                              &env->fp_status);
> +
> +    dn = FIELD_EX32(env->fpsw, FPSW, DN);
> +    set_flush_to_zero(dn, &env->fp_status);
> +    set_flush_inputs_to_zero(dn, &env->fp_status);
>  }
>  
>  #define FLOATOP(op, func)                                           \
> -- 
> 2.25.1
> 
>