[llvm] [VPlan] First step towards VPlan cost modeling. (PR #92555)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 06:47:54 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;
----------------
fhahn wrote:
Yes, the original exit conditions are DCE'd by VPlan transforms if they are only used to control the exit.
https://github.com/llvm/llvm-project/pull/92555
More information about the llvm-commits
mailing list