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

Evan Cheng evan.cheng at apple.com
Tue Feb 14 17:55:03 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.159 -> 1.160
---
Log message:

Lower memcpy with small constant size operand into a series of load / store
ops.


---
Diffs of the changes:  (+34 -8)

 SelectionDAGISel.cpp |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.159 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.160
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.159	Tue Feb 14 17:05:54 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Tue Feb 14 19:54:51 2006
@@ -1641,18 +1641,44 @@
           MVT::ValueType VT = MemOps[i];
           unsigned VTSize = getSizeInBits(VT) / 8;
           SDOperand Value = getMemsetValue(Op2, VT, DAG);
-          OutChains.
-            push_back(DAG.getNode(ISD::STORE, MVT::Other, getRoot(),
-                                  Value,
-                                  getMemBasePlusOffset(Op1, Offset, DAG, TLI),
-                                  DAG.getSrcValue(NULL)));
+          SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, getRoot(),
+                                        Value,
+                                        getMemBasePlusOffset(Op1, Offset, DAG, TLI),
+                                        DAG.getSrcValue(I.getOperand(1), Offset));
+          OutChains.push_back(Store);
           Offset += VTSize;
         }
-
-        DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other, OutChains));
-        return;
       }
+      break;
     }
+    case ISD::MEMCPY: {
+      if (MeetsMaxMemopRequirement(MemOps, TLI.getMaxStoresPerMemcpy(),
+                                   Size->getValue(), Align, TLI)) {
+        unsigned NumMemOps = MemOps.size();
+        unsigned Offset = 0;
+        for (unsigned i = 0; i < NumMemOps; i++) {
+          MVT::ValueType VT = MemOps[i];
+          unsigned VTSize = getSizeInBits(VT) / 8;
+          SDOperand Value =
+            DAG.getLoad(VT, getRoot(),
+                        getMemBasePlusOffset(Op2, Offset, DAG, TLI),
+                        DAG.getSrcValue(I.getOperand(2), Offset));
+          SDOperand Store =
+            DAG.getNode(ISD::STORE, MVT::Other, Value.getValue(1),
+                        Value,
+                        getMemBasePlusOffset(Op1, Offset, DAG, TLI),
+                        DAG.getSrcValue(I.getOperand(1), Offset));
+          OutChains.push_back(Store);
+          Offset += VTSize;
+        }
+      }
+      break;
+    }
+    }
+
+    if (!OutChains.empty()) {
+      DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other, OutChains));
+      return;
     }
   }
 






More information about the llvm-commits mailing list