diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -2300,21 +2300,19 @@ return minDepth; // Sort the patterns by those likely to be the most beneficial. - llvm::array_pod_sort(patternsByDepth.begin(), patternsByDepth.end(), - [](const std::pair *lhs, - const std::pair *rhs) { - // First sort by the smaller pattern legalization - // depth. - if (lhs->second != rhs->second) - return llvm::array_pod_sort_comparator( - &lhs->second, &rhs->second); - - // Then sort by the larger pattern benefit. - auto lhsBenefit = lhs->first->getBenefit(); - auto rhsBenefit = rhs->first->getBenefit(); - return llvm::array_pod_sort_comparator( - &rhsBenefit, &lhsBenefit); - }); + std::stable_sort(patternsByDepth.begin(), patternsByDepth.end(), + [](const std::pair &lhs, + const std::pair &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; + }); // Update the legalization pattern to use the new sorted list. patterns.clear();