[llvm-commits] [llvm] r68014 - in /llvm/branches/Apple/Dib: lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll

Bill Wendling isanbard at gmail.com
Sun Mar 29 13:26:16 PDT 2009


Author: void
Date: Sun Mar 29 15:26:14 2009
New Revision: 68014

URL: http://llvm.org/viewvc/llvm-project?rev=68014&view=rev
Log:
--- Merging (from foreign repository) r67996 into '.':
A    test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll
U    lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
U    lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
U    lib/CodeGen/SelectionDAG/LegalizeTypes.h

Fix PR3899: add support for extracting floats from vectors
when using -soft-float.
Based on a patch by Jakob Stoklund Olesen.

Added:
    llvm/branches/Apple/Dib/test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll
Modified:
    llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
    llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
    llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=68014&r1=68013&r2=68014&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Sun Mar 29 15:26:14 2009
@@ -59,6 +59,8 @@
     case ISD::ConstantFP:
       R = SoftenFloatRes_ConstantFP(cast<ConstantFPSDNode>(N));
       break;
+    case ISD::EXTRACT_VECTOR_ELT:
+      R = SoftenFloatRes_EXTRACT_VECTOR_ELT(N); break;
     case ISD::FABS:        R = SoftenFloatRes_FABS(N); break;
     case ISD::FADD:        R = SoftenFloatRes_FADD(N); break;
     case ISD::FCEIL:       R = SoftenFloatRes_FCEIL(N); break;
@@ -113,6 +115,13 @@
                          TLI.getTypeToTransformTo(N->getValueType(0)));
 }
 
+SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N) {
+  SDValue NewOp = BitConvertVectorToIntegerVector(N->getOperand(0));
+  return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(),
+                     NewOp.getValueType().getVectorElementType(),
+                     NewOp, N->getOperand(1));
+}
+
 SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(SDNode *N) {
   MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
   unsigned Size = NVT.getSizeInBits();

Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=68014&r1=68013&r2=68014&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Sun Mar 29 15:26:14 2009
@@ -858,6 +858,17 @@
                      MVT::getIntegerVT(BitWidth), Op);
 }
 
+/// BitConvertVectorToIntegerVector - Convert to a vector of integers of the
+/// same size.
+SDValue DAGTypeLegalizer::BitConvertVectorToIntegerVector(SDValue Op) {
+  assert(Op.getValueType().isVector() && "Only applies to vectors!");
+  unsigned EltWidth = Op.getValueType().getVectorElementType().getSizeInBits();
+  MVT EltNVT = MVT::getIntegerVT(EltWidth);
+  unsigned NumElts = Op.getValueType().getVectorNumElements();
+  return DAG.getNode(ISD::BIT_CONVERT, Op.getDebugLoc(),
+                     MVT::getVectorVT(EltNVT, NumElts), Op);
+}
+
 SDValue DAGTypeLegalizer::CreateStackStoreLoad(SDValue Op,
                                                MVT DestVT) {
   DebugLoc dl = Op.getDebugLoc();

Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=68014&r1=68013&r2=68014&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/LegalizeTypes.h Sun Mar 29 15:26:14 2009
@@ -190,6 +190,7 @@
 
   // Common routines.
   SDValue BitConvertToInteger(SDValue Op);
+  SDValue BitConvertVectorToIntegerVector(SDValue Op);
   SDValue CreateStackStoreLoad(SDValue Op, MVT DestVT);
   bool CustomLowerResults(SDNode *N, MVT VT, bool LegalizeResult);
   SDValue GetVectorElementPointer(SDValue VecPtr, MVT EltVT, SDValue Index);
@@ -392,6 +393,7 @@
   SDValue SoftenFloatRes_BIT_CONVERT(SDNode *N);
   SDValue SoftenFloatRes_BUILD_PAIR(SDNode *N);
   SDValue SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
+  SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
   SDValue SoftenFloatRes_FABS(SDNode *N);
   SDValue SoftenFloatRes_FADD(SDNode *N);
   SDValue SoftenFloatRes_FCEIL(SDNode *N);

Added: llvm/branches/Apple/Dib/test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll?rev=68014&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll (added)
+++ llvm/branches/Apple/Dib/test/CodeGen/Generic/2009-03-29-SoftFloatVectorExtract.ll Sun Mar 29 15:26:14 2009
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc -soft-float
+; PR3899
+
+ at m = external global <2 x double>;
+
+define double @vector_ex() nounwind {
+       %v = load <2 x double>* @m
+       %x = extractelement <2 x double> %v, i32 1
+       ret double %x
+}





More information about the llvm-commits mailing list