[llvm] [LV] Use shl for (VFxUF * vscale) when creating minimum iter check. (PR #153495)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 02:21:48 PDT 2025


================
@@ -2305,16 +2305,27 @@ Value *InnerLoopVectorizer::createIterationCountCheck(ElementCount VF,
   Type *CountTy = Count->getType();
   Value *CheckMinIters = Builder.getFalse();
   auto CreateStep = [&]() -> Value * {
+    ElementCount VFTimesUF = VF.multiplyCoefficientBy(UF);
+    Value *VFxUF = nullptr;
+    if (!VFTimesUF.isScalable() ||
+        !isPowerOf2_64(VFTimesUF.getKnownMinValue())) {
+      VFxUF = createStepForVF(Builder, CountTy, VF, UF);
+    } else {
+      VFxUF = Builder.CreateShl(
+          Builder.CreateVScale(CountTy),
+          ConstantInt::get(CountTy, Log2_64(VFTimesUF.getKnownMinValue())), "",
+          true);
+    }
+
----------------
fhahn wrote:

I originally thought that this probably adds a lot to the diff, but it doesn't seem to bad, so I added this to the patch here, thanks

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


More information about the llvm-commits mailing list