diff mbox series

[13/72] target/mips: Set set_default_nan_mode with set_snan_bit_is_one

Message ID 20210508014802.892561-14-richard.henderson@linaro.org
State Superseded
Headers show
Series Convert floatx80 and float128 to FloatParts | expand

Commit Message

Richard Henderson May 8, 2021, 1:47 a.m. UTC
This behavior is currently hard-coded in parts_silence_nan,
but setting this bit properly will allow this to be cleaned up.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/mips/fpu_helper.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

-- 
2.25.1

Comments

Alex Bennée May 11, 2021, 9:37 a.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> This behavior is currently hard-coded in parts_silence_nan,

> but setting this bit properly will allow this to be cleaned up.

>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


-- 
Alex Bennée
David Hildenbrand May 11, 2021, 10:16 a.m. UTC | #2
On 08.05.21 03:47, Richard Henderson wrote:
> This behavior is currently hard-coded in parts_silence_nan,

> but setting this bit properly will allow this to be cleaned up.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>   target/mips/fpu_helper.h | 10 ++++++++--

>   1 file changed, 8 insertions(+), 2 deletions(-)

> 

> diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h

> index 1c2d6d35a7..ad1116e8c1 100644

> --- a/target/mips/fpu_helper.h

> +++ b/target/mips/fpu_helper.h

> @@ -27,8 +27,14 @@ static inline void restore_flush_mode(CPUMIPSState *env)

>   

>   static inline void restore_snan_bit_mode(CPUMIPSState *env)

>   {

> -    set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) == 0,

> -                        &env->active_fpu.fp_status);

> +    bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);

> +

> +    /*

> +     * With nan2008, SNaNs are silenced in the usual way.

> +     * Before that, SNaNs are not silenced; default nans are produced.

> +     */

> +    set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status);

> +    set_default_nan_mode(!nan2008, &env->active_fpu.fp_status);

>   }

>   

>   static inline void restore_fp_status(CPUMIPSState *env)

> 


Reviewed-by: David Hildenbrand <david@redhat.com>


-- 
Thanks,

David / dhildenb
diff mbox series

Patch

diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
index 1c2d6d35a7..ad1116e8c1 100644
--- a/target/mips/fpu_helper.h
+++ b/target/mips/fpu_helper.h
@@ -27,8 +27,14 @@  static inline void restore_flush_mode(CPUMIPSState *env)
 
 static inline void restore_snan_bit_mode(CPUMIPSState *env)
 {
-    set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) == 0,
-                        &env->active_fpu.fp_status);
+    bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
+
+    /*
+     * With nan2008, SNaNs are silenced in the usual way.
+     * Before that, SNaNs are not silenced; default nans are produced.
+     */
+    set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status);
+    set_default_nan_mode(!nan2008, &env->active_fpu.fp_status);
 }
 
 static inline void restore_fp_status(CPUMIPSState *env)