Skip to content

Commit 6464238

Browse files
[mlir] Use llvm::stable_sort (NFC) (#141186)
1 parent 9c62446 commit 6464238

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ void LoopEmitter::categorizeIterators(
404404
spIters.push_back(it);
405405
}
406406

407-
std::stable_sort(spIters.begin(), spIters.end(), [](auto lhs, auto rhs) {
407+
llvm::stable_sort(spIters, [](auto lhs, auto rhs) {
408408
// AffineUnRed > Affine > Slice > Trivial
409409
return static_cast<uint8_t>(lhs->kind) > static_cast<uint8_t>(rhs->kind);
410410
});

mlir/lib/IR/Diagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
979979
// Stable sort all of the diagnostics that were emitted. This creates a
980980
// deterministic ordering for the diagnostics based upon which order id they
981981
// were emitted for.
982-
std::stable_sort(diagnostics.begin(), diagnostics.end());
982+
llvm::stable_sort(diagnostics);
983983

984984
// Emit each diagnostic to the context again.
985985
for (ThreadDiagnostic &diag : diagnostics)

mlir/lib/Rewrite/ByteCode.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,10 +2346,10 @@ void PDLByteCode::match(Operation *op, PatternRewriter &rewriter,
23462346
assert(succeeded(executeResult) && "unexpected matcher execution failure");
23472347

23482348
// Order the found matches by benefit.
2349-
std::stable_sort(matches.begin(), matches.end(),
2350-
[](const MatchResult &lhs, const MatchResult &rhs) {
2351-
return lhs.benefit > rhs.benefit;
2352-
});
2349+
llvm::stable_sort(matches,
2350+
[](const MatchResult &lhs, const MatchResult &rhs) {
2351+
return lhs.benefit > rhs.benefit;
2352+
});
23532353
}
23542354

23552355
LogicalResult PDLByteCode::rewrite(PatternRewriter &rewriter,

mlir/lib/Rewrite/PatternApplicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void PatternApplicator::applyCostModel(CostModel model) {
103103

104104
// Sort patterns with highest benefit first, and remove those that are
105105
// impossible to match.
106-
std::stable_sort(list.begin(), list.end(), cmp);
106+
llvm::stable_sort(list, cmp);
107107
while (!list.empty() && benefits[list.back()].isImpossibleToMatch()) {
108108
LLVM_DEBUG(logImpossibleToMatch(*list.back()));
109109
list.pop_back();

mlir/lib/Transforms/Utils/CommutativityUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ class SortCommutativeOperands : public RewritePattern {
297297
}
298298

299299
// Sort the operands.
300-
std::stable_sort(commOperands.begin(), commOperands.end(),
301-
commutativeOperandComparator);
300+
llvm::stable_sort(commOperands, commutativeOperandComparator);
302301
SmallVector<Value, 2> sortedOperands;
303302
for (const std::unique_ptr<CommutativeOperand> &commOperand : commOperands)
304303
sortedOperands.push_back(commOperand->operand);

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,19 +2520,19 @@ unsigned OperationLegalizer::applyCostModelToPatterns(
25202520
return minDepth;
25212521

25222522
// Sort the patterns by those likely to be the most beneficial.
2523-
std::stable_sort(patternsByDepth.begin(), patternsByDepth.end(),
2524-
[](const std::pair<const Pattern *, unsigned> &lhs,
2525-
const std::pair<const Pattern *, unsigned> &rhs) {
2526-
// First sort by the smaller pattern legalization
2527-
// depth.
2528-
if (lhs.second != rhs.second)
2529-
return lhs.second < rhs.second;
2530-
2531-
// Then sort by the larger pattern benefit.
2532-
auto lhsBenefit = lhs.first->getBenefit();
2533-
auto rhsBenefit = rhs.first->getBenefit();
2534-
return lhsBenefit > rhsBenefit;
2535-
});
2523+
llvm::stable_sort(patternsByDepth,
2524+
[](const std::pair<const Pattern *, unsigned> &lhs,
2525+
const std::pair<const Pattern *, unsigned> &rhs) {
2526+
// First sort by the smaller pattern legalization
2527+
// depth.
2528+
if (lhs.second != rhs.second)
2529+
return lhs.second < rhs.second;
2530+
2531+
// Then sort by the larger pattern benefit.
2532+
auto lhsBenefit = lhs.first->getBenefit();
2533+
auto rhsBenefit = rhs.first->getBenefit();
2534+
return lhsBenefit > rhsBenefit;
2535+
});
25362536

25372537
// Update the legalization pattern to use the new sorted list.
25382538
patterns.clear();

0 commit comments

Comments
 (0)