[InstCombine] Generalize and-reduce pattern to handle `ne` case as well as `eq`
authorMax Kazantsev <mkazantsev@azul.com>
Mon, 31 Jan 2022 05:12:48 +0000 (12:12 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Mon, 31 Jan 2022 05:14:08 +0000 (12:14 +0700)
commit70b3beb0e22dd0eb33c6fcef019a24f9f1f09ef9
treef56c54663b6420664f147a093f812a461cd28035
parentf8a2cd67b9ad414508235b9bd1489651ed9938e6
[InstCombine] Generalize and-reduce pattern to handle `ne` case as well as `eq`

Following Sanjay's proposal from discussion in D118317, this patch
generalizes and-reduce handling to fold the following pattern
```
  icmp ne (bitcast(icmp ne (lhs, rhs)), 0)
```
into
```
  icmp ne (bitcast(lhs), bitcast(rhs))
```

https://alive2.llvm.org/ce/z/WDcuJ_

Differential Revision: https://reviews.llvm.org/D118431
Reviewed By: lebedev.ri
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-vec.ll
llvm/test/Transforms/InstCombine/reduction-or-sext-zext-i1.ll