[llvm] Extend vector.reduce.add and splat transform to scalable vectors (PR #161101)
Gábor Spaits via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 00:54:30 PDT 2025
================
@@ -3785,13 +3785,19 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
// vector.reduce.add.vNiM(splat(%x)) -> mul(%x, N)
if (Value *Splat = getSplatValue(Arg)) {
- ElementCount VecToReduceCount =
- cast<VectorType>(Arg->getType())->getElementCount();
+ VectorType *VecToReduceTy = cast<VectorType>(Arg->getType());
+ ElementCount VecToReduceCount = VecToReduceTy->getElementCount();
+ Value *RHS;
if (VecToReduceCount.isFixed()) {
unsigned VectorSize = VecToReduceCount.getFixedValue();
- return BinaryOperator::CreateMul(
- Splat, ConstantInt::get(Splat->getType(), VectorSize));
+ RHS = ConstantInt::get(Splat->getType(), VectorSize);
----------------
spaits wrote:
I see. Inetersting that it did not change the exepcted output for the other cases (I mean the disregarding of the result coming from this branch). Probably later CreateElementCount returns wit a constant and that is propagated (or folded? I am not 100% sure that is the right word to use here) to the mul.
https://github.com/llvm/llvm-project/pull/161101
More information about the llvm-commits
mailing list