[llvm] [SLP] NFC: Remove redundant expression from getBuildVectorCost (PR #222547)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 01:19:04 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Sander de Smalen (sdesmalen-arm)
<details>
<summary>Changes</summary>
Gathers is initialized with the contents from VL and then not modified, so `VL.equals(Gathers)` is always true.
Also removed unnecessary `std::iota`, as the constructor for SmallVector can initialize the array with 0 instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/222547.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+4-8)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3fd146320c959..c050cb305379c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14451,7 +14451,6 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return TTI::TCC_Free;
auto *VecTy = cast<VectorType>(getWidenedType(ScalarTy, VL.size()));
InstructionCost GatherCost = 0;
- SmallVector<Value *> Gathers(VL);
if (!Root && isSplat(VL)) {
// Found the broadcasting of the single scalar, calculate the cost as
// the broadcast.
@@ -14486,11 +14485,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
/*Index=*/0, /*SubTp=*/nullptr,
/*Args=*/*It);
}
- return GatherCost +
- (all_of(Gathers, IsaPred<UndefValue>)
- ? TTI::TCC_Free
- : R.getGatherCost(Gathers, !Root && VL.equals(Gathers),
- ScalarTy));
+ return GatherCost + (all_of(VL, IsaPred<UndefValue>)
+ ? TTI::TCC_Free
+ : R.getGatherCost(VL, !Root, ScalarTy));
};
/// Compute the cost of creating a vector containing the extracted values from
@@ -20726,8 +20723,7 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
Cost += TTI->getCastInstrCost(Instruction::Trunc, ScalarTy, V->getType(),
TTI::CastContextHint::None, CostKind);
};
- SmallVector<int> ConstantShuffleMask(VF, PoisonMaskElem);
- std::iota(ConstantShuffleMask.begin(), ConstantShuffleMask.end(), 0);
+ SmallVector<int> ConstantShuffleMask(VF, 0);
for (auto [I, V] : enumerate(VL)) {
// No need to shuffle duplicates for constants.
if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V))
``````````
</details>
https://github.com/llvm/llvm-project/pull/222547
More information about the llvm-commits
mailing list