[llvm] r283885 - [DAG] simplify logic; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 11 07:14:31 PDT 2016
Author: spatel
Date: Tue Oct 11 09:14:30 2016
New Revision: 283885
URL: http://llvm.org/viewvc/llvm-project?rev=283885&view=rev
Log:
[DAG] simplify logic; NFC
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=283885&r1=283884&r2=283885&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Oct 11 09:14:30 2016
@@ -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
More information about the llvm-commits
mailing list