[llvm] [LV] Add epilogue minimum iteration check in VPlan as well. (PR #189372)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 05:49:14 PDT 2026


================
@@ -7471,6 +7367,9 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
   // making any changes to the CFG.
   DenseMap<const SCEV *, Value *> ExpandedSCEVs =
       VPlanTransforms::expandSCEVs(BestVPlan, *PSE.getSE());
+  // Check if the epilogue VPlan is executed (where the trip count was already
+  // set when executing the main plan).
+  bool IsEpilogueVectorization = VectorizingEpilogue && ILV.getTripCount();
   if (!ILV.getTripCount()) {
     ILV.setTripCount(BestVPlan.getTripCount()->getLiveInIRValue());
----------------
artagnon wrote:

I think I see the reason for this now, which is right under (I missed it earlier, sorry)?

```cpp
    assert(VectorizingEpilogue && "should only re-use the existing trip "
                                  "count during epilogue vectorization");
```

I think we should directly pass IsEpilogueVectorization, instead of doing this unintuitive &&, and having an essentially-dead assert?

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


More information about the llvm-commits mailing list