[PATCH] D11995: [SimplifyCFG] Prune code from a provably unreachable switch default

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 15:21:59 PDT 2015


sanjoy added a comment.

Minor drop by comments inline.  I'll let someone more familiar with this bit of code do a proper review.


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:3256
@@ +3255,3 @@
+  if (HasDefault && DeadCases.empty() && 
+      SI->getNumCases() >= pow(2,Bits)) {
+    DEBUG(dbgs() << "SimplifyCFG: switch default is dead.\n");
----------------
Can `SI->getNumCases()` ever be `> pow(2, Bits)`?

I don't think checking for `>=` is sufficient if `switch`es allow duplicate cases, if that's how number of case can be greater than 2^Bits.

================
Comment at: test/Transforms/SimplifyCFG/switch-dead-default.ll:25
@@ +24,3 @@
+                                i2 3, label %case3
+                                i2 4, label %case4]
+case1:
----------------
Interesting -- I did not know that `i2 4` worked -- I presume this is the same as `i2 0`?


http://reviews.llvm.org/D11995





More information about the llvm-commits mailing list