summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2016-07-01 21:44:12 +0000
committerAlina Sbirlea <asbirlea@google.com>2016-07-01 21:44:12 +0000
commit8d8aa5dd6ce3c427fa0cf057acfc7ad4aef193dd (patch)
tree4a6daaa31e920236e7e11832a7022bf2f694dd27 /llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
parentc7bb34f6ec9714ee717ca2166e06aae2c34e9041 (diff)
downloadbcm5719-llvm-8d8aa5dd6ce3c427fa0cf057acfc7ad4aef193dd.tar.gz
bcm5719-llvm-8d8aa5dd6ce3c427fa0cf057acfc7ad4aef193dd.zip
Address two correctness issues in LoadStoreVectorizer
Summary: GetBoundryInstruction returns the last instruction as the instruction which follows or end(). Otherwise the last instruction in the boundry set is not being tested by isVectorizable(). Partially solve reordering of instructions. More extensive solution to follow. Reviewers: tstellarAMD, llvm-commits, jlebar Subscribers: escha, arsenm, mzolotukhin Differential Revision: http://reviews.llvm.org/D21934 llvm-svn: 274389
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp13
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;
OpenPOWER on IntegriCloud