// 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();