[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Apr 9 21:05:05 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.68 -> 1.69
---
Log message:

add a simple xform


---
Diffs of the changes:  (+6 -0)

 SelectionDAG.cpp |    6 ++++++
 1 files changed, 6 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.68 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.69
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.68	Sat Apr  9 20:13:15 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Sat Apr  9 23:04:49 2005
@@ -892,6 +892,12 @@
       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) {






More information about the llvm-commits mailing list