summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-07-28 20:11:16 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-07-28 20:11:16 +0000
commite109655c902f6e381348c5874512b4897bedff8f (patch)
treea1fbdbdbbba1d1f4f0f3d25d413f9be2a1a68547 /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
parent74ddba0c95bc0bc2b1bf23bb95f5c6e3e539aec5 (diff)
downloadbcm5719-llvm-e109655c902f6e381348c5874512b4897bedff8f.tar.gz
bcm5719-llvm-e109655c902f6e381348c5874512b4897bedff8f.zip
[SLP] Allow vectorization of the instruction from the same basic blocks only, NFC.
Summary: After some changes in SLP vectorizer we missed some additional checks to limit the instructions for vectorization. We should not perform analysis of the instructions if the parent of instruction is not the same as the parent of the first instruction in the tree or it was analyzed already. Subscribers: mzolotukhin Differential Revision: https://reviews.llvm.org/D34881 llvm-svn: 309425
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 9931c78fcbc..a0da1a15074 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4776,7 +4776,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
if (!Root)
return false;
- if (Root->getParent() != BB)
+ if (Root->getParent() != BB || isa<PHINode>(Root))
return false;
// Start analysis starting from Root instruction. If horizontal reduction is
// found, try to vectorize it. If it is not a horizontal reduction or
@@ -4797,7 +4797,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
if (!V)
continue;
auto *Inst = dyn_cast<Instruction>(V);
- if (!Inst || isa<PHINode>(Inst))
+ if (!Inst)
continue;
if (auto *BI = dyn_cast<BinaryOperator>(Inst)) {
HorizontalReduction HorRdx;
@@ -4831,9 +4831,14 @@ static bool tryToVectorizeHorReductionOrInstOperands(
}
// Try to vectorize operands.
+ // Continue analysis for the instruction from the same basic block only to
+ // save compile time.
if (++Level < RecursionMaxDepth)
for (auto *Op : Inst->operand_values())
- Stack.emplace_back(Op, Level);
+ if (VisitedInstrs.insert(Op).second)
+ if (auto *I = dyn_cast<Instruction>(Op))
+ if (!isa<PHINode>(Inst) && I->getParent() == BB)
+ Stack.emplace_back(Op, Level);
}
return Res;
}
OpenPOWER on IntegriCloud