Reland "Use a stable-sort when combining bases"
authorSterling Augustine <saugustine@google.com>
Thu, 17 Mar 2022 17:01:49 +0000 (10:01 -0700)
committerSterling Augustine <saugustine@google.com>
Thu, 17 Mar 2022 18:32:16 +0000 (11:32 -0700)
Differential Revision: https://reviews.llvm.org/D121922

llvm/lib/Target/ARM/ARMISelLowering.cpp

index 583b6b8..52d1734 100644 (file)
@@ -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();