[llvm] [InstCombine] Fold select(X >s 0, 0, -X) | smax(X, 0) to abs(X) (PR #165200)

Wenju He via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 19:38:34 PDT 2025


wenju-he wrote:

> When we know X is never INT_MIN, `select(X >s 0, 0, -X)` may be folded into `smax(-X, 0)`: https://alive2.llvm.org/ce/z/wDiDh2 Currently we don't do this fold. Can you please also add a test with `smax(-X, 0) | smax(X, 0)` and leave it as a todo?

thanks, added 2 TODO tests in https://github.com/llvm/llvm-project/pull/165200/commits/1e9a8cedf135cb04e02050a7e48c019674211915

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


More information about the llvm-commits mailing list