[PATCH] AArch64: Make AArch64A57FPLoadBalancing output stable.
Geoff Berry
gberry at codeaurora.org
Fri Jan 30 07:47:51 PST 2015
Hi James,
No, I don’t think just switching to std::stable_sort() would solve the problem. The elements that are “equal” based on the sort comparison would remain in their original order before the sort, which I believe is determined by the order they occur in the EquivalenceClasses member iterator, which is in turn determined by pointer order since the EquivalenceClasses members are stored in a set<Chain*> in this case.
Hopefully that makes sense. If so, could you commit this change?
Thanks,
-Geoff
--
Geoff Berry
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
From: James Molloy [mailto:james at jamesmolloy.co.uk]
Sent: Friday, January 30, 2015 3:41 AM
To: reviews+D7265+public+9863efb7948c8628 at reviews.llvm.org; gberry at codeaurora.org; james.molloy at arm.com; mcrosier at codeaurora.org; apazos at codeaurora.org
Cc: llvm-commits at cs.uiuc.edu; kanheim at a-bix.com
Subject: Re: [PATCH] AArch64: Make AArch64A57FPLoadBalancing output stable.
Hi Geoff,
Thanks for fixing this! It looks ok as-is, but wouldn't switching simply from std::sort to std::stable_sort solve the problem easier? Stable_sort is used for this reason in other areas of the compiler.
Cheers,
James
On Fri, 30 Jan 2015 at 03:51, Geoff Berry <gberry at codeaurora.org <mailto:gberry at codeaurora.org> > wrote:
Hi jmolloy, mcrosier, apazos,
Add tie breaker to colorChainSet() sort so that processing order doesn't
depend on std::set order, which depends on pointer order, which is
unstable from run to run.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7265
Files:
lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
Index: lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
===================================================================
--- lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
+++ lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
@@ -259,7 +259,7 @@
}
/// Return true if this chain starts before Other.
- bool startsBefore(Chain *Other) {
+ bool startsBefore(const Chain *Other) const {
return StartInstIdx < Other->StartInstIdx;
}
@@ -431,10 +431,17 @@
// chains that we cannot change before we look at those we can,
// so the parity counter is updated and we know what color we should
// change them to!
+ // Final tie-break with instruction order so pass output is stable (i.e. not
+ // dependent on malloc'd pointer values).
std::sort(GV.begin(), GV.end(), [](const Chain *G1, const Chain *G2) {
if (G1->size() != G2->size())
return G1->size() > G2->size();
- return G1->requiresFixup() > G2->requiresFixup();
+ if (G1->requiresFixup() != G2->requiresFixup())
+ return G1->requiresFixup() > G2->requiresFixup();
+ // Make sure startsBefore() produces a stable final order.
+ assert((G1 == G2 || (G1->startsBefore(G2) ^ G2->startsBefore(G1))) &&
+ "Starts before not total order!");
+ return G1->startsBefore(G2);
});
Color PreferredColor = Parity < 0 ? Color::Even : Color::Odd;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/fc5682ce/attachment.html>
More information about the llvm-commits
mailing list