[mlir] Use llvm::stable_sort (NFC) (#141186)

This commit is contained in:
Kazu Hirata
2025-05-22 22:36:32 -07:00
committed by GitHub
parent 9c62446024
commit 6464238dc0
6 changed files with 20 additions and 21 deletions

View File

@@ -404,7 +404,7 @@ void LoopEmitter::categorizeIterators(
spIters.push_back(it);
}
std::stable_sort(spIters.begin(), spIters.end(), [](auto lhs, auto rhs) {
llvm::stable_sort(spIters, [](auto lhs, auto rhs) {
// AffineUnRed > Affine > Slice > Trivial
return static_cast<uint8_t>(lhs->kind) > static_cast<uint8_t>(rhs->kind);
});

View File

@@ -979,7 +979,7 @@ struct ParallelDiagnosticHandlerImpl : public llvm::PrettyStackTraceEntry {
// Stable sort all of the diagnostics that were emitted. This creates a
// deterministic ordering for the diagnostics based upon which order id they
// were emitted for.
std::stable_sort(diagnostics.begin(), diagnostics.end());
llvm::stable_sort(diagnostics);
// Emit each diagnostic to the context again.
for (ThreadDiagnostic &diag : diagnostics)

View File

@@ -2346,10 +2346,10 @@ void PDLByteCode::match(Operation *op, PatternRewriter &rewriter,
assert(succeeded(executeResult) && "unexpected matcher execution failure");
// Order the found matches by benefit.
std::stable_sort(matches.begin(), matches.end(),
[](const MatchResult &lhs, const MatchResult &rhs) {
return lhs.benefit > rhs.benefit;
});
llvm::stable_sort(matches,
[](const MatchResult &lhs, const MatchResult &rhs) {
return lhs.benefit > rhs.benefit;
});
}
LogicalResult PDLByteCode::rewrite(PatternRewriter &rewriter,

View File

@@ -103,7 +103,7 @@ void PatternApplicator::applyCostModel(CostModel model) {
// Sort patterns with highest benefit first, and remove those that are
// impossible to match.
std::stable_sort(list.begin(), list.end(), cmp);
llvm::stable_sort(list, cmp);
while (!list.empty() && benefits[list.back()].isImpossibleToMatch()) {
LLVM_DEBUG(logImpossibleToMatch(*list.back()));
list.pop_back();

View File

@@ -297,8 +297,7 @@ public:
}
// Sort the operands.
std::stable_sort(commOperands.begin(), commOperands.end(),
commutativeOperandComparator);
llvm::stable_sort(commOperands, commutativeOperandComparator);
SmallVector<Value, 2> sortedOperands;
for (const std::unique_ptr<CommutativeOperand> &commOperand : commOperands)
sortedOperands.push_back(commOperand->operand);

View File

@@ -2520,19 +2520,19 @@ unsigned OperationLegalizer::applyCostModelToPatterns(
return minDepth;
// Sort the patterns by those likely to be the most beneficial.
std::stable_sort(patternsByDepth.begin(), patternsByDepth.end(),
[](const std::pair<const Pattern *, unsigned> &lhs,
const std::pair<const Pattern *, unsigned> &rhs) {
// First sort by the smaller pattern legalization
// depth.
if (lhs.second != rhs.second)
return lhs.second < rhs.second;
llvm::stable_sort(patternsByDepth,
[](const std::pair<const Pattern *, unsigned> &lhs,
const std::pair<const Pattern *, unsigned> &rhs) {
// First sort by the smaller pattern legalization
// depth.
if (lhs.second != rhs.second)
return lhs.second < rhs.second;
// Then sort by the larger pattern benefit.
auto lhsBenefit = lhs.first->getBenefit();
auto rhsBenefit = rhs.first->getBenefit();
return lhsBenefit > rhsBenefit;
});
// Then sort by the larger pattern benefit.
auto lhsBenefit = lhs.first->getBenefit();
auto rhsBenefit = rhs.first->getBenefit();
return lhsBenefit > rhsBenefit;
});
// Update the legalization pattern to use the new sorted list.
patterns.clear();