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

Chris Lattner lattner at cs.uiuc.edu
Sat Mar 18 16:20:33 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.318 -> 1.319
SelectionDAGISel.cpp updated: 1.194 -> 1.195
---
Log message:

implement vector.ll:test_undef


---
Diffs of the changes:  (+24 -9)

 LegalizeDAG.cpp      |    8 ++++++--
 SelectionDAGISel.cpp |   25 ++++++++++++++++++-------
 2 files changed, 24 insertions(+), 9 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.318 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.319
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.318	Sat Mar 18 18:07:49 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sat Mar 18 18:20:20 2006
@@ -730,12 +730,16 @@
       std::vector<Constant*> CV;
       if (MVT::isFloatingPoint(VT)) {
         for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
-          double V = cast<ConstantFPSDNode>(Node->getOperand(i))->getValue();
+          double V = 0;
+          if (Node->getOperand(i).getOpcode() != ISD::UNDEF)
+            V = cast<ConstantFPSDNode>(Node->getOperand(i))->getValue();
           CV.push_back(ConstantFP::get(OpNTy, V));
         }
       } else {
         for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
-          uint64_t V = cast<ConstantSDNode>(Node->getOperand(i))->getValue();
+          uint64_t V = 0;
+          if (Node->getOperand(i).getOpcode() != ISD::UNDEF)
+            V = cast<ConstantSDNode>(Node->getOperand(i))->getValue();
           CV.push_back(ConstantUInt::get(OpNTy, V));
         }
       }


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.194 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.195
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.194	Fri Mar 17 19:44:44 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Sat Mar 18 18:20:20 2006
@@ -516,13 +516,26 @@
     } else if (isa<ConstantPointerNull>(C)) {
       return N = DAG.getConstant(0, TLI.getPointerTy());
     } else if (isa<UndefValue>(C)) {
-      return N = DAG.getNode(ISD::UNDEF, VT);
+      if (!isa<PackedType>(VTy))
+        return N = DAG.getNode(ISD::UNDEF, VT);
+
+      // Create a VConstant of undef nodes.
+      const PackedType *PTy = cast<PackedType>(VTy);
+      unsigned NumElements = PTy->getNumElements();
+      MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
+
+      std::vector<SDOperand> Ops;
+      Ops.assign(NumElements, DAG.getNode(ISD::UNDEF, PVT));
+      
+      // Create a VConstant node with generic Vector type.
+      Ops.push_back(DAG.getConstant(NumElements, MVT::i32));
+      Ops.push_back(DAG.getValueType(PVT));
+      return N = DAG.getNode(ISD::VConstant, MVT::Vector, Ops);
     } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
       return N = DAG.getConstantFP(CFP->getValue(), VT);
     } else if (const PackedType *PTy = dyn_cast<PackedType>(VTy)) {
       unsigned NumElements = PTy->getNumElements();
       MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
-      MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements);
       
       // Now that we know the number and type of the elements, push a
       // Constant or ConstantFP node onto the ops list for each element of
@@ -551,11 +564,9 @@
         Ops.assign(NumElements, Op);
       }
       
-      // Create a ConstantVec node with generic Vector type.
-      SDOperand Num = DAG.getConstant(NumElements, MVT::i32);
-      SDOperand Typ = DAG.getValueType(PVT);
-      Ops.push_back(Num);
-      Ops.push_back(Typ);
+      // Create a VConstant node with generic Vector type.
+      Ops.push_back(DAG.getConstant(NumElements, MVT::i32));
+      Ops.push_back(DAG.getValueType(PVT));
       return N = DAG.getNode(ISD::VConstant, MVT::Vector, Ops);
     } else {
       // Canonicalize all constant ints to be unsigned.






More information about the llvm-commits mailing list