[llvm] [X86] Promote cttz_i32(x) -> cttz_i64((i64)x | (1 << 32)) (PR #102900)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 07:44:44 PDT 2024


================
@@ -3237,9 +3238,10 @@ bool X86TargetLowering::shouldFormOverflowOp(unsigned Opcode, EVT VT,
 }
 
 bool X86TargetLowering::isCheapToSpeculateCttz(Type *Ty) const {
-  // Speculate cttz only if we can directly use TZCNT or can promote to i32.
+  // Speculate cttz only if we can directly use TZCNT or can promote to i32/i64.
   return Subtarget.hasBMI() ||
-         (!Ty->isVectorTy() && Ty->getScalarSizeInBits() < 32);
+         (!Ty->isVectorTy() &&
+          Ty->getScalarSizeInBits() < (Subtarget.is64Bit() ? 64u : 32u));
----------------
phoebewang wrote:

Is there any different to add `u`?

https://github.com/llvm/llvm-project/pull/102900


More information about the llvm-commits mailing list