[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 16:13:12 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");
----------------
majnemer wrote:
> reames wrote:
> > sanjoy wrote:
> > > hans wrote:
> > > > 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.
> > > > ultra nit: space between , and 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.
> > I'll switch to the equality before submission.
> `pow` uses doubles, was this intentional?
> 
> Could we use `1U << Bits` or `1ULL << Bits`?
> Could we use 1U << Bits or 1ULL << Bits?

Won't that break if `Bits` is > 64?


http://reviews.llvm.org/D11995





More information about the llvm-commits mailing list