[llvm] [RFC][LV] VPlan-based cost model (PR #67647)

Renato Golin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 02:27:19 PDT 2024


================
@@ -5474,73 +5396,97 @@ static void emitInvalidCostRemarks(SmallVector<InstructionVFPair> InvalidCosts,
   } while (!Tail.empty());
 }
 
-VectorizationFactor LoopVectorizationCostModel::selectVectorizationFactor(
-    const ElementCountSet &VFCandidates) {
-  InstructionCost ExpectedCost = expectedCost(ElementCount::getFixed(1)).first;
-  LLVM_DEBUG(dbgs() << "LV: Scalar loop costs: " << ExpectedCost << ".\n");
-  assert(ExpectedCost.isValid() && "Unexpected invalid cost for scalar loop");
-  assert(VFCandidates.count(ElementCount::getFixed(1)) &&
-         "Expected Scalar VF to be a candidate");
+bool LoopVectorizationPlanner::isMoreProfitable(
----------------
rengolin wrote:

Since working with VPlan is cheaper and we'll be doing a lot more cost model checks and we'll be comparing the same VPlan against other VPlans, I suggest we cache the cost of VPlans and only compute the ones that haven't been done yet.

Otherwise we'll be re-running the cost checks across the same VPlans over and over.

https://github.com/llvm/llvm-project/pull/67647


More information about the llvm-commits mailing list