[llvm] [LV] Use getDecisionRangeAndClamp for IVUpdateMayOverflow (PR #156028)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 29 07:11:19 PDT 2025


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/156028

The change is very difficult to test.

>From 96f4e435b368c0cd851e4509713cef341476481f Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Fri, 29 Aug 2025 15:08:12 +0100
Subject: [PATCH] [LV] Use getDecisionRangeAndClamp for IVUpdateMayOverflow

The change is very difficult to test.
---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6317bc3c20e25..5dfcd26e882d4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8567,14 +8567,11 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
 
   VPlanTransforms::createLoopRegions(*Plan);
 
-  // Don't use getDecisionAndClampRange here, because we don't know the UF
-  // so this function is better to be conservative, rather than to split
-  // it up into different VPlans.
-  // TODO: Consider using getDecisionAndClampRange here to split up VPlans.
-  bool IVUpdateMayOverflow = false;
-  for (ElementCount VF : Range)
-    IVUpdateMayOverflow |= !isIndvarOverflowCheckKnownFalse(&CM, VF);
-
+  bool IVUpdateMayOverflow = LoopVectorizationPlanner::getDecisionAndClampRange(
+      [this](ElementCount VF) {
+        return !isIndvarOverflowCheckKnownFalse(&CM, VF);
+      },
+      Range);
   TailFoldingStyle Style = CM.getTailFoldingStyle(IVUpdateMayOverflow);
   // Use NUW for the induction increment if we proved that it won't overflow in
   // the vector loop or when not folding the tail. In the later case, we know



More information about the llvm-commits mailing list