summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-28 19:19:09 +0000
committerNikita Popov <nikita.ppv@gmail.com>2019-01-28 19:19:09 +0000
commit8e1a464e6ad8b81a4ae3ba3fa07a176e2ba23152 (patch)
tree212f47f6d28526a9ec895c5f47ab6b6eb186c8d4 /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
parent1c3694a4d47be9dcf635d2dda6f70928a3bd2f25 (diff)
downloadbcm5719-llvm-8e1a464e6ad8b81a4ae3ba3fa07a176e2ba23152.tar.gz
bcm5719-llvm-8e1a464e6ad8b81a4ae3ba3fa07a176e2ba23152.zip
[CodeGen][X86] Expand UADDSAT to NOT+UMIN+ADD
Followup to D56636, this time handling the UADDSAT case by expanding uadd.sat(a, b) to umin(a, ~b) + b. Differential Revision: https://reviews.llvm.org/D56869 llvm-svn: 352409
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 5d8f3851980..a07b2594153 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5287,6 +5287,12 @@ SDValue TargetLowering::expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const {
return DAG.getNode(ISD::SUB, dl, VT, Max, RHS);
}
+ if (Opcode == ISD::UADDSAT && isOperationLegalOrCustom(ISD::UMIN, VT)) {
+ SDValue InvRHS = DAG.getNOT(dl, RHS, VT);
+ SDValue Min = DAG.getNode(ISD::UMIN, dl, VT, LHS, InvRHS);
+ return DAG.getNode(ISD::ADD, dl, VT, Min, RHS);
+ }
+
if (VT.isVector()) {
// TODO: Consider not scalarizing here.
return SDValue();
OpenPOWER on IntegriCloud