diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-01-14 12:34:31 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-01-14 12:34:31 +0000 |
commit | cfa5f06dde800c9d9207199b3764405aa0afc57e (patch) | |
tree | 5a52cbf5f207c71f943f80f53363799d3b7a0d46 /llvm/lib/CodeGen | |
parent | 4c4c0377ca6c6d35fa60934f1624252c1e38f901 (diff) | |
download | bcm5719-llvm-cfa5f06dde800c9d9207199b3764405aa0afc57e.tar.gz bcm5719-llvm-cfa5f06dde800c9d9207199b3764405aa0afc57e.zip |
[DAGCombiner] Enable add saturation constant folding
llvm-svn: 351060
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 580a668100b..9a40774cff8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2198,8 +2198,9 @@ SDValue DAGCombiner::visitADDSAT(SDNode *N) { // canonicalize constant to RHS if (!DAG.isConstantIntBuildVectorOrConstantInt(N1)) return DAG.getNode(Opcode, DL, VT, N1, N0); - - // TODO Constant Folding + // fold (add_sat c1, c2) -> c3 + return DAG.FoldConstantArithmetic(Opcode, DL, VT, N0.getNode(), + N1.getNode()); } // fold (add_sat x, 0) -> x diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 23a7b3ece82..a0ee80c0dcd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4488,6 +4488,8 @@ static std::pair<APInt, bool> FoldValue(unsigned Opcode, const APInt &C1, case ISD::SMAX: return std::make_pair(C1.sge(C2) ? C1 : C2, true); case ISD::UMIN: return std::make_pair(C1.ule(C2) ? C1 : C2, true); case ISD::UMAX: return std::make_pair(C1.uge(C2) ? C1 : C2, true); + case ISD::SADDSAT: return std::make_pair(C1.sadd_sat(C2), true); + case ISD::UADDSAT: return std::make_pair(C1.uadd_sat(C2), true); case ISD::UDIV: if (!C2.getBoolValue()) break; |