[llvm] [Instcombine] Lower to explicit subtraction + unsigned comparison (PR #170896)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 6 06:18:40 PST 2025


dtcxzyw wrote:

We try to recover this pattern into usubo in CodeGenPrepare. So usubo should be canonical in the middle-end.
https://github.com/llvm/llvm-project/blob/6bb786398efdbc496edd517e682caeaaefd46f6e/llvm/lib/CodeGen/CodeGenPrepare.cpp#L1732-L1736

The root cause is the inefficient lowering of usubo. Currently we lower the overflow bit of usubo into `x - y u> x` in `TargetLowering::expandUADDSUBO`:
https://github.com/llvm/llvm-project/blob/ddd770d97b2c4a071d4cd9cb471ed9a397e0135c/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp#L11467-L11471

If it causes some regressions after we change it into `x u> y`, at least we can implement a custom lowering for the RISC-V backend.


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


More information about the llvm-commits mailing list