On 2/22/22 04:36, matheus.fe...@eldorado.org.br wrote:
From: Víctor Colombo <victor.colo...@eldorado.org.br>
Signed-off-by: Víctor Colombo <victor.colo...@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.fe...@eldorado.org.br>
---
target/ppc/fpu_helper.c | 21 +++++++++++++++++++
target/ppc/helper.h | 1 +
target/ppc/insn32.decode | 11 +++++++---
target/ppc/translate/vsx-impl.c.inc | 31 ++++++++++++++++++++++++++++-
4 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 7773333bd7..d77900fff1 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -2790,6 +2790,27 @@ VSX_CVT_FP_TO_FP_HP(xscvhpdp, 1, float16, float64,
VsrH(3), VsrD(0), 1)
VSX_CVT_FP_TO_FP_HP(xvcvsphp, 4, float32, float16, VsrW(i), VsrH(2 * i + 1),
0)
VSX_CVT_FP_TO_FP_HP(xvcvhpsp, 4, float16, float32, VsrH(2 * i + 1), VsrW(i),
0)
+void helper_XVCVSPBF16(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb)
+{
+ ppc_vsr_t t = { };
+ int i;
+
+ helper_reset_fpstatus(env);
+ for (i = 0; i < 4; i++) {
+ if (unlikely(float32_is_signaling_nan(xb->VsrW(i), &env->fp_status))) {
+ float_invalid_op_vxsnan(env, GETPC());
+ t.VsrH(2 * i + 1) = float32_to_bfloat16(
+ float32_snan_to_qnan(xb->VsrW(i)), &env->fp_status);
+ } else {
+ t.VsrH(2 * i + 1) =
+ float32_to_bfloat16(xb->VsrW(i), &env->fp_status);
+ }
+ }
Do not check for snan first; use float_flag_invalid_snan.
And you can move that check outside the loop, before the
writeback of t to *xt.
r~