[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
This commit is contained in:
Alexey Bataev 2026-04-01 12:22:02 -04:00 committed by GitHub
parent 27c8596400
commit 1e06cd634e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.