[InstCombine] Simplify compare of Phi with constant inputs against a constant
authorMax Kazantsev <mkazantsev@azul.com>
Fri, 5 Jun 2020 09:43:45 +0000 (16:43 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Fri, 5 Jun 2020 10:02:47 +0000 (17:02 +0700)
commit16b7eb6dd1247dbe322061d33636a054d6c954dc
tree545afb027aa2c404b9071a8d96bef88c9ed0bab5
parent6d15451b175293cc98ef1d0fd9869ac71904e3bd
[InstCombine] Simplify compare of Phi with constant inputs against a constant

We can simplify
```
  icmp <pred> phi(C1, C2, ...), C
```
with
```
  phi(icmp(C1, C), icmp(C2, C), ...)
```
provided that all comparison of constants are constants themselves.

Differential Revision: https://reviews.llvm.org/D81151
Reviewed By: lebedev.ri
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
llvm/test/Transforms/InstCombine/zext-or-icmp.ll