[PATCH] D39995: [SelectionDAG] Make sorting predicate stronger to remove non-deterministic ordering

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 18:20:03 PST 2017


mgrang created this revision.
Herald added subscribers: kristof.beyls, aemerson.

This fixes failures in the following tests uncovered by https://reviews.llvm.org/D39245:

  LLVM :: CodeGen/ARM/ifcvt3.ll
  LLVM :: CodeGen/ARM/switch-minsize.ll


Repository:
  rL LLVM

https://reviews.llvm.org/D39995

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp


Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -9548,7 +9548,7 @@
     // Order cases by probability so the most likely case will be checked first.
     std::sort(W.FirstCluster, W.LastCluster + 1,
               [](const CaseCluster &a, const CaseCluster &b) {
-      return a.Prob > b.Prob;
+      return a.Prob != b.Prob ? a.Prob > b.Prob : a.Low < b.Low;
     });
 
     // Rearrange the case blocks so that the last one falls through if possible


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39995.122761.patch
Type: text/x-patch
Size: 637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171114/8fade1a3/attachment.bin>


More information about the llvm-commits mailing list