From: Florian Krohm Date: Sun, 24 Aug 2025 20:26:58 +0000 (+0000) Subject: PPC specific changes for BC 507033 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7991d02a61a1f0aa4cf3784d8afbf42f97f3925e;p=thirdparty%2Fvalgrind.git PPC specific changes for BC 507033 Replace the deprecated Iop_Clz64 with Iop_ClzNat64. This is safe to do because insn selection does not distinguish between Iop_Clz64 and Iop_ClzNat64: Iop_Clz64 / Iop_ClzNat64 --isel--> Pun_CLZ64 --emit-->cntlzd The cntlzd insn has "natural" semantics and a 0 operand is not special. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 --- diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c index 18716dd04..eafc557cc 100644 --- a/VEX/priv/guest_ppc_toIR.c +++ b/VEX/priv/guest_ppc_toIR.c @@ -21285,7 +21285,7 @@ dis_vector_logical_mask_bits ( UInt prefix, UInt theInstr, UInt opc2, ) ) ) ); assign( clz[0], - unop( Iop_Clz64, + unop( Iop_ClzNat64, mkexpr( extracted_bits[0] ) ) ); assign( extracted_bits[1], @@ -21300,7 +21300,7 @@ dis_vector_logical_mask_bits ( UInt prefix, UInt theInstr, UInt opc2, mkexpr( cnt_extract_bits[1] ) ) ) ) ); assign( clz[1], - unop( Iop_Clz64, + unop( Iop_ClzNat64, mkexpr( extracted_bits[1] ) ) ); putVReg( vRT_addr, binop( Iop_64HLtoV128, diff --git a/VEX/priv/host_ppc_isel.c b/VEX/priv/host_ppc_isel.c index ff87ae7ed..2fad3c59e 100644 --- a/VEX/priv/host_ppc_isel.c +++ b/VEX/priv/host_ppc_isel.c @@ -2069,14 +2069,14 @@ static HReg iselWordExpr_R_wrk ( ISelEnv* env, const IRExpr* e, } break; - case Iop_Clz32: case Iop_ClzNat32: - case Iop_Clz64: case Iop_ClzNat64: { + case Iop_ClzNat32: + case Iop_ClzNat64: { // cntlz is available even in the most basic (earliest) ppc // variants, so it's safe to generate it unconditionally. HReg r_src, r_dst; - PPCUnaryOp op_clz = (op_unop == Iop_Clz32 || op_unop == Iop_ClzNat32) + PPCUnaryOp op_clz = (op_unop == Iop_ClzNat32) ? Pun_CLZ32 : Pun_CLZ64; - if ((op_unop == Iop_Clz64 || op_unop == Iop_ClzNat64) && !mode64) + if ((op_unop == Iop_ClzNat64) && !mode64) goto irreducible; /* Count leading zeroes. */ r_dst = newVRegI(env); @@ -2085,9 +2085,7 @@ static HReg iselWordExpr_R_wrk ( ISelEnv* env, const IRExpr* e, return r_dst; } - //case Iop_Ctz32: case Iop_CtzNat32: - //case Iop_Ctz64: case Iop_CtzNat64: { // Generate code using Clz, because we can't assume the host has @@ -2095,7 +2093,7 @@ static HReg iselWordExpr_R_wrk ( ISelEnv* env, const IRExpr* e, // creating a Ctz in ir_opt.c from smaller fragments. PPCUnaryOp op_clz = Pun_CLZ64; Int WS = 64; - if (op_unop == Iop_Ctz32 || op_unop == Iop_CtzNat32) { + if (op_unop == Iop_CtzNat32) { op_clz = Pun_CLZ32; WS = 32; }