[InstCombine] Improve bitreverse optimization
authorAustin Chang <austin880625@gmail.com>
Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 25 May 2023 18:41:32 +0000 (13:41 -0500)
commit68c5d46b6ec46c59afa052d2b2945ca7b22f58d6
tree8985aafa46535f1a10d2356a0d23da9749fae79a
parent1d1f7eeee6bf38ef35083f676875950b4f5528f7
[InstCombine] Improve bitreverse optimization

This patch utilizes the helper function implemented in D149699 and thus folds the following cases:

```
bitreverse(logic_op(x, bitreverse(y))) -> logic_op(bitreverse(x), y)
bitreverse(logic_op(bitreverse(x), y)) -> logic_op(x, bitreverse(y))
bitreverse(logic_op(bitreverse(x), bitreverse(y))) -> logic_op(x, y) in multiuse case
```

Reviewed By: goldstein.w.n, RKSimon

Differential Revision: https://reviews.llvm.org/D151246
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/bitreverse.ll