[PATCH] D21291: [SimplifyCFG] Range reduce switches

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 19 14:59:00 PDT 2016

eli.friedman added inline comments.

Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8332
@@ +8331,3 @@
+                                C.High->getValue().lshr(Shift));
+    C.Low = C.High = cast<ConstantInt>(CI);
+  }
Do we need to merge clusters in some cases, so we don't end up with adjacent clusters with the same destination?  (This doesn't affect building a jump table, but it affects isDense.)

Hmm... actually, more generally, whether we transform a switch condition is to some extent independent of whether we form a jump table; for example, if we end up with one cluster here, you don't need a jump table at all.  Maybe we can leave that for a followup, though.

Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h:267
@@ +266,3 @@
+      if (Shift == 0)
+        this->Base = First;
+    }
It's unintuitive to hide this in the constructor... it seems like a good idea to push the Shift == 0 special-case out.



More information about the llvm-commits mailing list