[llvm] 0c3bfbe - [SLP] reduce code duplication for checking parent block; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 06:26:58 PDT 2020
Author: Sanjay Patel
Date: 2020-09-22T09:21:20-04:00
New Revision: 0c3bfbe4bc212c8e6b54ffd6d9f59ae513e31247
URL: https://github.com/llvm/llvm-project/commit/0c3bfbe4bc212c8e6b54ffd6d9f59ae513e31247
DIFF: https://github.com/llvm/llvm-project/commit/0c3bfbe4bc212c8e6b54ffd6d9f59ae513e31247.diff
LOG: [SLP] reduce code duplication for checking parent block; NFC
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 0f9193e502a1..1c8501a92e2e 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6418,17 +6418,16 @@ class HorizontalReduction {
return isMinMax() ? 3 : 2;
}
- /// Checks if the operation has the same parent as \p P.
- bool hasSameParent(Instruction *I, Value *P, bool IsRedOp) const {
+ /// Checks if the instruction is in basic block \p BB.
+ /// For a min/max reduction check that both compare and select are in \p BB.
+ bool hasSameParent(Instruction *I, BasicBlock *BB, bool IsRedOp) const {
assert(Kind != RK_None && !!*this && LHS && RHS &&
"Expected reduction operation.");
- if (!IsRedOp)
- return I->getParent() == P;
- if (isMinMax()) {
+ if (IsRedOp && isMinMax()) {
auto *Cmp = cast<Instruction>(cast<SelectInst>(I)->getCondition());
- return I->getParent() == P && Cmp && Cmp->getParent() == P;
+ return I->getParent() == BB && Cmp && Cmp->getParent() == BB;
}
- return I->getParent() == P;
+ return I->getParent() == BB;
}
/// Expected number of uses for reduction operations/reduced values.
More information about the llvm-commits
mailing list