[llvm] [LoopVectorize] Further improve cost model for early exit loops (PR #126235)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 02:47:38 PST 2025


================
@@ -726,6 +726,19 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
     return Ctx.TTI.getArithmeticReductionCost(
         Instruction::Or, cast<VectorType>(VecTy), std::nullopt, Ctx.CostKind);
   }
+  case VPInstruction::ExtractFirstActive: {
+    // Calculate the cost of determining the lane index.
+    auto *PredTy = toVectorTy(Ctx.Types.inferScalarType(getOperand(1)), VF);
+    IntrinsicCostAttributes Attrs(
+        Intrinsic::experimental_cttz_elts, Type::getInt64Ty(Ctx.LLVMCtx),
+        {PoisonValue::get(PredTy), ConstantInt::getTrue(Ctx.LLVMCtx)});
----------------
fhahn wrote:

Are the arguments here only used to pass the type? Is there a variant of `IntrinsicCostAttributes` that just takes the argument types?

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


More information about the llvm-commits mailing list