diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index f24628eb2f5..2f8a470b4c0 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -331,6 +331,7 @@ bool Vectorizer::isConsecutiveAccess(Value *A, Value *B) { } void Vectorizer::reorder(Instruction *I) { + Instruction *InsertAfter = I; for (User *U : I->users()) { Instruction *User = dyn_cast<Instruction>(U); if (!User || User->getOpcode() == Instruction::PHI) @@ -338,7 +339,8 @@ void Vectorizer::reorder(Instruction *I) { if (!DT.dominates(I, User)) { User->removeFromParent(); - User->insertAfter(I); + User->insertAfter(InsertAfter); + InsertAfter = User; reorder(User); } } @@ -359,13 +361,15 @@ Vectorizer::getBoundaryInstrs(ArrayRef<Value *> Chain) { ++NumFound; if (NumFound == 1) { FirstInstr = I.getIterator(); - } else if (NumFound == Chain.size()) { + } + if (NumFound == Chain.size()) { LastInstr = I.getIterator(); break; } } - return std::make_pair(FirstInstr, LastInstr); + // Range is [first, last). + return std::make_pair(FirstInstr, ++LastInstr); } void Vectorizer::eraseInstructions(ArrayRef<Value *> Chain) { @@ -415,6 +419,9 @@ bool Vectorizer::isVectorizable(ArrayRef<Value *> Chain, } } + assert(Chain.size() == ChainInstrs.size() && + "All instructions in the Chain must exist in [From, To)."); + for (auto EntryMem : MemoryInstrs) { Value *V = EntryMem.first; unsigned VIdx = EntryMem.second; |