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

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 04:28:56 PDT 2024


================
@@ -2455,8 +2471,17 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
         ConstantInt::get(CountTy, cast<IntegerType>(CountTy)->getMask());
     Value *LHS = Builder.CreateSub(MaxUIntTripCount, Count);
 
+    Value *Step = CreateStep();
+    ScalarEvolution &SE = *PSE.getSE();
+    // Check if we can prove that the trip count is >= the step.
+    // TODO: Emit unconditional branch to vector preheader instead of
+    // conditional branch with known condition.
+    const SCEV *TripCountSCEV = SE.getSCEV(LHS);
----------------
ayalz wrote:

nit: can also apply loop guards to TripCountSCEV here.

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


More information about the llvm-commits mailing list