[PATCH] D52002: Switch optimization for known maximum switch values

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 07:08:39 PDT 2018


hans added a comment.

Sorry for the slow response.

This is looking promising. I have a few comments, and also this needs a good test.



================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2157
+                                               MachineBasicBlock *SwitchBB,
+                                               bool OmitDefaultBranch) {
   SDLoc dl = getCurSDLoc();
----------------
Nit: I would call it OmitRangeCheck instead. And maybe this flag could be part of the JumpTableHeader instead, so we don't need to pass it around here?


================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:9958
         if (CurMBB == SwitchMBB) {
-          visitJumpTableHeader(*JT, *JTH, SwitchMBB);
+          bool UnreachableDefault =
+              isa<UnreachableInst>(SI.getDefaultDest()->getFirstNonPHIOrDbg());
----------------
Instead of checking for unreachable default here, I think we should check for it earlier, already when the WorkItems are created probably.


Repository:
  rL LLVM

https://reviews.llvm.org/D52002





More information about the llvm-commits mailing list