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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 08:35:46 PDT 2025


https://github.com/dtcxzyw commented:

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?


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


More information about the llvm-commits mailing list