[llvm] [InstCombine] Fold extended add/sub of the same type (PR #185259)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 00:16:25 PDT 2026


suoyuan666 wrote:

`zext` and `trunc` don't seem to be involved in the core of this optimization. I think this can be considered more general:

- `umin(a + b, lower bitwidth MAX)` --> `uadd.sat(a, b)`
- `smax(a - b, 0)` --> `usub.sat(a, b)`

I'm currently conducting this test locally, along with the other scenarios mentioned by sweiglbosker. Once my locally written test and existing tests pass, I will push and update the PR description.

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


More information about the llvm-commits mailing list