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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 03:58:33 PDT 2026


================
@@ -3012,6 +3012,16 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
   }
 
   auto ExpectedTC = getSmallBestKnownTC(PSE, TheLoop);
+  auto ApplyVectorWidth = [](FixedScalableVFPair &MaxFactors,
+                             unsigned int FixedVF, unsigned int ScalableVF) {
+    MaxFactors.FixedVF = ElementCount::getFixed(FixedVF);
+    MaxFactors.ScalableVF = ElementCount::getScalable(ScalableVF);
+  };
+  unsigned EffectiveIC = UserIC > 0 ? UserIC : 1;
+  auto HasOneScalarIterationRemainder = [EffectiveIC](ElementCount &ExactTC,
+                                                      unsigned int VF) -> bool {
+    return ExactTC.getFixedValue() == ((VF * EffectiveIC) + 1);
----------------
david-arm wrote:

nit: I think you can just write this as `1 + (VF * EffectiveIC)`

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


More information about the llvm-commits mailing list