OSDN Git Service

[SimplifyCFG] Use known bits to eliminate dead switch defaults
authorPhilip Reames <listmail@philipreames.com>
Thu, 10 Sep 2015 17:44:47 +0000 (17:44 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 10 Sep 2015 17:44:47 +0000 (17:44 +0000)
commit5d8f37f825cec858600981175c9f25303ad98bd5
tree70d23c087bf877c6dd40b9b7dc48fe83738ff2e4
parent4b5f4e5618d5daf8c5394ae0c22fa00ebc428cec
[SimplifyCFG] Use known bits to eliminate dead switch defaults

This is a follow up to http://reviews.llvm.org/D11995 implementing the suggestion by Hans.

If we know some of the bits of the value being switched on, we know that the maximum number of unique cases covers the unknown bits. This allows to eliminate switch defaults for large integers (i32) when most bits in the value are known.

Note that I had to make the transform contingent on not having any dead cases. This is conservatively correct with the old code, but required for the new code since we might have a dead case which varies one of the known bits. Counting that towards our number of covering cases would be bad.  If we do have dead cases, we'll eliminate them first, then revisit the possibly dead default.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247309 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/switch-dead-default.ll