From 23d564c11fbe628dbebd6d8f09d7d07fa862b719 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 19 Mar 2006 00:20:20 +0000 Subject: [PATCH] implement vector.ll:test_undef git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26845 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 8 ++++-- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 25 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index b4b607db3e7..d6f23dc9248 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -730,12 +730,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { std::vector CV; if (MVT::isFloatingPoint(VT)) { for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { - double V = cast(Node->getOperand(i))->getValue(); + double V = 0; + if (Node->getOperand(i).getOpcode() != ISD::UNDEF) + V = cast(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(Node->getOperand(i))->getValue(); + uint64_t V = 0; + if (Node->getOperand(i).getOpcode() != ISD::UNDEF) + V = cast(Node->getOperand(i))->getValue(); CV.push_back(ConstantUInt::get(OpNTy, V)); } } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index de4d2ec686e..8254f6ed921 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -516,13 +516,26 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { } else if (isa(C)) { return N = DAG.getConstant(0, TLI.getPointerTy()); } else if (isa(C)) { - return N = DAG.getNode(ISD::UNDEF, VT); + if (!isa(VTy)) + return N = DAG.getNode(ISD::UNDEF, VT); + + // Create a VConstant of undef nodes. + const PackedType *PTy = cast(VTy); + unsigned NumElements = PTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); + + std::vector 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(C)) { return N = DAG.getConstantFP(CFP->getValue(), VT); } else if (const PackedType *PTy = dyn_cast(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 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { 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.