[llvm] [LV] Simplify epilogue VF selection by comparing against MaxTripCount (PR #186185)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 20 05:10:03 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,
----------------
david-arm wrote:
What happens when `RemainingIterations` is scalable? In this case the expression will involve `vscale` and we'll be comparing against a constant with the new code. If `RemainingIterations` is scalable then it also means `MainLoopVF ` is scalable. I think you either have to:
1. Use calculations depending upon whether `RemainingIterations` is scalable or not. For example, you can use calculations on `RemainingIterations` and `MainLoopVF` directly keeping the comparison in the vscale space. Or
2. Estimate the remaining iterations using VScaleForTuning.
https://github.com/llvm/llvm-project/pull/186185
More information about the llvm-commits
mailing list