[llvm] [SelectionDAG] Fix condition used for unsigned subtraction overflow (PR #170896)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 8 01:39:21 PST 2025
================
@@ -11466,7 +11466,9 @@ void TargetLowering::expandUADDSUBO(
DAG.getConstant(0, dl, Node->getValueType(0)), ISD::SETNE);
} else {
ISD::CondCode CC = IsAdd ? ISD::SETULT : ISD::SETUGT;
- SetCC = DAG.getSetCC(dl, SetCCType, Result, LHS, CC);
+ SDValue CompareLHS = IsAdd ? Result : LHS;
+ SDValue CompareRHS = IsAdd ? LHS : RHS;
----------------
jayfoad wrote:
Nit: for uadd, it doesn't matter whether you check `Result < LHS` or `Result < RHS`, so you could simplify this a bit:
```suggestion
SDValue CompareRHS = RHS;
```
Maybe it could even generate better code on average because RHS is supposed to be canonically simpler than LHS? Or maybe it is just pointless churn, in which case feel free to ignore the suggestion.
https://github.com/llvm/llvm-project/pull/170896
More information about the llvm-commits
mailing list