[llvm] [InstCombine] Transform `vector.reduce.add` and `splat` into multiplication (PR #161020)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 28 09:41:12 PDT 2025
================
@@ -3761,6 +3762,24 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
return replaceInstUsesWith(CI, Res);
}
}
+
+ // Handle the case where a splat is summarized. In that case we have a
+ // multpilication. For example: %2 = insertelement <4 x i32> poison, i32
+ // %0, i64 0 %3 = shufflevector <4 x i32> %2, poison, <4 x i32>
+ // zeroinitializer %4 = tail call i32 @llvm.vector.reduce.add.v4i32(%3)
+ // =>
+ // %2 = mul i32 %0, 4
----------------
nikic wrote:
```suggestion
// vector.reduce.add.vNiM(splat(%x)) -> mul(%x, N)
```
Or so.
https://github.com/llvm/llvm-project/pull/161020
More information about the llvm-commits
mailing list