[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 032/102] target/ppc: Fix VXCVI return value
From: |
Cédric Le Goater |
Subject: |
[PULL 032/102] target/ppc: Fix VXCVI return value |
Date: |
Wed, 15 Dec 2021 18:02:47 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
We were returning nanval for any instance of invalid being set,
but that is an incorrect for VXCVI. This failure can be seen
in the float_convs tests.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211119160502.17432-14-richard.henderson@linaro.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
target/ppc/fpu_helper.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index be460cc74451..d471a0a1b89b 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -585,13 +585,20 @@ float64 helper_fdiv(CPUPPCState *env, float64 arg1,
float64 arg2)
return ret;
}
-static void float_invalid_cvt(CPUPPCState *env, int flags,
- bool set_fprc, uintptr_t retaddr)
-{
- float_invalid_op_vxcvi(env, set_fprc, retaddr);
+static uint64_t float_invalid_cvt(CPUPPCState *env, int flags,
+ uint64_t ret, uint64_t ret_nan,
+ bool set_fprc, uintptr_t retaddr)
+{
+ /*
+ * VXCVI is different from most in that it sets two exception bits,
+ * VXCVI and VXSNAN for an SNaN input.
+ */
if (flags & float_flag_invalid_snan) {
- float_invalid_op_vxsnan(env, retaddr);
+ env->fpscr |= FP_VXSNAN;
}
+ float_invalid_op_vxcvi(env, set_fprc, retaddr);
+
+ return flags & float_flag_invalid_cvti ? ret : ret_nan;
}
#define FPU_FCTI(op, cvt, nanval) \
@@ -599,10 +606,8 @@ uint64_t helper_##op(CPUPPCState *env, float64 arg)
\
{ \
uint64_t ret = float64_to_##cvt(arg, &env->fp_status); \
int flags = get_float_exception_flags(&env->fp_status); \
- \
if (unlikely(flags & float_flag_invalid)) { \
- float_invalid_cvt(env, flags, 1, GETPC()); \
- ret = nanval; \
+ ret = float_invalid_cvt(env, flags, ret, nanval, 1, GETPC()); \
} \
return ret; \
}
@@ -2794,8 +2799,7 @@ void helper_##op(CPUPPCState *env, ppc_vsr_t *xt,
ppc_vsr_t *xb) \
t.tfld = stp##_to_##ttp##_round_to_zero(xb->sfld, &env->fp_status); \
flags = env->fp_status.float_exception_flags; \
if (unlikely(flags & float_flag_invalid)) { \
- float_invalid_cvt(env, flags, 0, GETPC()); \
- t.tfld = rnan; \
+ t.tfld = float_invalid_cvt(env, flags, t.tfld, rnan, 0, GETPC());\
} \
all_flags |= flags; \
} \
@@ -2842,8 +2846,7 @@ void helper_##op(CPUPPCState *env, uint32_t opcode,
\
t.tfld = stp##_to_##ttp##_round_to_zero(xb->sfld, &env->fp_status); \
flags = get_float_exception_flags(&env->fp_status); \
if (flags & float_flag_invalid) { \
- float_invalid_cvt(env, flags, 0, GETPC()); \
- t.tfld = rnan; \
+ t.tfld = float_invalid_cvt(env, flags, t.tfld, rnan, 0, GETPC()); \
} \
\
*xt = t; \
--
2.31.1
- [PULL 024/102] softfloat: Add flag specific to sqrt(-x), (continued)
- [PULL 024/102] softfloat: Add flag specific to sqrt(-x), Cédric Le Goater, 2021/12/15
- [PULL 031/102] target/ppc: Update float_invalid_cvt for new flags, Cédric Le Goater, 2021/12/15
- [PULL 041/102] target/ppc: Update do_frsp for new flags, Cédric Le Goater, 2021/12/15
- [PULL 020/102] softfloat: Extend float_exception_flags to 16 bits, Cédric Le Goater, 2021/12/15
- [PULL 035/102] target/ppc: Tidy inexact handling in do_fri, Cédric Le Goater, 2021/12/15
- [PULL 044/102] target/ppc: Update xsrqpi and xsrqpxp to new flags, Cédric Le Goater, 2021/12/15
- [PULL 034/102] target/ppc: Use FloatRoundMode in do_fri, Cédric Le Goater, 2021/12/15
- [PULL 029/102] target/ppc: Update float_invalid_op_div for new flags, Cédric Le Goater, 2021/12/15
- [PULL 040/102] target/ppc: Split out do_frsp, Cédric Le Goater, 2021/12/15
- [PULL 030/102] target/ppc: Move float_check_status from FPU_FCTI to translate, Cédric Le Goater, 2021/12/15
- [PULL 032/102] target/ppc: Fix VXCVI return value,
Cédric Le Goater <=
- [PULL 039/102] target/ppc: Do not call do_float_check_status from do_fmadd, Cédric Le Goater, 2021/12/15
- [PULL 050/102] target/ppc: Add helper for fmuls, Cédric Le Goater, 2021/12/15
- [PULL 051/102] target/ppc: Add helper for frsqrtes, Cédric Le Goater, 2021/12/15
- [PULL 055/102] target/ppc: Disable unused facilities in the e600 CPU, Cédric Le Goater, 2021/12/15
- [PULL 047/102] target/ppc: Add helpers for fmadds et al, Cédric Le Goater, 2021/12/15
- [PULL 036/102] target/ppc: Clean up do_fri, Cédric Le Goater, 2021/12/15
- [PULL 038/102] target/ppc: Split out do_fmadd, Cédric Le Goater, 2021/12/15
- [PULL 033/102] target/ppc: Remove inline from do_fri, Cédric Le Goater, 2021/12/15
- [PULL 048/102] target/ppc: Add helper for fsqrts, Cédric Le Goater, 2021/12/15
- [PULL 042/102] target/ppc: Use helper_todouble in do_frsp, Cédric Le Goater, 2021/12/15