[JumpThreading] Split select that has constant conditions coming from the PHI node
authorHaicheng Wu <haicheng@codeaurora.org>
Fri, 8 Jan 2016 19:39:39 +0000 (19:39 +0000)
committerHaicheng Wu <haicheng@codeaurora.org>
Fri, 8 Jan 2016 19:39:39 +0000 (19:39 +0000)
commit1d3fb4f73625f1728e79cd14774fa11890fd2b89
tree5007385efdb9b6a5779938ab742362e36ecf13e4
parent3bd93089a9b944e40edb913871c2a67972ed0af7
[JumpThreading] Split select that has constant conditions coming from the PHI node

Look for PHI/Select in the same BB of the form

bb:
  %p = phi [false, %bb1], [true, %bb2], [false, %bb3], [true, %bb4], ...
  %s = select p, trueval, falseval

And expand the select into a branch structure. This later enables
jump-threading over bb in this pass.

Using the similar approach of SimplifyCFG::FoldCondBranchOnPHI(), unfold
select if the associated PHI has at least one constant.  If the unfolded
select is not jump-threaded, it will be folded again in the later
optimizations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257198 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/select.ll