[SimplifyCFG] Prune code from a provably unreachable switch default
authorPhilip Reames <listmail@philipreames.com>
Wed, 26 Aug 2015 23:56:46 +0000 (23:56 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 26 Aug 2015 23:56:46 +0000 (23:56 +0000)
commit287d051e44138575ef345a3fdf66381a0b73e005
tree6da754efaf4749742cedea78189325eb96417e52
parent251711d0537702067716810652d9561d8213e7a9
[SimplifyCFG] Prune code from a provably unreachable switch default

As Sanjoy pointed out over in http://reviews.llvm.org/D11819, a switch on an icmp should always be able to become a branch instruction. This patch generalizes that notion slightly to prove that the default case of a switch is unreachable if the cases completely cover all possible bit patterns in the condition. Once that's done, the switch to branch conversion kicks in just fine.

Note: Duplicate case values are disallowed by the LangRef and verifier.

Differential Revision: http://reviews.llvm.org/D11995

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246125 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/switch-dead-default.ll [new file with mode: 0644]