[llvm] [LV] Simplify epilogue VF selection by comparing against MaxTripCount (PR #186185)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 02:51:37 PDT 2026


================
@@ -4313,55 +4313,26 @@ std::unique_ptr<VPlan> LoopVectorizationPlanner::selectBestEpiloguePlan(
   if (RemainingIterations->isZero())
     return nullptr;
 
-  if (MainLoopVF.isFixed()) {
-    MaxTripCount = MainLoopVF.getFixedValue() * IC - 1;
-    if (SE.isKnownPredicate(CmpInst::ICMP_ULT, RemainingIterations,
-                            SE.getConstant(TCType, MaxTripCount))) {
-      MaxTripCount = SE.getUnsignedRangeMax(RemainingIterations).getZExtValue();
-    }
-    LLVM_DEBUG(dbgs() << "LEV: Maximum Trip Count for Epilogue: "
-                      << MaxTripCount << "\n");
-  }
+  unsigned MaxTripCount = EstimatedRuntimeVF.getFixedValue() * IC - 1;
+  if (SE.isKnownPredicate(CmpInst::ICMP_ULT, RemainingIterations,
----------------
hassnaaHamdi wrote:

Because SCEV right now can't evaluate some cases, I thought about leaving sticking to `MaxTripCount` without considering the `RemainingIterations`. I think that was not a good decision. I will update it.

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


More information about the llvm-commits mailing list