[PATCH] SelectionDAG switch lowering: Replace unreachable default with most popular case.

David Majnemer david.majnemer at gmail.com
Fri Dec 5 16:34:06 PST 2014


================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2711
@@ +2710,3 @@
+    // destination.
+    DenseMap<const BasicBlock*, uint64_t> Popularity;
+    uint64_t MaxPop = 0;
----------------
`DenseMap<const BasicBlock *, uint64_t>`

================
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;
+    }
+  }
----------------
How about `remove_if(Cases.begin(), Cases.end(), ...`

http://reviews.llvm.org/D6510






More information about the llvm-commits mailing list