]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: Replace use of deprecated Iop_Clz64 operator
authorAndreas Arnez <arnez@linux.ibm.com>
Tue, 25 Feb 2020 14:54:46 +0000 (15:54 +0100)
committerAndreas Arnez <arnez@linux.ibm.com>
Tue, 25 Feb 2020 15:45:34 +0000 (16:45 +0100)
The operator Iop_Clz64 has been deprecated.  Drop it in the s390x backend
and replace it by Iop_ClzNat64.  Previously s390_irgen_FLOGR() handled the
value zero specially and replaced it by 1 before applying Iop_Clz64.  With
Iop_ClzNat64 this is no longer needed, so remove this special-case
handling.

VEX/priv/guest_s390_toIR.c
VEX/priv/host_s390_isel.c

index ed95fc04215b54ff1ccca8819535ca0a4e506fa7..eb3a25b56736f1d5ef97bb86eb3bcd2cacc770e9 100644 (file)
@@ -14883,27 +14883,15 @@ static const HChar *
 s390_irgen_FLOGR(UChar r1, UChar r2)
 {
    IRTemp input    = newTemp(Ity_I64);
-   IRTemp not_zero = newTemp(Ity_I64);
-   IRTemp tmpnum   = newTemp(Ity_I64);
    IRTemp num      = newTemp(Ity_I64);
    IRTemp shift_amount = newTemp(Ity_I8);
 
-   /* We use the "count leading zeroes" operator because the number of
-      leading zeroes is identical with the bit position of the first '1' bit.
-      However, that operator does not work when the input value is zero.
-      Therefore, we set the LSB of the input value to 1 and use Clz64 on
-      the modified value. If input == 0, then the result is 64. Otherwise,
-      the result of Clz64 is what we want. */
+   /* Use the "count leading zeroes" operator with "natural" semantics.  The
+      results of FLOGR and Iop_ClzNat64 are the same for all inputs, including
+      input == 0, in which case both operators yield 64. */
 
    assign(input, get_gpr_dw0(r2));
-   assign(not_zero, binop(Iop_Or64, mkexpr(input), mkU64(1)));
-   assign(tmpnum, unop(Iop_Clz64, mkexpr(not_zero)));
-
-   /* num = (input == 0) ? 64 : tmpnum */
-   assign(num, mkite(binop(Iop_CmpEQ64, mkexpr(input), mkU64(0)),
-                     /* == 0 */ mkU64(64),
-                     /* != 0 */ mkexpr(tmpnum)));
-
+   assign(num, unop(Iop_ClzNat64, mkexpr(input)));
    put_gpr_dw0(r1, mkexpr(num));
 
    /* Set the leftmost '1' bit of the input value to zero. The general scheme
index fff81fe0fbc187f1df8885cff195efb93fa76598..5d26825daf7d5b5aeb74a36c8ebc394d181d8285 100644 (file)
@@ -1943,7 +1943,7 @@ s390_isel_int_expr_wrk(ISelEnv *env, IRExpr *expr)
          return dst;
       }
 
-      case Iop_Clz64: {
+      case Iop_ClzNat64: {
          HReg r10, r11;
 
          /* This will be implemented using FLOGR, if possible. So we need to