summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-06-16 07:06:03 +0000
committerNate Begeman <natebegeman@mac.com>2005-06-16 07:06:03 +0000
commita2e8779b0d91006ed1699f46816ddd7f703457db (patch)
tree3929152581e19ea345ee87e5b92e2d27d57be71f /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent89dc4f16f57f4d8dd714a6c6d404724356dfd1ae (diff)
downloadbcm5719-llvm-a2e8779b0d91006ed1699f46816ddd7f703457db.tar.gz
bcm5719-llvm-a2e8779b0d91006ed1699f46816ddd7f703457db.zip
Fix bug 537 test 2, which checks to make sure that we fold A+(B-A) -> B for
integer types. Add a couple checks to not perform these kinds of transform on floating point values. llvm-svn: 22228
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 75e07ca7620..8a34a59a15e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1183,12 +1183,17 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
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
+ if (N2.getOpcode() == ISD::SUB && N1 == N2.Val->getOperand(1) &&
+ !MVT::isFloatingPoint(N2.getValueType()))
+ return N2.Val->getOperand(0); // A+(B-A) -> B
break;
case ISD::SUB:
if (N1.getOpcode() == ISD::ADD) {
- if (N1.Val->getOperand(0) == N2)
+ if (N1.Val->getOperand(0) == N2 &&
+ !MVT::isFloatingPoint(N2.getValueType()))
return N1.Val->getOperand(1); // (A+B)-A == B
- if (N1.Val->getOperand(1) == N2)
+ if (N1.Val->getOperand(1) == N2 &&
+ !MVT::isFloatingPoint(N2.getValueType()))
return N1.Val->getOperand(0); // (A+B)-B == A
}
if (N2.getOpcode() == ISD::FNEG) // (A- (-B) -> A+B
OpenPOWER on IntegriCloud