diff options
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index b571b5a..16196b0 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1579,6 +1579,7 @@ static bool matchUAddWithOverflowConstantEdgeCases(CmpInst *Cmp, /// intrinsic. Return true if any changes were made. bool CodeGenPrepare::combineToUAddWithOverflow(CmpInst *Cmp, ModifyDT &ModifiedDT) { + bool EdgeCase = false; Value *A, *B; BinaryOperator *Add; if (!match(Cmp, m_UAddWithOverflow(m_Value(A), m_Value(B), m_BinOp(Add)))) { @@ -1587,11 +1588,12 @@ bool CodeGenPrepare::combineToUAddWithOverflow(CmpInst *Cmp, // Set A and B in case we match matchUAddWithOverflowConstantEdgeCases. A = Add->getOperand(0); B = Add->getOperand(1); + EdgeCase = true; } if (!TLI->shouldFormOverflowOp(ISD::UADDO, TLI->getValueType(*DL, Add->getType()), - Add->hasNUsesOrMore(2))) + Add->hasNUsesOrMore(EdgeCase ? 1 : 2))) return false; // We don't want to move around uses of condition values this late, so we @@ -1660,7 +1662,7 @@ bool CodeGenPrepare::combineToUSubWithOverflow(CmpInst *Cmp, if (!TLI->shouldFormOverflowOp(ISD::USUBO, TLI->getValueType(*DL, Sub->getType()), - Sub->hasNUsesOrMore(2))) + Sub->hasNUsesOrMore(1))) return false; if (!replaceMathCmpWithIntrinsic(Sub, Sub->getOperand(0), Sub->getOperand(1), |