@@ -7072,13 +7072,10 @@ bool VPCostContext::skipCostComputation(Instruction *UI, bool IsVector) const {
70727072 SkipCostComputation.contains (UI);
70737073}
70747074
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;
70827079 // Cost modeling for inductions is inaccurate in the legacy cost model
70837080 // compared to the recipes that are generated. To match here initially during
70847081 // VPlan cost model bring up directly use the induction costs from the legacy
@@ -7224,6 +7221,16 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,
72247221 auto BranchCost = CostCtx.getLegacyCost (BB->getTerminator (), VF);
72257222 Cost += BranchCost;
72267223 }
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+
72277234 // Now compute and add the VPlan-based cost.
72287235 Cost += Plan.cost (VF, CostCtx);
72297236 LLVM_DEBUG (dbgs () << " Cost for VF " << VF << " : " << Cost << " \n " );
0 commit comments