summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-01-13 22:08:26 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-01-13 22:08:26 +0000
commit56ba1db933ea7fc3e993c31fce176bbf8578a64c (patch)
tree5c04eaa89447b62795988a159e2d33bac5c47058 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent888fa8680cdd09f0b196c853b4982ddb3a5682c9 (diff)
downloadbcm5719-llvm-56ba1db933ea7fc3e993c31fce176bbf8578a64c.tar.gz
bcm5719-llvm-56ba1db933ea7fc3e993c31fce176bbf8578a64c.zip
[DAGCombiner] If add_sat(x,y) can't overflow -> add(x,y)
NOTE: We need more powerful signed overflow detection in computeOverflowKind llvm-svn: 351026
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b3785359f81..6d828d3972d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2206,6 +2206,10 @@ SDValue DAGCombiner::visitADDSAT(SDNode *N) {
if (isNullConstant(N1))
return N0;
+ // If it cannot overflow, transform into an add.
+ if (DAG.computeOverflowKind(N0, N1) == SelectionDAG::OFK_Never)
+ return DAG.getNode(ISD::ADD, DL, VT, N0, N1);
+
return SDValue();
}
OpenPOWER on IntegriCloud