qemu-ppc
[Top][All Lists]
Advanced

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

Re: [PATCH v4 42/47] target/ppc: Refactor VSX_MAX_MINC helper


From: Richard Henderson
Subject: Re: [PATCH v4 42/47] target/ppc: Refactor VSX_MAX_MINC helper
Date: Tue, 22 Feb 2022 14:40:47 -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:
-#define VSX_MAX_MINC(name, max)                                               \
+#define VSX_MAX_MINC(name, op, tp, fld)                                       \
  void helper_##name(CPUPPCState *env,                                          
\
                     ppc_vsr_t *xt, ppc_vsr_t *xa, ppc_vsr_t *xb)               
\
  {                                                                             
\
      ppc_vsr_t t = { };                                                        
\
      bool vxsnan_flag = false, vex_flag = false;                               
\
                                                                                
\
-    if (unlikely(float64_is_any_nan(xa->VsrD(0)) ||                           \
-                 float64_is_any_nan(xb->VsrD(0)))) {                          \
-        if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) ||         \
-            float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) {         \
+    if (unlikely(tp##_is_any_nan(xa->fld) ||                                  \
+                 tp##_is_any_nan(xb->fld))) {                                 \
+        if (tp##_is_signaling_nan(xa->fld, &env->fp_status) ||                \
+            tp##_is_signaling_nan(xb->fld, &env->fp_status)) {                \
              vxsnan_flag = true;                                               
\
          }                                                                     
\
-        t.VsrD(0) = xb->VsrD(0);                                              \
-    } else if ((max &&                                                        \
-               !float64_lt(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) ||     \
-               (!max &&                                                       \
-               float64_lt(xa->VsrD(0), xb->VsrD(0), &env->fp_status))) {      \
-        t.VsrD(0) = xa->VsrD(0);                                              \
+        t.fld = xb->fld;                                                      \
      } else {                                                                  
\
-        t.VsrD(0) = xb->VsrD(0);                                              \
+        t.fld = tp##_##op(xa->fld, xb->fld, &env->fp_status);                 \
      }                                                                         
\
                                                                                
\
      vex_flag = fpscr_ve & vxsnan_flag;                                        
\

I think this would be simpler to utilize the result of the compare vs nans:

    bool first;

    if (max) {
        first = tp##_le_quiet(xb->fld, xa->fld, status);
    } else {
        first = tp##_lt_quiet(xa->fld, xb->fld, status);
    }
    if (first) {
        t.fld = xa->fld;
    } else {
        t.fld = xb->fld;
        if (flags & float_flag_invalid_snan) {
            float_invalid_op_vxsnan(env, retaddr);
        }
    }
    xt = *t;


r~



reply via email to

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