forked from OSchip/llvm-project
[DAG] expandAddSubSat - break if-else chain. NFCI.
Fix styleguide issue - each if() block always returns so we don't need to make them a if-else chain.
This commit is contained in:
parent
a754dc2358
commit
73adc26ac0
|
@ -7892,8 +7892,7 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
|
||||||
|
|
||||||
unsigned BitWidth = LHS.getScalarValueSizeInBits();
|
unsigned BitWidth = LHS.getScalarValueSizeInBits();
|
||||||
EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
|
EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
|
||||||
SDValue Result = DAG.getNode(OverflowOp, dl, DAG.getVTList(VT, BoolVT),
|
SDValue Result = DAG.getNode(OverflowOp, dl, DAG.getVTList(VT, BoolVT), LHS, RHS);
|
||||||
LHS, RHS);
|
|
||||||
SDValue SumDiff = Result.getValue(0);
|
SDValue SumDiff = Result.getValue(0);
|
||||||
SDValue Overflow = Result.getValue(1);
|
SDValue Overflow = Result.getValue(1);
|
||||||
SDValue Zero = DAG.getConstant(0, dl, VT);
|
SDValue Zero = DAG.getConstant(0, dl, VT);
|
||||||
|
@ -7907,7 +7906,9 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
|
||||||
}
|
}
|
||||||
// Overflow ? 0xffff.... : (LHS + RHS)
|
// Overflow ? 0xffff.... : (LHS + RHS)
|
||||||
return DAG.getSelect(dl, VT, Overflow, AllOnes, SumDiff);
|
return DAG.getSelect(dl, VT, Overflow, AllOnes, SumDiff);
|
||||||
} else if (Opcode == ISD::USUBSAT) {
|
}
|
||||||
|
|
||||||
|
if (Opcode == ISD::USUBSAT) {
|
||||||
if (getBooleanContents(VT) == ZeroOrNegativeOneBooleanContent) {
|
if (getBooleanContents(VT) == ZeroOrNegativeOneBooleanContent) {
|
||||||
// (LHS - RHS) & ~OverflowMask
|
// (LHS - RHS) & ~OverflowMask
|
||||||
SDValue OverflowMask = DAG.getSExtOrTrunc(Overflow, dl, VT);
|
SDValue OverflowMask = DAG.getSExtOrTrunc(Overflow, dl, VT);
|
||||||
|
@ -7916,17 +7917,17 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
|
||||||
}
|
}
|
||||||
// Overflow ? 0 : (LHS - RHS)
|
// Overflow ? 0 : (LHS - RHS)
|
||||||
return DAG.getSelect(dl, VT, Overflow, Zero, SumDiff);
|
return DAG.getSelect(dl, VT, Overflow, Zero, SumDiff);
|
||||||
} else {
|
|
||||||
// SatMax -> Overflow && SumDiff < 0
|
|
||||||
// SatMin -> Overflow && SumDiff >= 0
|
|
||||||
APInt MinVal = APInt::getSignedMinValue(BitWidth);
|
|
||||||
APInt MaxVal = APInt::getSignedMaxValue(BitWidth);
|
|
||||||
SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
|
|
||||||
SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
|
|
||||||
SDValue SumNeg = DAG.getSetCC(dl, BoolVT, SumDiff, Zero, ISD::SETLT);
|
|
||||||
Result = DAG.getSelect(dl, VT, SumNeg, SatMax, SatMin);
|
|
||||||
return DAG.getSelect(dl, VT, Overflow, Result, SumDiff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SatMax -> Overflow && SumDiff < 0
|
||||||
|
// SatMin -> Overflow && SumDiff >= 0
|
||||||
|
APInt MinVal = APInt::getSignedMinValue(BitWidth);
|
||||||
|
APInt MaxVal = APInt::getSignedMaxValue(BitWidth);
|
||||||
|
SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
|
||||||
|
SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
|
||||||
|
SDValue SumNeg = DAG.getSetCC(dl, BoolVT, SumDiff, Zero, ISD::SETLT);
|
||||||
|
Result = DAG.getSelect(dl, VT, SumNeg, SatMax, SatMin);
|
||||||
|
return DAG.getSelect(dl, VT, Overflow, Result, SumDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue TargetLowering::expandShlSat(SDNode *Node, SelectionDAG &DAG) const {
|
SDValue TargetLowering::expandShlSat(SDNode *Node, SelectionDAG &DAG) const {
|
||||||
|
|
Loading…
Reference in New Issue