summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-08-02 14:38:07 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-08-02 14:38:07 +0000
commit36e6096a031d88611ca65a364143530584212e4b (patch)
treee7bf7bee4c35c8eb9fcb96fb147f096c0220d81b /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
parent4e93a6986e4619a1235cac5e02e43ba02e671db3 (diff)
downloadbcm5719-llvm-36e6096a031d88611ca65a364143530584212e4b.tar.gz
bcm5719-llvm-36e6096a031d88611ca65a364143530584212e4b.zip
[SLPVectorizer] Generalize interface of functions, NFC.
llvm-svn: 309816
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 11bc030e312..1e0e0ac4d09 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4352,15 +4352,18 @@ bool SLPVectorizerPass::tryToVectorizeList(ArrayRef<Value *> VL, BoUpSLP &R,
return Changed;
}
-bool SLPVectorizerPass::tryToVectorize(BinaryOperator *V, BoUpSLP &R) {
- if (!V)
+bool SLPVectorizerPass::tryToVectorize(Instruction *I, BoUpSLP &R) {
+ if (!I)
+ return false;
+
+ if (!isa<BinaryOperator>(I))
return false;
- Value *P = V->getParent();
+ Value *P = I->getParent();
// Vectorize in current basic block only.
- auto *Op0 = dyn_cast<Instruction>(V->getOperand(0));
- auto *Op1 = dyn_cast<Instruction>(V->getOperand(1));
+ auto *Op0 = dyn_cast<Instruction>(I->getOperand(0));
+ auto *Op1 = dyn_cast<Instruction>(I->getOperand(1));
if (!Op0 || !Op1 || Op0->getParent() != P || Op1->getParent() != P)
return false;
@@ -5015,7 +5018,7 @@ static Value *getReductionValue(const DominatorTree *DT, PHINode *P,
static bool tryToVectorizeHorReductionOrInstOperands(
PHINode *P, Instruction *Root, BasicBlock *BB, BoUpSLP &R,
TargetTransformInfo *TTI,
- const function_ref<bool(BinaryOperator *, BoUpSLP &)> Vectorize) {
+ const function_ref<bool(Instruction *, BoUpSLP &)> Vectorize) {
if (!ShouldVectorizeHor)
return false;
@@ -5071,7 +5074,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
// Set P to nullptr to avoid re-analysis of phi node in
// matchAssociativeReduction function unless this is the root node.
P = nullptr;
- if (Vectorize(dyn_cast<BinaryOperator>(Inst), R)) {
+ if (Vectorize(Inst, R)) {
Res = true;
continue;
}
@@ -5101,10 +5104,11 @@ bool SLPVectorizerPass::vectorizeRootInstruction(PHINode *P, Value *V,
if (!isa<BinaryOperator>(I))
P = nullptr;
// Try to match and vectorize a horizontal reduction.
- return tryToVectorizeHorReductionOrInstOperands(
- P, I, BB, R, TTI, [this](BinaryOperator *BI, BoUpSLP &R) -> bool {
- return tryToVectorize(BI, R);
- });
+ auto &&ExtraVectorization = [this](Instruction *I, BoUpSLP &R) -> bool {
+ return tryToVectorize(I, R);
+ };
+ return tryToVectorizeHorReductionOrInstOperands(P, I, BB, R, TTI,
+ ExtraVectorization);
}
bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
OpenPOWER on IntegriCloud