aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-07-12 00:04:18 +0000
committerNadav Rotem <nrotem@apple.com>2013-07-12 00:04:18 +0000
commit931b861e3dcf966fde46d57683013e74736eb448 (patch)
treea0150891b9c88eb362e8cd0a87a6105ec918b2c0 /lib/Transforms
parent2c3c7fd6960de68e8c27fdf8f7e73796acb5f4c5 (diff)
downloadexternal_llvm-931b861e3dcf966fde46d57683013e74736eb448.zip
external_llvm-931b861e3dcf966fde46d57683013e74736eb448.tar.gz
external_llvm-931b861e3dcf966fde46d57683013e74736eb448.tar.bz2
SLPVectorize: Replace the code that checks for vectorization candidates in successor blocks with code that scans PHINodes.
Before we could vectorize PHINodes scanning successors was a good way of finding candidates. Now we can vectorize the phinodes which is simpler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Vectorize/SLPVectorizer.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 7b9be65..2cf843d 100644
--- a/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1550,8 +1550,7 @@ private:
/// \brief Try to vectorize a chain that starts at two arithmetic instrs.
bool tryToVectorizePair(Value *A, Value *B, BoUpSLP &R);
- /// \brief Try to vectorize a list of operands. If \p NeedExtracts is true
- /// then we calculate the cost of extracting the scalars from the vector.
+ /// \brief Try to vectorize a list of operands.
/// \returns true if a value was vectorized.
bool tryToVectorizeList(ArrayRef<Value *> VL, BoUpSLP &R);
@@ -1791,6 +1790,27 @@ bool SLPVectorizer::tryToVectorize(BinaryOperator *V, BoUpSLP &R) {
bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
bool Changed = false;
+ SmallVector<Value *, 4> Incoming;
+ // Collect the incoming values from the PHIs.
+ for (BasicBlock::iterator instr = BB->begin(), ie = BB->end(); instr != ie;
+ ++instr) {
+ PHINode *P = dyn_cast<PHINode>(instr);
+
+ if (!P)
+ break;
+
+ // Stop constructing the list when you reach a different type.
+ if (Incoming.size() && P->getType() != Incoming[0]->getType()) {
+ Changed |= tryToVectorizeList(Incoming, R);
+ Incoming.clear();
+ }
+
+ Incoming.push_back(P);
+ }
+
+ if (Incoming.size() > 1)
+ Changed |= tryToVectorizeList(Incoming, R);
+
for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e; ++it) {
if (isa<DbgInfoIntrinsic>(it))
continue;
@@ -1831,29 +1851,6 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
}
}
- // Scan the PHINodes in our successors in search for pairing hints.
- for (succ_iterator it = succ_begin(BB), e = succ_end(BB); it != e; ++it) {
- BasicBlock *Succ = *it;
- SmallVector<Value *, 4> Incoming;
-
- // Collect the incoming values from the PHIs.
- for (BasicBlock::iterator instr = Succ->begin(), ie = Succ->end();
- instr != ie; ++instr) {
- PHINode *P = dyn_cast<PHINode>(instr);
-
- if (!P)
- break;
-
- Value *V = P->getIncomingValueForBlock(BB);
- if (Instruction *I = dyn_cast<Instruction>(V))
- if (I->getParent() == BB)
- Incoming.push_back(I);
- }
-
- if (Incoming.size() > 1)
- Changed |= tryToVectorizeList(Incoming, R);
- }
-
return Changed;
}