[llvm] [VPlan] First step towards VPlan cost modeling. (PR #92555)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 14:39:06 PDT 2024
================
@@ -7300,6 +7295,161 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
return VF;
}
+InstructionCost VPCostContext::getLegacyCost(Instruction *UI,
+ ElementCount VF) const {
+ return CM.getInstructionCost(UI, VF).first;
+}
+
+InstructionCost VPCostContext::getLoopExitCost(ElementCount VF) {
+ SmallVector<BasicBlock *> Exiting;
+ CM.TheLoop->getExitingBlocks(Exiting);
+ InstructionCost Cost = 0;
+ // Add the cost of all exit conditions.
+ for (BasicBlock *EB : Exiting) {
+ auto *Term = dyn_cast<BranchInst>(EB->getTerminator());
+ if (!Term)
+ continue;
+ if (auto *CondI = dyn_cast<Instruction>(Term->getOperand(0))) {
+ SkipCostComputation.insert(CondI);
+ Cost += CM.getInstructionCost(CondI, VF).first;
----------------
ayalz wrote:
This appears to be another case of Insns that may or may not be covered by recipes, where the latter case (only) would compute their cost accurately.
https://github.com/llvm/llvm-project/pull/92555
More information about the llvm-commits
mailing list