[llvm] [InstCombine]: Fold OR bit tests (PR #178366)
Kang-Che Sung 宋岡哲 via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 22:52:00 PST 2026
Explorer09 wrote:
As I mentioned in the original report (#167199). This pattern should be a multi-step reduction. I don't think it's appropriate to implement directly from `((x & (c0<<y)) != 0) || ((x & (c1<<y)) != 0)` to `((x & ((c0|c1)<<y)) != 0)`.
```text
((x & (c0<<y)) != 0) || ((x & (c1<<y)) != 0)
→ (((x & (c0<<y)) | (x & (c1<<y))) != 0)
→ ((x & ((c0<<y) | (c1<<y))) != 0)
→ ((x & ((c0|c1)<<y)) != 0)
```
```text
(a != 0 || b != 0) → (a | b) != 0
(a & b | a & c) → (a & (b | c))
((a << y) | (b << y)) → (a | b) << y
```
Yeah. That should be three rules.
https://github.com/llvm/llvm-project/pull/178366
More information about the llvm-commits
mailing list