[llvm] [LoopVectorize] Improve Vectorization of Small Loops (PR #195823)

Jack Styles via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 00:58:30 PDT 2026


================
@@ -3016,6 +3031,33 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
         MaxFactors.ScalableVF = ElementCount::getScalable(0);
         return MaxFactors;
       }
+      // Allow cases where the ExactTC == VF + 1. VF can be any power of
+      // 2 between 2 and MaxVF.
+      //
+      // This produces 1 vector iteration, and 1 scalar iteration with
+      // no remainder. Later passes will eliminate the loop and leave
+      // straight-line code as the both iteration counts are statically known.
+      ElementCount ExactTC = getSmallConstantTripCount(PSE.getSE(), TheLoop);
----------------
Stylie777 wrote:

I've run the tests with `ExpectedTC` and I would agree it's using the same value, so I have changed it to use ExpectedTC throughout.

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


More information about the llvm-commits mailing list