[llvm] [LV] Don't vectorize epilogue with scalable VF if no iterations remain. (PR #149789)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 03:51:19 PDT 2025


================
@@ -4479,6 +4479,27 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
   Type *TCType = Legal->getWidestInductionType();
   const SCEV *RemainingIterations = nullptr;
   unsigned MaxTripCount = 0;
+  if (MainLoopVF.isFixed()) {
----------------
david-arm wrote:

With the work done by @paulwalker-arm (see https://github.com/llvm/llvm-project/pull/146102) I think we also need to do this for scalable main loop VFs too. For example, the trip count may be a multiple of vscale such as 16 * vscale, and if the main loop VF=vscale x 4 with IC = 1, we know at compile there will be no remaining iterations.

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


More information about the llvm-commits mailing list