[llvm] [LV] Transform to handle exits in the scalar loop (PR #148626)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 02:21:43 PST 2025


================
@@ -8318,6 +8323,15 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
       if (CM.foldTailWithEVL())
         VPlanTransforms::runPass(VPlanTransforms::addExplicitVectorLength,
                                  *Plan, CM.getMaxSafeElements());
+
+      // See if we can convert an early exit vplan to bail out to a scalar
+      // loop if state-changing operations (like stores) are present and
+      // an exit will be taken in the next vector iteration.
+      // If not, discard the plan.
+      if (!Plan->hasScalarVFOnly() && HandleEarlyExitsInScalarTail &&
----------------
sdesmalen-arm wrote:

nit: move the check for `Plan->hasScalarVFOnly()` to `handleUncountableExitsInScalarLoop`.

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


More information about the llvm-commits mailing list