Add a hacky workaround for crashes due to vectors live across blocks.
authorChris Lattner <sabre@nondot.org>
Tue, 21 Mar 2006 19:20:37 +0000 (19:20 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 21 Mar 2006 19:20:37 +0000 (19:20 +0000)
Note that this code won't work for vectors that aren't legal on the
target.  Improvements coming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26925 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index f2a8c8c1479ef1f42489da238489bf26c8d632b3..2744c41532282bd916a3b035de9ab26ebfd24336 100644 (file)
@@ -4262,6 +4262,9 @@ void SelectionDAGLegalize::SplitVectorOp(SDOperand Op, SDOperand &Lo,
 /// type for the result.
 SDOperand SelectionDAGLegalize::PackVectorOp(SDOperand Op, 
                                              MVT::ValueType NewVT) {
+  // FIXME: THIS IS A TEMPORARY HACK
+  if (Op.getValueType() == NewVT) return Op;
+  
   assert(Op.getValueType() == MVT::Vector && "Bad PackVectorOp invocation!");
   SDNode *Node = Op.Val;
   
index a0ce3fb756ed04c7d63b25fb87b6bf73d4ad0cd9..8bf499eb7b5dfe1ed5c0336a09a3b5bf668dc96f 100644 (file)
@@ -1086,7 +1086,8 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
     break;
   case ISD::BIT_CONVERT:
     // Basic sanity checking.
-    assert(MVT::getSizeInBits(VT) == MVT::getSizeInBits(Operand.getValueType())
+    assert((Operand.getValueType() == MVT::Vector ||   // FIXME: This is a hack.
+           MVT::getSizeInBits(VT) == MVT::getSizeInBits(Operand.getValueType()))
            && "Cannot BIT_CONVERT between two different types!");
     if (VT == Operand.getValueType()) return Operand;  // noop conversion.
     if (OpOpcode == ISD::BIT_CONVERT)  // bitconv(bitconv(x)) -> bitconv(x)
index 4107479bb5328c65c5bd638cdd6007efebe22488..d59184b1e5f08ded0cdca82cbea981c4bbff42e7 100644 (file)
@@ -2285,6 +2285,32 @@ CopyValueToVirtualRegister(SelectionDAGLowering &SDL, Value *V, unsigned Reg) {
   SelectionDAG &DAG = SDL.DAG;
   if (SrcVT == DestVT) {
     return DAG.getCopyToReg(SDL.getRoot(), Reg, Op);
+  } else if (SrcVT == MVT::Vector) {
+    // FIXME: THIS DOES NOT SUPPORT PROMOTED/EXPANDED ELEMENTS!
+
+    // Figure out the right, legal destination reg to copy into.
+    const PackedType *PTy = cast<PackedType>(V->getType());
+    unsigned NumElts = PTy->getNumElements();
+    MVT::ValueType EltTy = TLI.getValueType(PTy->getElementType());
+    
+    unsigned NumVectorRegs = 1;
+
+    // Divide the input until we get to a supported size.  This will always
+    // end with a scalar if the target doesn't support vectors.
+    while (NumElts > 1 && !TLI.isTypeLegal(getVectorType(EltTy, NumElts))) {
+      NumElts >>= 1;
+      NumVectorRegs <<= 1;
+    }
+    
+    MVT::ValueType VT;
+    if (NumElts == 1)
+      VT = EltTy;
+    else
+      VT = getVectorType(EltTy, NumElts);
+    
+    // FIXME: THIS ASSUMES THAT THE INPUT VECTOR WILL BE LEGAL!
+    Op = DAG.getNode(ISD::BIT_CONVERT, VT, Op);
+    return DAG.getCopyToReg(SDL.getRoot(), Reg, Op);
   } else if (SrcVT < DestVT) {
     // The src value is promoted to the register.
     if (MVT::isFloatingPoint(SrcVT))