From bb594e098b75ae6309c8f2ee2a7ddc5c6dc2361f Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Tue, 25 Feb 2020 15:54:46 +0100 Subject: [PATCH] s390x: Replace use of deprecated Iop_Clz64 operator 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 | 20 ++++---------------- VEX/priv/host_s390_isel.c | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index ed95fc0421..eb3a25b567 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -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 diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c index fff81fe0fb..5d26825daf 100644 --- a/VEX/priv/host_s390_isel.c +++ b/VEX/priv/host_s390_isel.c @@ -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 -- 2.47.2