summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
diff options
context:
space:
mode:
authorYevgeny Rouban <yevgeny.rouban@azul.com>2019-02-01 06:44:08 +0000
committerYevgeny Rouban <yevgeny.rouban@azul.com>2019-02-01 06:44:08 +0000
commit4cdd7839552decf3d753cf6c3b38d26db838a2b1 (patch)
tree18a85ab2b258df628cbf7d6c0b352142d97c2bad /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
parent5ef88bdb68234b21b2ecda683dfe2f76513502d9 (diff)
downloadbcm5719-llvm-4cdd7839552decf3d753cf6c3b38d26db838a2b1.tar.gz
bcm5719-llvm-4cdd7839552decf3d753cf6c3b38d26db838a2b1.zip
[SLPVectorizer] Get rid of IndexQueue array from vectorizeStores. NFCI.
Indices are checked as they are generated. No need to fill the whole array of indices. Differential Revision: https://reviews.llvm.org/D57144 llvm-svn: 352839
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b0157ee0f1c..d040f8eba86 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4746,38 +4746,29 @@ bool SLPVectorizerPass::vectorizeStores(ArrayRef<StoreInst *> Stores,
BoUpSLP::ValueSet VectorizedStores;
bool Changed = false;
- // Do a quadratic search on all of the given stores in reverse order and find
- // all of the pairs of stores that follow each other.
- SmallVector<unsigned, 16> IndexQueue;
- unsigned E = Stores.size();
- IndexQueue.resize(E - 1);
- for (unsigned I = E; I > 0; --I) {
- unsigned Idx = I - 1;
- // If a store has multiple consecutive store candidates, search Stores
- // array according to the sequence: Idx-1, Idx+1, Idx-2, Idx+2, ...
- // This is because usually pairing with immediate succeeding or preceding
- // candidate create the best chance to find slp vectorization opportunity.
- unsigned Offset = 1;
- unsigned Cnt = 0;
- for (unsigned J = 0; J < E - 1; ++J, ++Offset) {
- if (Idx >= Offset) {
- IndexQueue[Cnt] = Idx - Offset;
- ++Cnt;
- }
- if (Idx + Offset < E) {
- IndexQueue[Cnt] = Idx + Offset;
- ++Cnt;
- }
- }
+ auto &&FindConsecutiveAccess =
+ [this, &Stores, &Heads, &Tails, &ConsecutiveChain] (int K, int Idx) {
+ if (!isConsecutiveAccess(Stores[K], Stores[Idx], *DL, *SE))
+ return false;
- for (auto K : IndexQueue) {
- if (isConsecutiveAccess(Stores[K], Stores[Idx], *DL, *SE)) {
Tails.insert(Stores[Idx]);
Heads.insert(Stores[K]);
ConsecutiveChain[Stores[K]] = Stores[Idx];
+ return true;
+ };
+
+ // Do a quadratic search on all of the given stores in reverse order and find
+ // all of the pairs of stores that follow each other.
+ int E = Stores.size();
+ for (int Idx = E - 1; Idx >= 0; --Idx) {
+ // If a store has multiple consecutive store candidates, search according
+ // to the sequence: Idx-1, Idx+1, Idx-2, Idx+2, ...
+ // This is because usually pairing with immediate succeeding or preceding
+ // candidate create the best chance to find slp vectorization opportunity.
+ for (int Offset = 1, F = std::max(E - Idx, Idx + 1); Offset < F; ++Offset)
+ if ((Idx >= Offset && FindConsecutiveAccess(Idx - Offset, Idx)) ||
+ (Idx + Offset < E && FindConsecutiveAccess(Idx + Offset, Idx)))
break;
- }
- }
}
// For stores that start but don't end a link in the chain:
OpenPOWER on IntegriCloud