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

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 16:03:50 PDT 2015


majnemer added a subscriber: majnemer.

================
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");
----------------
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`?


http://reviews.llvm.org/D11995





More information about the llvm-commits mailing list