[llvm] r309425 - [SLP] Allow vectorization of the instruction from the same basic blocks only, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 13:11:17 PDT 2017
Author: abataev
Date: Fri Jul 28 13:11:16 2017
New Revision: 309425
URL: http://llvm.org/viewvc/llvm-project?rev=309425&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=309425&r1=309424&r2=309425&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Fri Jul 28 13:11:16 2017
@@ -4776,7 +4776,7 @@ static bool tryToVectorizeHorReductionOr
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 tryToVectorizeHorReductionOr
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 tryToVectorizeHorReductionOr
}
// 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;
}
More information about the llvm-commits
mailing list