]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
PPC specific changes for BC 507033
authorFlorian Krohm <flo2030@eich-krohm.de>
Sun, 24 Aug 2025 20:26:58 +0000 (20:26 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Sun, 24 Aug 2025 20:26:58 +0000 (20:26 +0000)
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

VEX/priv/guest_ppc_toIR.c
VEX/priv/host_ppc_isel.c

index 18716dd04c4154fca704672c4cda29109ce009ca..eafc557cc73d6f675b6dd7093bd885e1ec662dbf 100644 (file)
@@ -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,
index ff87ae7ed66e9592dc31133c028059e5218f9129..2fad3c59ea6c2f035e8acc1a9da64649b8095a03 100644 (file)
@@ -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;
          }