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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 02:43:58 PDT 2025


================
@@ -824,7 +824,13 @@ namespace llvm {
 Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
                        int64_t Step) {
   assert(Ty->isIntegerTy() && "Expected an integer step");
-  return B.CreateElementCount(Ty, VF.multiplyCoefficientBy(Step));
+  if (!VF.isScalable() || !isPowerOf2_64(VF.getKnownMinValue()) ||
+      !isPowerOf2_64(Step))
+    return B.CreateElementCount(Ty, VF.multiplyCoefficientBy(Step));
----------------
david-arm wrote:

nit: Given you're effectively doing the same thing below you could just do:

```
  ElementCount VFxStep = VF.multiplyCoefficientBy(Step);
  if (!VF.isScalable() || !isPowerOf2_64(VF.getKnownMinValue()) ||
      !isPowerOf2_64(Step))
    return B.CreateElementCount(Ty, VFxStep);

  return B.CreateShl(
      B.CreateVScale(Ty),
      ConstantInt::get(Ty, Log2_64(VFxStep.getKnownMinValue())), "", true);
```

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


More information about the llvm-commits mailing list