[llvm] [LV][VPlan] Implement VPlan-based cost for exit condition. (PR #125640)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 22:50:53 PDT 2025
================
@@ -964,6 +964,37 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
return Ctx.TTI.getArithmeticReductionCost(
Instruction::Or, cast<VectorType>(VecTy), std::nullopt, Ctx.CostKind);
}
+ case VPInstruction::BranchOnCount: {
+ Type *ValTy = Ctx.Types.inferScalarType(getOperand(0));
+
+ // If the vector loop only executed once (VF == original trip count), ignore
+ // the cost of cmp.
+ // TODO: We can remove this after hoist `unrollByUF` and
+ // `optimizeForVFandUF` which will optimize BranchOnCount out.
+ auto TC = dyn_cast_if_present<ConstantInt>(
+ getParent()->getPlan()->getTripCount()->getUnderlyingValue());
+ if (TC && VF.isFixed() && TC->getSExtValue() == VF.getFixedValue())
----------------
ElvisWang123 wrote:
Updated, thanks!
https://github.com/llvm/llvm-project/pull/125640
More information about the llvm-commits
mailing list