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

Nate Begeman natebegeman at mac.com
Wed Nov 30 00:22:41 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.107 -> 1.108
---
Log message:

First chunk of actually generating vector code for packed types.  These
changes allow us to generate the following code:

_foo:
        li r2, 0
        lvx v0, r2, r3
        vaddfp v0, v0, v0
        stvx v0, r2, r3
        blr

for this llvm:

void %foo(<4 x float>* %a) {
entry:
        %tmp1 = load <4 x float>* %a
        %tmp2 = add <4 x float> %tmp1, %tmp1
        store <4 x float> %tmp2, <4 x float>* %a
        ret void
}


---
Diffs of the changes:  (+12 -2)

 SelectionDAGISel.cpp |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.107 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.108
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.107	Tue Nov 29 23:21:10 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Wed Nov 30 02:22:07 2005
@@ -520,12 +520,19 @@
     const PackedType *PTy = cast<PackedType>(Ty);
     unsigned NumElements = PTy->getNumElements();
     MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
+    MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements);
     
     // Immediately scalarize packed types containing only one element, so that
-    // the Legalize pass does not have to deal with them.
+    // the Legalize pass does not have to deal with them.  Similarly, if the
+    // abstract vector is going to turn into one that the target natively
+    // supports, generate that type now so that Legalize doesn't have to deal
+    // with that either.  These steps ensure that Legalize only has to handle
+    // vector types in its Expand case.
+    unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp;
     if (NumElements == 1) {
-      unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp;
       setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2));
+    } else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) {
+      setValue(&I, DAG.getNode(Opc, TVT, Op1, Op2));
     } else {
       SDOperand Num = DAG.getConstant(NumElements, MVT::i32);
       SDOperand Typ = DAG.getValueType(PVT);
@@ -777,11 +784,14 @@
     const PackedType *PTy = cast<PackedType>(Ty);
     unsigned NumElements = PTy->getNumElements();
     MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
+    MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements);
     
     // Immediately scalarize packed types containing only one element, so that
     // the Legalize pass does not have to deal with them.
     if (NumElements == 1) {
       L = DAG.getLoad(PVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0)));
+    } else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) {
+      L = DAG.getLoad(TVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0)));
     } else {
       L = DAG.getVecLoad(NumElements, PVT, Root, Ptr, 
                          DAG.getSrcValue(I.getOperand(0)));






More information about the llvm-commits mailing list