llvm-project
265b032b - [InstCombine] Added optimisation for trunc (Pow2 >> x) to i1 (#157030)

Commit
13 days ago
[InstCombine] Added optimisation for trunc (Pow2 >> x) to i1 (#157030) Closes #156898 I have added two cases. The first one matches when the constant is exactly power of 2. The second case was to address the general case mentioned in the linked issue. I, however, did not really solve the general case. We can only emit a `icmp ult` if all the bits are one and that's only the case when the constant + 1 is a power of 2. Otherwise, we need to create `icmp eq` for every bit that is one. Here are a few examples which won't be working with the two cases: - constant is `9`: https://alive2.llvm.org/ce/z/S5FLJZ - subrange in `56`: https://alive2.llvm.org/ce/z/yn_ZNG - and finally an example as worst case (because it alternates the bits): https://alive2.llvm.org/ce/z/nDitNA
Author
Parents
Loading