[llvm] [InstCombine] Fold comparisons of urem with dividend (PR #214933)

Hadong Lee via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 05:21:34 PDT 2026


ChrisLee02 wrote:

> No real-world benefits shown in https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/872/files
> 
> Besides, it also loses the relationship between `X urem Y ` and `X`, causing `umax(X - (X urem Y), 1)` to not be eliminated after this patch. We should teach InstSimplify to use the relationship between X and Y to simplify the icmp first (similar to #214381).

Thanks for pointing this out. I'll first try teaching InstSimplify about this relationship to address the `umax` regression, and add a regression test.

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


More information about the llvm-commits mailing list