[llvm] [X86] Resolve FIXME: Accept live flag if no overflow occurs (PR #86836)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 11:14:02 PDT 2024
================
@@ -54539,9 +54552,14 @@ static SDValue combineADC(SDNode *N, SelectionDAG &DAG,
}
// Fold ADC(ADD(X,Y),0,Carry) -> ADC(X,Y,Carry)
- // iff the flag result is dead.
+ // iff the flag result is dead or if X + Y are known to not overflow.
if (LHS.getOpcode() == ISD::ADD && RHSC && RHSC->isZero() &&
- !N->hasAnyUseOfValue(1))
+ (!N->hasAnyUseOfValue(1) ||
+ (DAG.computeOverflowForSignedAdd(LHS.getOperand(0), LHS.getOperand(1)) ==
+ SelectionDAG::OverflowKind::OFK_Never &&
+ DAG.computeOverflowForUnsignedAdd(LHS.getOperand(0),
+ LHS.getOperand(1)) ==
+ SelectionDAG::OverflowKind::OFK_Never)))
----------------
RKSimon wrote:
```
willNotOverflowAdd(true, LHS.getOperand(0), LHS.getOperand(1)) &&
willNotOverflowAdd(false, LHS.getOperand(0), LHS.getOperand(1))
```
https://github.com/llvm/llvm-project/pull/86836
More information about the llvm-commits
mailing list