diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-10 19:06:38 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-10 19:06:38 +0000 |
commit | a0e96bd56d99d6313b15af0900859a8cb3ad73df (patch) | |
tree | 61dc104e97810fed9563a231dfd8c1b6409c5b0c /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | e8adbae00a3e78795a653dadb58425cb89050e4c (diff) | |
download | bcm5719-llvm-a0e96bd56d99d6313b15af0900859a8cb3ad73df.tar.gz bcm5719-llvm-a0e96bd56d99d6313b15af0900859a8cb3ad73df.zip |
[CodeGen][X86] Don't scalarize vector saturating add/sub
Now that we have vector support for [US](ADD|SUB)O we no longer
need to scalarize when expanding [US](ADD|SUB)SAT.
This matches what the cost model already does.
Differential Revision: https://reviews.llvm.org/D57348
llvm-svn: 353651
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 370e0d5a088..26c495507cf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -5385,6 +5385,11 @@ 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"); + // usub.sat(a, b) -> umax(a, b) - b if (Opcode == ISD::USUBSAT && isOperationLegalOrCustom(ISD::UMAX, VT)) { SDValue Max = DAG.getNode(ISD::UMAX, dl, VT, LHS, RHS); @@ -5397,11 +5402,6 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const { return DAG.getNode(ISD::ADD, dl, VT, Min, RHS); } - if (VT.isVector()) { - // TODO: Consider not scalarizing here. - return SDValue(); - } - unsigned OverflowOp; switch (Opcode) { case ISD::SADDSAT: @@ -5421,16 +5421,7 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const { "addition or subtraction node."); } - assert(LHS.getValueType().isScalarInteger() && - "Expected operands to be integers. Vector of int arguments should " - "already be unrolled."); - assert(RHS.getValueType().isScalarInteger() && - "Expected operands to be integers. Vector of int arguments should " - "already be unrolled."); - assert(LHS.getValueType() == RHS.getValueType() && - "Expected both operands to be the same type"); - - unsigned BitWidth = LHS.getValueSizeInBits(); + unsigned BitWidth = LHS.getScalarValueSizeInBits(); EVT ResultType = LHS.getValueType(); EVT BoolVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), ResultType); |