[llvm] [SelectionDAG] Lowering usub.sat(a, 1) to a - (a != 0) (PR #170076)

guan jian via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 6 04:16:13 PST 2025


================
@@ -10867,6 +10867,16 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
   assert(VT == RHS.getValueType() && "Expected operands to be the same type");
   assert(VT.isInteger() && "Expected operands to be integers");
 
+  // usub.sat(a, 1) -> sub(a, zext(a != 0))
+  if (Opcode == ISD::USUBSAT && isOneConstant(RHS)) {
----------------
rez5427 wrote:

I saw some regressions on some test files, I use `!VT.isVector() && isOneConstant(RHS)` now.

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


More information about the llvm-commits mailing list