SimplifyCFG: preserve branch-weight metadata when creating a new switch from
authorManman Ren <mren@apple.com>
Tue, 11 Sep 2012 17:43:35 +0000 (17:43 +0000)
committerManman Ren <mren@apple.com>
Tue, 11 Sep 2012 17:43:35 +0000 (17:43 +0000)
commit020aba0c3b6092e353e133446cb6453f95f0d61b
treee0a60a2cc7b3c3d76b154786d7b6a5473a59b497
parenta6035773d8d29827a124e65c258adbf0dcbb1a5a
SimplifyCFG: preserve branch-weight metadata when creating a new switch from
a pair of switch/branch where both depend on the value of the same variable and
the default case of the first switch/branch goes to the second switch/branch.

Code clean up and fixed a few issues:
1> handling the case where some cases of the 2nd switch are invalidated
2> correctly calculate the weight for the 2nd switch when it is a conditional eq

Testing case is modified from Alastair's original patch.

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