diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-03-06 16:06:27 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-03-06 16:06:27 +0000 |
commit | 1fefc30b08714f3a56b815bde26bb70f63b08df8 (patch) | |
tree | 7f6cd88bbcf6c1aaba3bd37bd993c52753b78d72 /llvm/lib/CodeGen | |
parent | 3d467a890e35edd913f8dee394da00744a1b58ce (diff) | |
download | bcm5719-llvm-1fefc30b08714f3a56b815bde26bb70f63b08df8.tar.gz bcm5719-llvm-1fefc30b08714f3a56b815bde26bb70f63b08df8.zip |
[TargetLowering] simplify code for uaddsat/usubsat expansion; NFC
We had 2 local variable names for the same type.
llvm-svn: 355516
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index f9d02af8959..c4b46dd9f3d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -5393,10 +5393,8 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const { EVT VT = LHS.getValueType(); SDLoc dl(Node); - assert(LHS.getValueType().isInteger() && "Expected operands to be integers"); - assert(RHS.getValueType().isInteger() && "Expected operands to be integers"); - assert(LHS.getValueType() == RHS.getValueType() && - "Expected both operands to be the same type"); + assert(VT == RHS.getValueType() && "Expected operands to be the same type"); + assert(VT.isInteger() && "Expected operands to be integers"); // usub.sat(a, b) -> umax(a, b) - b if (Opcode == ISD::USUBSAT && isOperationLegalOrCustom(ISD::UMAX, VT)) { @@ -5430,32 +5428,30 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const { } unsigned BitWidth = LHS.getScalarValueSizeInBits(); - EVT ResultType = LHS.getValueType(); - EVT BoolVT = - getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), ResultType); - SDValue Result = - DAG.getNode(OverflowOp, dl, DAG.getVTList(ResultType, BoolVT), LHS, RHS); + EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT); + SDValue Result = DAG.getNode(OverflowOp, dl, DAG.getVTList(VT, BoolVT), + LHS, RHS); SDValue SumDiff = Result.getValue(0); SDValue Overflow = Result.getValue(1); - SDValue Zero = DAG.getConstant(0, dl, ResultType); - SDValue AllOnes = DAG.getAllOnesConstant(dl, ResultType); + SDValue Zero = DAG.getConstant(0, dl, VT); + SDValue AllOnes = DAG.getAllOnesConstant(dl, VT); if (Opcode == ISD::UADDSAT) { // Overflow ? 0xffff.... : (LHS + RHS) - return DAG.getSelect(dl, ResultType, Overflow, AllOnes, SumDiff); + return DAG.getSelect(dl, VT, Overflow, AllOnes, SumDiff); } else if (Opcode == ISD::USUBSAT) { // Overflow ? 0 : (LHS - RHS) - return DAG.getSelect(dl, ResultType, 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, ResultType); - SDValue SatMax = DAG.getConstant(MaxVal, dl, ResultType); + 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, ResultType, SumNeg, SatMax, SatMin); - return DAG.getSelect(dl, ResultType, Overflow, Result, SumDiff); + Result = DAG.getSelect(dl, VT, SumNeg, SatMax, SatMin); + return DAG.getSelect(dl, VT, Overflow, Result, SumDiff); } } |