diff options
author | Michael Kuperstein <mkuper@google.com> | 2017-03-06 23:54:51 +0000 |
---|---|---|
committer | Michael Kuperstein <mkuper@google.com> | 2017-03-06 23:54:51 +0000 |
commit | 768d013a036802ca80b6a4dd5d109dd78b1a1bf0 (patch) | |
tree | c2c812eb8fe28d240ce1ca6c1d5998641123997c /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | 4af068ea5510354bda588ba53430e31b6f9e60f6 (diff) | |
download | bcm5719-llvm-768d013a036802ca80b6a4dd5d109dd78b1a1bf0.tar.gz bcm5719-llvm-768d013a036802ca80b6a4dd5d109dd78b1a1bf0.zip |
[SLP] Revert r296863 due to miscompiles.
Details and reproducer are on the email thread for r296863.
llvm-svn: 297103
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 0d588b901a5..a3ed412b738 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1040,8 +1040,7 @@ static unsigned getAddressSpaceOperand(Value *I) { bool llvm::sortMemAccesses(ArrayRef<Value *> VL, const DataLayout &DL, ScalarEvolution &SE, - SmallVectorImpl<Value *> &Sorted, - SmallVectorImpl<unsigned> *Mask) { + SmallVectorImpl<Value *> &Sorted) { SmallVector<std::pair<int64_t, Value *>, 4> OffValPairs; OffValPairs.reserve(VL.size()); Sorted.reserve(VL.size()); @@ -1051,6 +1050,7 @@ bool llvm::sortMemAccesses(ArrayRef<Value *> VL, const DataLayout &DL, Value *Ptr0 = getPointerOperand(VL[0]); const SCEV *Scev0 = SE.getSCEV(Ptr0); Value *Obj0 = GetUnderlyingObject(Ptr0, DL); + for (auto *Val : VL) { // The only kind of access we care about here is load. if (!isa<LoadInst>(Val)) @@ -1077,30 +1077,14 @@ bool llvm::sortMemAccesses(ArrayRef<Value *> VL, const DataLayout &DL, OffValPairs.emplace_back(Diff->getAPInt().getSExtValue(), Val); } - SmallVector<unsigned, 4> UseOrder(VL.size()); - for (unsigned i = 0; i < VL.size(); i++) { - UseOrder[i] = i; - } - - // Sort the memory accesses and keep the order of their uses in UseOrder. - std::sort(UseOrder.begin(), UseOrder.end(), - [&OffValPairs](unsigned Left, unsigned Right) { - return OffValPairs[Left].first < OffValPairs[Right].first; + std::sort(OffValPairs.begin(), OffValPairs.end(), + [](const std::pair<int64_t, Value *> &Left, + const std::pair<int64_t, Value *> &Right) { + return Left.first < Right.first; }); - for (unsigned i = 0; i < VL.size(); i++) - Sorted.emplace_back(OffValPairs[UseOrder[i]].second); - - // Sort UseOrder to compute the Mask. - if (Mask) { - Mask->reserve(VL.size()); - for (unsigned i = 0; i < VL.size(); i++) - Mask->emplace_back(i); - std::sort(Mask->begin(), Mask->end(), - [&UseOrder](unsigned Left, unsigned Right) { - return UseOrder[Left] < UseOrder[Right]; - }); - } + for (auto &it : OffValPairs) + Sorted.push_back(it.second); return true; } |