[DAG] simplify logic; NFC

llvm-svn: 283885
This commit is contained in:
Sanjay Patel 2016-10-11 14:14:30 +00:00
parent 907ae69125
commit 38a42e4bfa
1 changed files with 6 additions and 8 deletions

View File

@ -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