From 38a42e4bfa37e97f572c46d2d130d28b1ce7b696 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 11 Oct 2016 14:14:30 +0000 Subject: [PATCH] [DAG] simplify logic; NFC llvm-svn: 283885 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 1e7b1ea..a00a48c9 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(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(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 -- 2.7.4