[llvm] [InstCombine] fold unsigned predicates on srem result (PR #122520)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 20:35:58 PST 2025


https://github.com/dtcxzyw requested changes to this pull request.

I think this optimization is too specific.
For your motivating case, we can simply convert `icmp ugt (srem i32 %x, 8), -2147483648` into `icmp slt (srem i32 %x, 8), 0`. Then InstCombine will convert the remain expression into `ashr X, 3`: https://godbolt.org/z/Y7K5hd7c3

Generalized proof: https://alive2.llvm.org/ce/z/gST2A5

https://github.com/llvm/llvm-project/pull/122520


More information about the llvm-commits mailing list