[llvm] 8141726 - Use a stable-sort when combining bases
Sterling Augustine via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 17 09:04:16 PDT 2022
Author: Sterling Augustine
Date: 2022-03-17T09:02:13-07:00
New Revision: 81417261a15f46284f2613118120d7d6de2bc02d
URL: https://github.com/llvm/llvm-project/commit/81417261a15f46284f2613118120d7d6de2bc02d
DIFF: https://github.com/llvm/llvm-project/commit/81417261a15f46284f2613118120d7d6de2bc02d.diff
LOG: Use a stable-sort when combining bases
While experimenting with different algorithms for std::sort
I discovered that combine-vmovdrr.ll fails if this sort is not
stable.
I suspect that the test is too stringent in its check--the resultant
code looks functionally identical to me under both stable and unstable
sorting, but a generic fix is quite a bit more difficult to implement.
Thanks to scw at google.com for finding the proper fix.
Differential Revision: https://reviews.llvm.org/D121870
Added:
Modified:
llvm/lib/Target/ARM/ARMISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 583b6b8afb5f3..f0e3b988642a7 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(),
+ [](BaseUpdateUser &LHS, BaseUpdateUser &RHS) {
+ return LHS.ConstInc < RHS.ConstInc;
+ });
for (BaseUpdateUser &User : BaseUpdates) {
if (TryCombineBaseUpdate(Target, User, /*SimpleConstIncOnly=*/false, DCI))
return SDValue();
More information about the llvm-commits
mailing list