summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-10 04:04:49 +0000
committerChris Lattner <sabre@nondot.org>2005-04-10 04:04:49 +0000
commitedeecfcbd5ae3fe6d7e65107203a93ed196aaf1b (patch)
treecc31ac38effbf8caccada8d7ec7113f96690f2f1 /lib/CodeGen
parent340f2907839cc5ecb34c5045cb24ef31588f2a39 (diff)
downloadllvm-edeecfcbd5ae3fe6d7e65107203a93ed196aaf1b.tar.gz
llvm-edeecfcbd5ae3fe6d7e65107203a93ed196aaf1b.tar.bz2
llvm-edeecfcbd5ae3fe6d7e65107203a93ed196aaf1b.tar.xz
add a simple xform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index f33ecd7223..7cf89144c3 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -892,6 +892,12 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
return getNode(ISD::SUB, VT, N1, N2.getOperand(0));
if (N1.getOpcode() == ISD::FNEG) // ((-A)+B) -> B-A
return getNode(ISD::SUB, VT, N2, N1.getOperand(0));
+ if (N1.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N1.getOperand(0)) &&
+ cast<ConstantSDNode>(N1.getOperand(0))->getValue() == 0)
+ return getNode(ISD::SUB, VT, N2, N1.getOperand(1)); // (0-A)+B -> B-A
+ if (N2.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N2.getOperand(0)) &&
+ cast<ConstantSDNode>(N2.getOperand(0))->getValue() == 0)
+ return getNode(ISD::SUB, VT, N1, N2.getOperand(1)); // A+(0-B) -> A-B
break;
case ISD::SUB:
if (N1.getOpcode() == ISD::ADD) {