[llvm] [VPlan] Update getBestPlan to return VF, use also for epilogue vec. (PR #98821)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 21 06:45:23 PDT 2024


================
@@ -10336,6 +10335,19 @@ bool LoopVectorizePass::processLoop(Loop *L) {
     } else {
       // If we decided that it is *legal* to vectorize the loop, then do it.
 
+      ElementCount Width = VF.Width;
+      std::optional<VPlan *> VPlanFromVPCost;
+      if (!UseLegacyCostModel) {
+        const auto &[VPWidth, Plan] = LVP.getBestPlan();
----------------
ayalz wrote:

It is a bit confusing to claim that getBestPlan() is also used for epilogue vectorization, given that `Plan` is soon overwritten by `BestPlan`, which is later overwritten by `BestMainPlan` (and `BestEpiPlan`) for epilogue vectorization. Could (some of) this redundancy be eliminated.

The current assertion checks best VF's rather than best Plans, verifying that LVP.getBestVF() equals the VF.Width of LVP.plan(), when vectorizing the main loop only; i.e., avoids checking the VF's of the main or epilog loops when doing epilog vectorization, right?

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


More information about the llvm-commits mailing list