[llvm] [LV] Use SCEV to check if minimum iteration check is known. (PR #111310)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 14:03:05 PDT 2024


================
@@ -2453,8 +2470,17 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
         ConstantInt::get(CountTy, cast<IntegerType>(CountTy)->getMask());
     Value *LHS = Builder.CreateSub(MaxUIntTripCount, Count);
 
+    Value *Step = CreateStep();
+#ifndef NDEBUG
+    ScalarEvolution &SE = *PSE.getSE();
+    const SCEV *TripCountSCEV = SE.applyLoopGuards(SE.getSCEV(LHS), OrigLoop);
+    assert(
+        !SE.isKnownPredicate(CmpInst::getInversePredicate(ICmpInst::ICMP_ULT),
+                             TripCountSCEV, SE.getSCEV(Step)) &&
----------------
fhahn wrote:

Added, thanks!

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


More information about the llvm-commits mailing list