[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:25:13 PDT 2015


sanjoy added inline comments.

================
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");
----------------
sanjoy wrote:
> 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.
> I don't think checking for >= is sufficient if switches allow duplicate cases, if that's how number of case can be greater than 2^Bits.

I had missed your note in the commit message -- given that duplicate values are prohibited, I think it should be sufficient to check for equality.


http://reviews.llvm.org/D11995





More information about the llvm-commits mailing list