[PATCH] D121870: Use a stable-sort when combining bases
Sterling Augustine via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 16:40:43 PDT 2022
saugustine created this revision.
Herald added subscribers: mgrang, hiraditya.
Herald added a project: All.
saugustine requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121870
Files:
llvm/lib/Target/ARM/ARMISelLowering.cpp
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -15977,10 +15977,10 @@
// 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121870.416024.patch
Type: text/x-patch
Size: 956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220316/4f57ee09/attachment.bin>
More information about the llvm-commits
mailing list