[InstCombine] Combine select & Phi by same condition
authorMax Kazantsev <mkazantsev@azul.com>
Thu, 25 Jun 2020 03:42:16 +0000 (10:42 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Thu, 25 Jun 2020 03:44:10 +0000 (10:44 +0700)
commit1eeb7147878edb7c0c0fbf54bc3dffd43db271b8
tree252803bb2c8aec5598ee9f71bfc03e537b1f93d5
parenta5041987eddc21d37345d055cb7a51b3eb5ee698
[InstCombine] Combine select & Phi by same condition

This patch transforms
```
p = phi [x, y]
s = select cond, z, p
```
with
```
s = phi[x, z]
```
if we can prove that the Phi node takes values basing on select's condition.

Differential Revision: https://reviews.llvm.org/D82072
Reviewed By: nikic
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select.ll