summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-08-13 00:04:12 +0000
committerJustin Lebar <jlebar@google.com>2016-08-13 00:04:12 +0000
commitd1675aadf6c730133f82288553d1e22f8313ff79 (patch)
tree35cba8981e1e6da866a88463f5c9c28733a56503 /llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
parent222ceff289a101cb5f318dc607a6ebe253e8b1e1 (diff)
downloadbcm5719-llvm-d1675aadf6c730133f82288553d1e22f8313ff79.tar.gz
bcm5719-llvm-d1675aadf6c730133f82288553d1e22f8313ff79.zip
[LSV] Use a set rather than an ArraySlice at the end of getVectorizablePrefix. NFC
Summary: This avoids a small O(n^2) loop. Reviewers: asbirlea Subscribers: mzolotukhin, llvm-commits, arsenm Differential Revision: https://reviews.llvm.org/D23473 llvm-svn: 278581
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
index 458d1446fdc..9fd0b8c3c25 100644
--- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -516,12 +516,11 @@ Vectorizer::getVectorizablePrefix(ArrayRef<Instruction *> Chain) {
// ChainInstrs[0, ChainInstrIdx). This is the largest vectorizable prefix of
// Chain. (Recall that Chain is in address order, but ChainInstrs is in BB
// order.)
- auto VectorizableChainInstrs =
- makeArrayRef(ChainInstrs.data(), ChainInstrIdx);
- unsigned ChainIdx, ChainLen;
- for (ChainIdx = 0, ChainLen = Chain.size(); ChainIdx < ChainLen; ++ChainIdx) {
- Instruction *I = Chain[ChainIdx];
- if (!is_contained(VectorizableChainInstrs, I))
+ SmallPtrSet<Instruction *, 8> VectorizableChainInstrs(
+ ChainInstrs.begin(), ChainInstrs.begin() + ChainInstrIdx);
+ unsigned ChainIdx = 0;
+ for (unsigned ChainLen = Chain.size(); ChainIdx < ChainLen; ++ChainIdx) {
+ if (!VectorizableChainInstrs.count(Chain[ChainIdx]))
break;
}
return Chain.slice(0, ChainIdx);
OpenPOWER on IntegriCloud