Author: lattner Date: Mon Nov 19 15:38:03 2007 New Revision: 44243 URL: http://llvm.org/viewvc/llvm-project?rev=44243&view=rev Log: ExpandUnalignedLoad doesn't handle vectors right at all apparently. Fix a couple of problems: 1. Don't assume the VT-1 is a VT that is half the size. 2. Treat vectors of FP in the vector path, not the FP path.
This has a couple of remaining problems before it will work with the code in PR1811: the code below this change assumes that it can use extload/shift/or to construct the result, which isn't right for vectors. This also doesn't handle vectors of 1 or vectors that aren't pow-2. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=44243&r1=44242&r2=44243&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Nov 19 15:38:03 2007 @@ -619,13 +619,13 @@ SDOperand Ptr = LD->getBasePtr(); MVT::ValueType VT = LD->getValueType(0); MVT::ValueType LoadedVT = LD->getLoadedVT(); - if (MVT::isFloatingPoint(VT)) { + if (MVT::isFloatingPoint(VT) && !MVT::isVector(VT)) { // Expand to a (misaligned) integer load of the same size, // then bitconvert to floating point. MVT::ValueType intVT; - if (LoadedVT==MVT::f64) + if (LoadedVT == MVT::f64) intVT = MVT::i64; - else if (LoadedVT==MVT::f32) + else if (LoadedVT == MVT::f32) intVT = MVT::i32; else assert(0 && "Unaligned load of unsupported floating point type"); @@ -641,11 +641,25 @@ return DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(VT, MVT::Other), Ops, 2); } - assert(MVT::isInteger(LoadedVT) && "Unaligned load of unsupported type."); - MVT::ValueType NewLoadedVT = LoadedVT - 1; - int NumBits = MVT::getSizeInBits(NewLoadedVT); - int Alignment = LD->getAlignment(); - int IncrementSize = NumBits / 8; + assert((MVT::isInteger(LoadedVT) || MVT::isVector(LoadedVT)) && + "Unaligned load of unsupported type."); + + // Compute the new VT that is half the size of the old one. We either have an + // integer MVT or we have a vector MVT. + unsigned NumBits = MVT::getSizeInBits(LoadedVT); + MVT::ValueType NewLoadedVT; + if (!MVT::isVector(LoadedVT)) { + NewLoadedVT = MVT::getIntegerType(NumBits/2); + } else { + // FIXME: This is not right for <1 x anything> it is also not right for + // non-power-of-two vectors. + NewLoadedVT = MVT::getVectorType(MVT::getVectorElementType(LoadedVT), + MVT::getVectorNumElements(LoadedVT)/2); + } + NumBits >>= 1; + + unsigned Alignment = LD->getAlignment(); + unsigned IncrementSize = NumBits / 8; ISD::LoadExtType HiExtType = LD->getExtensionType(); // If the original load is NON_EXTLOAD, the hi part load must be ZEXTLOAD. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits