[llvm] [SLP] Don't rely on VectorizableTree in canBuildSplitNode() when called from tryToReduce() (PR #220014)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 31 09:06:27 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ryan Buchner (bababuck)
<details>
<summary>Changes</summary>
The tree is left-over from the prior vectorization attempt in this case.
---
Full diff: https://github.com/llvm/llvm-project/pull/220014.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+7-4)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index a7eaef3701415..0ec53761ad6c9 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2663,7 +2663,8 @@ class slpvectorizer::BoUpSLP {
const InstructionsState &LocalState,
SmallVectorImpl<Value *> &Op1,
SmallVectorImpl<Value *> &Op2,
- OrdersType &ReorderIndices) const;
+ OrdersType &ReorderIndices,
+ bool TreeExists = true) const;
~BoUpSLP();
@@ -11091,7 +11092,8 @@ bool BoUpSLP::canBuildSplitNode(ArrayRef<Value *> VL,
const InstructionsState &LocalState,
SmallVectorImpl<Value *> &Op1,
SmallVectorImpl<Value *> &Op2,
- OrdersType &ReorderIndices) const {
+ OrdersType &ReorderIndices,
+ bool TreeExists) const {
constexpr unsigned SmallNodeSize = 4;
if (VL.size() <= SmallNodeSize || TTI->preferAlternateOpcodeVectorization() ||
!SplitAlternateInstructions)
@@ -11211,7 +11213,7 @@ bool BoUpSLP::canBuildSplitNode(ArrayRef<Value *> VL,
TTI->getArithmeticInstrCost(Opcode1, Op2VecTy, CostKind);
InstructionCost NewCost =
NewVecOpsCost + InsertCost +
- (!VectorizableTree.empty() && getRootNode().hasState() &&
+ (TreeExists && !VectorizableTree.empty() && getRootNode().hasState() &&
getRootNode().getOpcode() == Instruction::Store
? NewShuffleCost
: 0);
@@ -31138,7 +31140,8 @@ class HorizontalReduction {
SmallVector<Value *> Op1, Op2;
BoUpSLP::OrdersType ReorderIndices;
if (MainOp && AltOp &&
- V.canBuildSplitNode(Ops, OpS, Op1, Op2, ReorderIndices)) {
+ V.canBuildSplitNode(Ops, OpS, Op1, Op2, ReorderIndices,
+ /*TreeExists*/ false)) {
if (LocalReducedVals.empty()) {
LocalReducedVals.push_back(Ops);
States.push_back(OpS);
``````````
</details>
https://github.com/llvm/llvm-project/pull/220014
More information about the llvm-commits
mailing list