diff options
| author | Pedro Lobo <pedro.lobo@tecnico.ulisboa.pt> | 2025-11-22 15:44:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-22 15:44:06 +0000 |
| commit | e8af134bb7f891caa49178c8a04a8ca944c611df (patch) | |
| tree | e67e6dd18345210bef83888631439db6a639426c /offload | |
| parent | cc4dd015ad4a1b33d43fbac00d62f6b309a96ff4 (diff) | |
[InstCombine] Generalize trunc-shift-icmp fold from (1 << Y) to (Pow2 << Y) (#169163)
Extends the `icmp(trunc(shl))` fold to handle any power of 2 constant as
the shift base, not just 1. This generalizes the following patterns by
adjusting the comparison offsets by `log2(Pow2)`.
```llvm
(trunc (1 << Y) to iN) == 0 --> Y u>= N
(trunc (1 << Y) to iN) != 0 --> Y u< N
(trunc (1 << Y) to iN) == 2**C --> Y == C
(trunc (1 << Y) to iN) != 2**C --> Y != C
; to
(trunc (Pow2 << Y) to iN) == 0 --> Y u>= N - log2(Pow2)
(trunc (Pow2 << Y) to iN) != 0 --> Y u< N - log2(Pow2)
(trunc (Pow2 << Y) to iN) == 2**C --> Y == C - log2(Pow2)
(trunc (Pow2 << Y) to iN) != 2**C --> Y != C - log2(Pow2)
```
Proof: https://alive2.llvm.org/ce/z/2zwTkp
Diffstat (limited to 'offload')
0 files changed, 0 insertions, 0 deletions
