[PATCH] D39995: [SelectionDAG] Make sorting predicate stronger to remove non-deterministic ordering
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 10:11:43 PST 2017
hans added inline comments.
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:9551
[](const CaseCluster &a, const CaseCluster &b) {
- return a.Prob > b.Prob;
});
----------------
mgrang wrote:
> fhahn wrote:
> > I might be missing something but could we still end up with multiple clusters where `a.Prob == b.Prob && a.Low == b.Low` ? Then the order of those nodes would still be non-deterministic, no?
> @fhahn Thanks! I am not sure if we two clusters can have the same Low. How about I add another predicate a.High < b.High?
>
> The fallback option is to simply change this to use std::stable_sort but I wanted to avoid this if we can simply get by adding stronger predicates.
The CaseClusters can't overlap, so having the same Low should not be possible.
I like this fix. Please expand the "Order cases by probability" comment to explain what's going on here. It would also be nice to have a test for this.
Repository:
rL LLVM
https://reviews.llvm.org/D39995
More information about the llvm-commits
mailing list