llvm.org GIT mirror llvm / 004e27c
Fix PR3899: add support for extracting floats from vectors when using -soft-float. Based on a patch by Jakob Stoklund Olesen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67996 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 11 years ago
4 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5858 case ISD::ConstantFP:
5959 R = SoftenFloatRes_ConstantFP(cast(N));
6060 break;
61 case ISD::EXTRACT_VECTOR_ELT:
62 R = SoftenFloatRes_EXTRACT_VECTOR_ELT(N); break;
6163 case ISD::FABS: R = SoftenFloatRes_FABS(N); break;
6264 case ISD::FADD: R = SoftenFloatRes_FADD(N); break;
6365 case ISD::FCEIL: R = SoftenFloatRes_FCEIL(N); break;
110112 SDValue DAGTypeLegalizer::SoftenFloatRes_ConstantFP(ConstantFPSDNode *N) {
111113 return DAG.getConstant(N->getValueAPF().bitcastToAPInt(),
112114 TLI.getTypeToTransformTo(N->getValueType(0)));
115 }
116
117 SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N) {
118 SDValue NewOp = BitConvertVectorToIntegerVector(N->getOperand(0));
119 return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(),
120 NewOp.getValueType().getVectorElementType(),
121 NewOp, N->getOperand(1));
113122 }
114123
115124 SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(SDNode *N) {
857857 MVT::getIntegerVT(BitWidth), Op);
858858 }
859859
860 /// BitConvertVectorToIntegerVector - Convert to a vector of integers of the
861 /// same size.
862 SDValue DAGTypeLegalizer::BitConvertVectorToIntegerVector(SDValue Op) {
863 assert(Op.getValueType().isVector() && "Only applies to vectors!");
864 unsigned EltWidth = Op.getValueType().getVectorElementType().getSizeInBits();
865 MVT EltNVT = MVT::getIntegerVT(EltWidth);
866 unsigned NumElts = Op.getValueType().getVectorNumElements();
867 return DAG.getNode(ISD::BIT_CONVERT, Op.getDebugLoc(),
868 MVT::getVectorVT(EltNVT, NumElts), Op);
869 }
870
860871 SDValue DAGTypeLegalizer::CreateStackStoreLoad(SDValue Op,
861872 MVT DestVT) {
862873 DebugLoc dl = Op.getDebugLoc();
189189
190190 // Common routines.
191191 SDValue BitConvertToInteger(SDValue Op);
192 SDValue BitConvertVectorToIntegerVector(SDValue Op);
192193 SDValue CreateStackStoreLoad(SDValue Op, MVT DestVT);
193194 bool CustomLowerResults(SDNode *N, MVT VT, bool LegalizeResult);
194195 SDValue GetVectorElementPointer(SDValue VecPtr, MVT EltVT, SDValue Index);
391392 SDValue SoftenFloatRes_BIT_CONVERT(SDNode *N);
392393 SDValue SoftenFloatRes_BUILD_PAIR(SDNode *N);
393394 SDValue SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
395 SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
394396 SDValue SoftenFloatRes_FABS(SDNode *N);
395397 SDValue SoftenFloatRes_FADD(SDNode *N);
396398 SDValue SoftenFloatRes_FCEIL(SDNode *N);
0 ; RUN: llvm-as < %s | llc -soft-float
1 ; PR3899
2
3 @m = external global <2 x double>;
4
5 define double @vector_ex() nounwind {
6 %v = load <2 x double>* @m
7 %x = extractelement <2 x double> %v, i32 1
8 ret double %x
9 }