diff options
author | Hans Wennborg <hans@hanshq.net> | 2015-04-27 23:35:22 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2015-04-27 23:35:22 +0000 |
commit | 67c03759e4f788d61c4475094295d42f7b8a2a15 (patch) | |
tree | ff18d945c442ab8620b63da68d3fdde4402b8b25 /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | 753e007091a7e70029750e68bcd5b82ab886830a (diff) | |
download | bcm5719-llvm-67c03759e4f788d61c4475094295d42f7b8a2a15.tar.gz bcm5719-llvm-67c03759e4f788d61c4475094295d42f7b8a2a15.zip |
Switch lowering: Take branch weight into account when ordering for fall-through
Previously, the code would try to put a fall-through case last,
even if that meant moving a case with much higher branch weight
further down the chain.
Ordering by branch weight is most important, putting a fall-through
block last is secondary.
llvm-svn: 235942
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index d7edd2c1966..985a4dfd49d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7678,11 +7678,12 @@ void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond, return a.Weight > b.Weight; }); - // Rearrange the case blocks so that the last one falls through if possible. - // Start at the bottom as that's the case with the lowest weight. - // FIXME: Take branch probability into account. + // Rearrange the case blocks so that the last one falls through if possible + // without without changing the order of weights. for (CaseClusterIt I = W.LastCluster; I > W.FirstCluster; ) { --I; + if (I->Weight > W.LastCluster->Weight) + break; if (I->Kind == CC_Range && I->MBB == NextMBB) { std::swap(*I, *W.LastCluster); break; |