summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-01-14 15:43:34 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-01-14 15:43:34 +0000
commita1bd4a6ba46672564261f40f4ab9a9b1d0ae35d0 (patch)
tree2957ad75373512e19838ffb71deafc2a054af66e /llvm/lib/CodeGen
parentfa1f5187482c12e949953e0b65f652af022e9d43 (diff)
downloadbcm5719-llvm-a1bd4a6ba46672564261f40f4ab9a9b1d0ae35d0.tar.gz
bcm5719-llvm-a1bd4a6ba46672564261f40f4ab9a9b1d0ae35d0.zip
[DAGCombiner] Add (sub_sat x, x) -> 0 combine
llvm-svn: 351073
Diffstat (limited to 'llvm/lib/CodeGen')
-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 d564bda7987..b1770920f06 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2800,6 +2800,10 @@ SDValue DAGCombiner::visitSUBSAT(SDNode *N) {
if (N0.isUndef() || N1.isUndef())
return DAG.getConstant(0, DL, VT);
+ // fold (sub_sat x, x) -> 0
+ if (N0 == N1)
+ return DAG.getConstant(0, DL, VT);
+
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
DAG.isConstantIntBuildVectorOrConstantInt(N1)) {
// fold (sub_sat c1, c2) -> c3
OpenPOWER on IntegriCloud