summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-04-23 14:51:27 +0000
committerFangrui Song <maskray@google.com>2019-04-23 14:51:27 +0000
commitefd94c56badf696ed7193f4a83c7a59f7dfbfc6e (patch)
tree63f7a8a57c367cf6ba845a80eda9177b62c516be /llvm/lib/Transforms/Scalar
parent99cf58339fceadee43ba3fdbf962a083cd5af6c4 (diff)
downloadbcm5719-llvm-efd94c56badf696ed7193f4a83c7a59f7dfbfc6e.tar.gz
bcm5719-llvm-efd94c56badf696ed7193f4a83c7a59f7dfbfc6e.zip
Use llvm::stable_sort
While touching the code, simplify if feasible. llvm-svn: 358996
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/ConstantHoisting.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/GVNSink.cpp5
-rw-r--r--llvm/lib/Transforms/Scalar/LoopSink.cpp7
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp8
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp7
6 files changed, 13 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
index 683cf32eb30..98243a23f1e 100644
--- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -647,8 +647,8 @@ void ConstantHoistingPass::findBaseConstants(GlobalVariable *BaseGV) {
ConstGEPInfoMap[BaseGV] : ConstIntInfoVec;
// Sort the constants by value and type. This invalidates the mapping!
- std::stable_sort(ConstCandVec.begin(), ConstCandVec.end(),
- [](const ConstantCandidate &LHS, const ConstantCandidate &RHS) {
+ llvm::stable_sort(ConstCandVec, [](const ConstantCandidate &LHS,
+ const ConstantCandidate &RHS) {
if (LHS.ConstInt->getType() != RHS.ConstInt->getType())
return LHS.ConstInt->getType()->getBitWidth() <
RHS.ConstInt->getType()->getBitWidth();
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index ca8f92c3887..7614599653c 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -702,7 +702,7 @@ private:
// Vector of PHIs contains PHIs for different instructions.
// Sort the args according to their VNs, such that identical
// instructions are together.
- std::stable_sort(CHIs.begin(), CHIs.end(), cmpVN);
+ llvm::stable_sort(CHIs, cmpVN);
auto TI = BB->getTerminator();
auto B = CHIs.begin();
// [PreIt, PHIIt) form a range of CHIs which have identical VNs.
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 94cc219a4a7..bf5ec47fbbb 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -790,10 +790,7 @@ unsigned GVNSink::sinkBB(BasicBlock *BBEnd) {
--LRI;
}
- std::stable_sort(
- Candidates.begin(), Candidates.end(),
- [](const SinkingInstructionCandidate &A,
- const SinkingInstructionCandidate &B) { return A > B; });
+ llvm::stable_sort(Candidates, std::greater<SinkingInstructionCandidate>());
LLVM_DEBUG(dbgs() << " -- Sinking candidates:\n"; for (auto &C
: Candidates) dbgs()
<< " " << C << "\n";);
diff --git a/llvm/lib/Transforms/Scalar/LoopSink.cpp b/llvm/lib/Transforms/Scalar/LoopSink.cpp
index 3235b639c9e..975452e13f0 100644
--- a/llvm/lib/Transforms/Scalar/LoopSink.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSink.cpp
@@ -290,10 +290,9 @@ static bool sinkLoopInvariantInstructions(Loop &L, AAResults &AA, LoopInfo &LI,
ColdLoopBBs.push_back(B);
LoopBlockNumber[B] = ++i;
}
- std::stable_sort(ColdLoopBBs.begin(), ColdLoopBBs.end(),
- [&](BasicBlock *A, BasicBlock *B) {
- return BFI.getBlockFreq(A) < BFI.getBlockFreq(B);
- });
+ llvm::stable_sort(ColdLoopBBs, [&](BasicBlock *A, BasicBlock *B) {
+ return BFI.getBlockFreq(A) < BFI.getBlockFreq(B);
+ });
// Traverse preheader's instructions in reverse order becaue if A depends
// on B (A appears after B), A needs to be sinked first before B can be
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 34066aea27d..7cdfce84559 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -1328,8 +1328,7 @@ Value *ReassociatePass::OptimizeXor(Instruction *I,
// So, if Rank(X) < Rank(Y) < Rank(Z), it means X is defined earlier
// than Y which is defined earlier than Z. Permute "x | 1", "Y & 2",
// "z" in the order of X-Y-Z is better than any other orders.
- std::stable_sort(OpndPtrs.begin(), OpndPtrs.end(),
- [](XorOpnd *LHS, XorOpnd *RHS) {
+ llvm::stable_sort(OpndPtrs, [](XorOpnd *LHS, XorOpnd *RHS) {
return LHS->getSymbolicRank() < RHS->getSymbolicRank();
});
@@ -1686,8 +1685,7 @@ static bool collectMultiplyFactors(SmallVectorImpl<ValueEntry> &Ops,
// below our mininum of '4'.
assert(FactorPowerSum >= 4);
- std::stable_sort(Factors.begin(), Factors.end(),
- [](const Factor &LHS, const Factor &RHS) {
+ llvm::stable_sort(Factors, [](const Factor &LHS, const Factor &RHS) {
return LHS.Power > RHS.Power;
});
return true;
@@ -2141,7 +2139,7 @@ void ReassociatePass::ReassociateExpression(BinaryOperator *I) {
// positions maintained (and so the compiler is deterministic). Note that
// this sorts so that the highest ranking values end up at the beginning of
// the vector.
- std::stable_sort(Ops.begin(), Ops.end());
+ llvm::stable_sort(Ops);
// Now that we have the expression tree in a convenient
// sorted form, optimize it globally if possible.
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index d748d967a5e..06d65b55890 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1722,10 +1722,9 @@ static bool rebuildLoopAfterUnswitch(Loop &L, ArrayRef<BasicBlock *> ExitBlocks,
// Sort the exits in ascending loop depth, we'll work backwards across these
// to process them inside out.
- std::stable_sort(ExitsInLoops.begin(), ExitsInLoops.end(),
- [&](BasicBlock *LHS, BasicBlock *RHS) {
- return LI.getLoopDepth(LHS) < LI.getLoopDepth(RHS);
- });
+ llvm::stable_sort(ExitsInLoops, [&](BasicBlock *LHS, BasicBlock *RHS) {
+ return LI.getLoopDepth(LHS) < LI.getLoopDepth(RHS);
+ });
// We'll build up a set for each exit loop.
SmallPtrSet<BasicBlock *, 16> NewExitLoopBlocks;
OpenPOWER on IntegriCloud