@@ -7072,13 +7072,10 @@ bool VPCostContext::skipCostComputation(Instruction *UI, bool IsVector) const {
7072
7072
SkipCostComputation.contains(UI);
7073
7073
}
7074
7074
7075
- InstructionCost LoopVectorizationPlanner::cost (VPlan &Plan,
7076
- ElementCount VF) const {
7077
- InstructionCost Cost = 0 ;
7078
- LLVMContext &LLVMCtx = OrigLoop->getHeader ()->getContext ();
7079
- VPCostContext CostCtx (CM.TTI , *CM.TLI , Legal->getWidestInductionType (),
7080
- LLVMCtx, CM);
7081
-
7075
+ InstructionCost
7076
+ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
7077
+ VPCostContext &CostCtx) const {
7078
+ InstructionCost Cost;
7082
7079
// Cost modeling for inductions is inaccurate in the legacy cost model
7083
7080
// compared to the recipes that are generated. To match here initially during
7084
7081
// VPlan cost model bring up directly use the induction costs from the legacy
@@ -7224,6 +7221,16 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
7224
7221
auto BranchCost = CostCtx.getLegacyCost(BB->getTerminator(), VF);
7225
7222
Cost += BranchCost;
7226
7223
}
7224
+ return Cost;
7225
+ }
7226
+
7227
+ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
7228
+ ElementCount VF) const {
7229
+ LLVMContext &LLVMCtx = OrigLoop->getHeader()->getContext();
7230
+ VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),
7231
+ LLVMCtx, CM);
7232
+ InstructionCost Cost = precomputeCosts(Plan, VF, CostCtx);
7233
+
7227
7234
// Now compute and add the VPlan-based cost.
7228
7235
Cost += Plan.cost(VF, CostCtx);
7229
7236
LLVM_DEBUG(dbgs() << "Cost for VF " << VF << ": " << Cost << "\n");
0 commit comments