qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH v4 38/47] target/ppc: Refactor VSX_SCALAR_CMP_DP


From: Richard Henderson
Subject: Re: [PATCH v4 38/47] target/ppc: Refactor VSX_SCALAR_CMP_DP
Date: Tue, 22 Feb 2022 14:20:36 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0

On 2/22/22 04:36, matheus.ferst@eldorado.org.br wrote:
From: Víctor Colombo <victor.colombo@eldorado.org.br>

Refactor VSX_SCALAR_CMP_DP, changing its name to VSX_SCALAR_CMP and
prepare the helper to be used for quadword comparisons.

Signed-off-by: Víctor Colombo <victor.colombo@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
  target/ppc/fpu_helper.c | 31 ++++++++++++++-----------------
  1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 9b034d1fe4..5ebbcfe3b7 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -2265,28 +2265,30 @@ VSX_MADDQ(XSNMSUBQP, NMSUB_FLGS, 0)
  VSX_MADDQ(XSNMSUBQPO, NMSUB_FLGS, 0)
/*
- * VSX_SCALAR_CMP_DP - VSX scalar floating point compare double precision
+ * VSX_SCALAR_CMP - VSX scalar floating point compare
   *   op    - instruction mnemonic
+ *   tp    - type
   *   cmp   - comparison operation
   *   exp   - expected result of comparison
+ *   fld   - vsr_t field
   *   svxvc - set VXVC bit
   */
-#define VSX_SCALAR_CMP_DP(op, cmp, exp, svxvc)                                \
+#define VSX_SCALAR_CMP(op, tp, cmp, fld, exp, svxvc)                          \
  void helper_##op(CPUPPCState *env, ppc_vsr_t *xt,                             
\
                   ppc_vsr_t *xa, ppc_vsr_t *xb)                                
\
  {                                                                             
\
-    ppc_vsr_t t = *xt;                                                        \
+    ppc_vsr_t t = { };                                                        \
      bool vxsnan_flag = false, vxvc_flag = false, vex_flag = false;            
\
                                                                                
\
-    if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) ||             \
-        float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) {             \
+    if (tp##_is_signaling_nan(xa->fld, &env->fp_status) ||                    \
+        tp##_is_signaling_nan(xb->fld, &env->fp_status)) {                    \
          vxsnan_flag = true;                                                   
\
          if (fpscr_ve == 0 && svxvc) {                                         
\
              vxvc_flag = true;                                                 
\
          }                                                                     
\
      } else if (svxvc) {                                                       
\
-        vxvc_flag = float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) ||     \
-            float64_is_quiet_nan(xb->VsrD(0), &env->fp_status);               \
+        vxvc_flag = tp##_is_quiet_nan(xa->fld, &env->fp_status) ||            \
+            tp##_is_quiet_nan(xb->fld, &env->fp_status);                      \
}

Note that this can be simplified further, using the full FloatRelation result and float_flag_invalid_snan.

Note that do_scalar_cmp gets half-way there, only checking for NaNs once we have float_relation_unordered as a comparision result. But it could go further and check float_flag_invalid_snan and drop all of the other checks vs snan and qnan.


r~



reply via email to

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