[PATCH] SelectionDAG switch lowering: Replace unreachable default with most popular case.
Hans Wennborg
hans at chromium.org
Fri Dec 5 16:51:50 PST 2014
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2711
@@ +2710,3 @@
+ // destination.
+ DenseMap<const BasicBlock*, uint64_t> Popularity;
+ uint64_t MaxPop = 0;
----------------
majnemer wrote:
> `DenseMap<const BasicBlock *, uint64_t>`
Done.
================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2728-2735
@@ +2727,10 @@
+ // Remove cases that have been replaced by the default.
+ CaseItr I = Cases.begin();
+ while (I != Cases.end()) {
+ if (I->BB == Default) {
+ I = Cases.erase(I);
+ continue;
+ }
+ ++I;
+ }
+ }
----------------
majnemer wrote:
> How about `remove_if(Cases.begin(), Cases.end(), ...`
Nice :) Done.
http://reviews.llvm.org/D6510
More information about the llvm-commits
mailing list