[llvm] [LV] Use IVUpdateMayOverflow to set HasNUW. (PR #111758)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 13:12:23 PDT 2024
================
@@ -9014,9 +9014,11 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
DebugLoc DL = getDebugLocFromInstOrOperands(Legal->getPrimaryInduction());
TailFoldingStyle Style = CM.getTailFoldingStyle(IVUpdateMayOverflow);
- // When not folding the tail, we know that the induction increment will not
- // overflow.
- bool HasNUW = Style == TailFoldingStyle::None;
+ // Use NUW for the induction increment if we proved that it won't overflow in
+ // the vector loop or when not folding the tail. Then we know that the
+ // induction increment will not overflow as the vector trip count is >=
+ // increment and a multiple of the increment.
----------------
artagnon wrote:
Is this correct: "the vector trip count >= increment and a multiple of the increment"? The trip count of the vectorized loop could be 1 for a VF of 4: won't the increment also be multiplied by 4 from the scalar version then? If the IV update doesn't overflow, doesn't it mean that trip count of vectorized loop * VF >= increment and a multiple of the increment? Maybe I'm getting confused with the "vector trip count" terminology.
https://github.com/llvm/llvm-project/pull/111758
More information about the llvm-commits
mailing list