qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/8] target/loongarch: Fix float_convd/float_convs test faili


From: Richard Henderson
Subject: Re: [PATCH 3/8] target/loongarch: Fix float_convd/float_convs test failing
Date: Tue, 19 Jul 2022 12:56:59 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 7/19/22 12:42, Richard Henderson wrote:
On 7/16/22 14:24, Song Gao wrote:
We should result zero when exception is invalid and operation is nan

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
  target/loongarch/fpu_helper.c | 143 +++++++++++++++++++---------------
  1 file changed, 80 insertions(+), 63 deletions(-)

diff --git a/target/loongarch/fpu_helper.c b/target/loongarch/fpu_helper.c
index 3d0cb8dd0d..bd76529219 100644
--- a/target/loongarch/fpu_helper.c
+++ b/target/loongarch/fpu_helper.c
@@ -13,9 +13,6 @@
  #include "fpu/softfloat.h"
  #include "internals.h"
-#define FLOAT_TO_INT32_OVERFLOW 0x7fffffff
-#define FLOAT_TO_INT64_OVERFLOW 0x7fffffffffffffffULL
-
  static inline uint64_t nanbox_s(float32 fp)
  {
      return fp | MAKE_64BIT_MASK(32, 32);
@@ -544,9 +541,10 @@ uint64_t helper_ftintrm_l_d(CPULoongArchState *env, 
uint64_t fj)
      fd = float64_to_int64(fj, &env->fp_status);
      set_float_rounding_mode(old_mode, &env->fp_status);
-    if (get_float_exception_flags(&env->fp_status) &
-        (float_flag_invalid | float_flag_overflow)) {
-        fd = FLOAT_TO_INT64_OVERFLOW;
+    if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) {
+        if (float64_is_any_nan(fj)) {
+            fd = 0;
+        }

The check for invalid is sufficient, the check for nan should be redundant with 
that.

Whoops, the other way around -- sometimes we get invalid raised from Inf.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]