diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-05-30 19:27:26 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-05-30 19:27:26 +0000 |
commit | 9ff3159b4aede9a53d65e67ada4a7e2ba1aaa301 (patch) | |
tree | e7947465dc31942074d5b74bd4fbde695fb13698 /llvm/lib/CodeGen | |
parent | cc9a9cf2378493ac3ba1f71a754561abbe0a766b (diff) | |
download | bcm5719-llvm-9ff3159b4aede9a53d65e67ada4a7e2ba1aaa301.tar.gz bcm5719-llvm-9ff3159b4aede9a53d65e67ada4a7e2ba1aaa301.zip |
[DAGCombine] Use FoldConstantArithmetic() to perform C2-(A+C1) -> (C2-C1)-A fold
Summary:
No tests change, and i'm not sure how to test this, but it's better safe than sorry.
Reviewers: spatel, RKSimon, craig.topper, t.p.northover
Reviewed By: craig.topper
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62663
llvm-svn: 362132
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9a06077587d..c04dbd276cf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2868,7 +2868,9 @@ SDValue DAGCombiner::visitSUB(SDNode *N) { SDValue N11 = N1.getOperand(1); if (isConstantOrConstantVector(N0, /* NoOpaques */ true) && isConstantOrConstantVector(N11, /* NoOpaques */ true)) { - SDValue NewC = DAG.getNode(ISD::SUB, DL, VT, N0, N11); + SDValue NewC = DAG.FoldConstantArithmetic(ISD::SUB, DL, VT, N0.getNode(), + N11.getNode()); + assert(NewC && "Constant folding failed"); return DAG.getNode(ISD::SUB, DL, VT, NewC, N1.getOperand(0)); } } |