diff options
author | Hans Wennborg <hans@hanshq.net> | 2015-04-27 20:21:17 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2015-04-27 20:21:17 +0000 |
commit | ba6d2568f91c34e30bf5a967c7d8d8fde20723f9 (patch) | |
tree | 0a6c5b7c0734c3cf2cd0ab509a73e27b5aac5368 /llvm/lib/CodeGen | |
parent | 1a848da518991408d9a3b10fd03dcd63e8185918 (diff) | |
download | bcm5719-llvm-ba6d2568f91c34e30bf5a967c7d8d8fde20723f9.tar.gz bcm5719-llvm-ba6d2568f91c34e30bf5a967c7d8d8fde20723f9.zip |
Switch lowering: order bit tests by branch weight.
llvm-svn: 235912
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index fd59d57580b..d7edd2c1966 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7482,12 +7482,15 @@ bool SelectionDAGBuilder::buildBitTests(CaseClusterVector &Clusters, CB->Bits++; } CB->ExtraWeight += Clusters[i].Weight; + assert(CB->ExtraWeight >= Clusters[i].Weight && "Weight sum overflowed!"); TotalWeight += Clusters[i].Weight; } BitTestInfo BTI; std::sort(CBV.begin(), CBV.end(), [](const CaseBits &a, const CaseBits &b) { - // FIXME: Sort by weight. + // Sort by weight first, number of bits second. + if (a.ExtraWeight != b.ExtraWeight) + return a.ExtraWeight > b.ExtraWeight; return a.Bits > b.Bits; }); |