[llvm] 1e06cd6 - [SLP][NFC] Fix uninitialized ReductionRoot in getTreeCost
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 09:22:07 PDT 2026
Author: Alexey Bataev
Date: 2026-04-01T12:22:02-04:00
New Revision: 1e06cd634e849054d1fe11c1493870b2a7ddf1c9
URL: https://github.com/llvm/llvm-project/commit/1e06cd634e849054d1fe11c1493870b2a7ddf1c9
DIFF: https://github.com/llvm/llvm-project/commit/1e06cd634e849054d1fe11c1493870b2a7ddf1c9.diff
LOG: [SLP][NFC] Fix uninitialized ReductionRoot in getTreeCost
ReductionRoot was initialized to nullptr instead of the RdxRoot
parameter. This caused two ScaleCost calls (for MinBWs cast cost and
ReductionBitWidth resize cost) to pass nullptr as the user instruction,
and suppressed the "Reduction Cost" line in debug output. In practice
the scale factor is the same because the tree root's main op and the
reduction root share the same basic block, so this is NFC.
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/189994
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e66801659e454..39ab9932c006f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -18082,11 +18082,11 @@ InstructionCost BoUpSLP::getTreeCost(InstructionCost TreeCost,
LLVM_DEBUG(dbgs() << "Scale " << Scale << " For entry " << TE.Idx << "\n");
return C * Scale;
};
- Instruction *ReductionRoot = nullptr;
+ Instruction *ReductionRoot = RdxRoot;
if (UserIgnoreList) {
// Scale reduction cost to the factor of the loop nest trip count.
ReductionCost = ScaleCost(ReductionCost, *VectorizableTree.front().get(),
- /*Scalar=*/nullptr, RdxRoot);
+ /*Scalar=*/nullptr, ReductionRoot);
}
// Add the cost for reduction.
More information about the llvm-commits
mailing list