summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-10-11 14:14:30 +0000
committerSanjay Patel <spatel@rotateright.com>2016-10-11 14:14:30 +0000
commit38a42e4bfa37e97f572c46d2d130d28b1ce7b696 (patch)
tree1c19619db65a816a7d85a98ac97ec245d7493e39 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent907ae691252863da2800bd7f1972cc2448333248 (diff)
downloadbcm5719-llvm-38a42e4bfa37e97f572c46d2d130d28b1ce7b696.tar.gz
bcm5719-llvm-38a42e4bfa37e97f572c46d2d130d28b1ce7b696.zip
[DAG] simplify logic; NFC
llvm-svn: 283885
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1e7b1ea604f..a00a48c9b5d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1912,14 +1912,12 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
return N0.getOperand(0);
// fold C2-(A+C1) -> (C2-C1)-A
- ConstantSDNode *N1C1 =
- N1.getOpcode() != ISD::ADD
- ? nullptr
- : dyn_cast<ConstantSDNode>(N1.getOperand(1).getNode());
- if (N1.getOpcode() == ISD::ADD && N0C && N1C1) {
- SDValue NewC =
- DAG.getConstant(N0C->getAPIntValue() - N1C1->getAPIntValue(), DL, VT);
- return DAG.getNode(ISD::SUB, DL, VT, NewC, N1.getOperand(0));
+ if (N1.getOpcode() == ISD::ADD && N0C) {
+ if (auto *N1C1 = dyn_cast<ConstantSDNode>(N1.getOperand(1).getNode())) {
+ SDValue NewC =
+ DAG.getConstant(N0C->getAPIntValue() - N1C1->getAPIntValue(), DL, VT);
+ return DAG.getNode(ISD::SUB, DL, VT, NewC, N1.getOperand(0));
+ }
}
// fold ((A+(B+or-C))-B) -> A+or-C
OpenPOWER on IntegriCloud