Switch lowering: order bit tests by branch weight.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hans Wennborg
2015-04-27 20:21:17 +00:00
parent d455682f39
commit 84145dcd08
2 changed files with 50 additions and 1 deletions

View File

@@ -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;
});