diff --git a/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp b/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp --- a/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp @@ -48,10 +48,9 @@ int64_t numOperands = op.getNumOperands(); SmallVector operandPositions = llvm::to_vector(llvm::seq(0, numOperands)); - std::sort(operandPositions.begin(), operandPositions.end(), - [&numInvariant](size_t i1, size_t i2) { - return numInvariant[i1] > numInvariant[i2]; - }); + llvm::stable_sort(operandPositions, [&numInvariant](size_t i1, size_t i2) { + return numInvariant[i1] > numInvariant[i2]; + }); SmallVector replacements(numOperands); SmallVector operands(numOperands); @@ -144,10 +143,9 @@ return i; return -1; }; - std::sort(subExpressions.begin(), subExpressions.end(), - [&](AffineExpr e1, AffineExpr e2) { - return getMaxSymbol(e1) < getMaxSymbol(e2); - }); + llvm::stable_sort(subExpressions, [&](AffineExpr e1, AffineExpr e2) { + return getMaxSymbol(e1) < getMaxSymbol(e2); + }); LLVM_DEBUG( llvm::interleaveComma(subExpressions, DBGS() << "--sorted subexprs: "); llvm::dbgs() << "\n");