[llvm] [LV] Support multiplies by constants when forming scaled reductions. (PR #161092)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 00:51:37 PDT 2025


================
@@ -7937,6 +7937,13 @@ bool VPRecipeBuilder::getScaledReductions(
   auto CollectExtInfo = [this, &Exts, &ExtOpTypes,
                          &ExtKinds](SmallVectorImpl<Value *> &Ops) -> bool {
     for (const auto &[I, OpI] : enumerate(Ops)) {
+      auto *CI = dyn_cast<ConstantInt>(OpI);
+      if (I > 0 && CI &&
+          canConstantBeExtended(CI, ExtOpTypes[0], ExtKinds[0])) {
+        ExtOpTypes[I] = ExtOpTypes[0];
+        ExtKinds[I] = ExtKinds[0];
+        continue;
+      }
----------------
david-arm wrote:

I guess the comment below:

```
// TODO: We should be able to support live-ins.
```

is still valid because the 2nd operand could be a non-constant loop invariant value?

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


More information about the llvm-commits mailing list