diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 583b6b8afb5f3b..52d173439e463d 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -15977,10 +15977,10 @@ static SDValue CombineBaseUpdate(SDNode *N, // Try to fold with other users. Non-constant updates are considered // first, and constant updates are sorted to not break a sequence of // strided accesses (if there is any). - std::sort(BaseUpdates.begin(), BaseUpdates.end(), - [](BaseUpdateUser &LHS, BaseUpdateUser &RHS) { - return LHS.ConstInc < RHS.ConstInc; - }); + std::stable_sort(BaseUpdates.begin(), BaseUpdates.end(), + [](const BaseUpdateUser &LHS, const BaseUpdateUser &RHS) { + return LHS.ConstInc < RHS.ConstInc; + }); for (BaseUpdateUser &User : BaseUpdates) { if (TryCombineBaseUpdate(Target, User, /*SimpleConstIncOnly=*/false, DCI)) return SDValue();