[llvm] [LV] Use IVUpdateMayOverflow to set HasNUW. (PR #111758)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 11:18:42 PST 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.
----------------
fhahn wrote:

The canonical induction goes from 0...Vector-trip-count, and is incremented by VF * UF in each iteration. The vector trip count is the original trip count adjusted to be a multiple of VF * UF.

I updated the comment to clarify that we mean the canonical induction increment. Does that make it clearer?

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


More information about the llvm-commits mailing list