[llvm] [LV] Adjust the trip count of tail-folded loops which may overflow (PR #224340)

Kerry McLaughlin via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 05:42:46 PDT 2026


================
@@ -6493,7 +6494,7 @@ void LoopVectorizationPlanner::buildVPlans(VPlan &VPlan1, ElementCount MinVF,
     TailFoldingStyle Style = CM->getTailFoldingStyle();
     RUN_VPLAN_PASS(VPlanTransforms::materializeHeaderMask, *Plan,
                    useActiveLaneMask(Style),
-                   useActiveLaneMaskForControlFlow(Style));
+                   useActiveLaneMaskForControlFlow(Style), IVUpdateMayOverflow);
----------------
kmclaughlin-arm wrote:

We should be able to check for the `nuw` flag on the canonical IV during the transform, although `addVPLaneMaskPhiAndUpdateExitBranch` was dropping this flag if it was set.
I've changed this in the latest commit, removing the call to `clearCanonicalIVNUW()`.

Unless I've missed something, I think this should be safe as the flag would have been dropped earlier if `isIndvarOverflowCheckKnownFalse` was false for any VF.

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


More information about the llvm-commits mailing list