[llvm-commits] [llvm] r73024 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll
Eli Friedman
eli.friedman at gmail.com
Sun Jun 7 02:42:03 PDT 2009
Author: efriedma
Date: Sun Jun 7 04:41:57 2009
New Revision: 73024
URL: http://llvm.org/viewvc/llvm-project?rev=73024&view=rev
Log:
Tweak the expansion code for BIT_CONVERT to generate better code
converting from an MMX vector to an i64.
Added:
llvm/trunk/test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=73024&r1=73023&r2=73024&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Sun Jun 7 04:41:57 2009
@@ -92,6 +92,26 @@
}
}
+ if (InVT.isVector() && OutVT.isInteger()) {
+ // Handle cases like i64 = BIT_CONVERT v1i64 on x86, where the operand
+ // is legal but the result is not.
+ MVT NVT = MVT::getVectorVT(TLI.getTypeToTransformTo(OutVT), 2);
+
+ if (isTypeLegal(NVT)) {
+ SDValue CastInOp = DAG.getNode(ISD::BIT_CONVERT, dl, NVT, InOp);
+ MVT EltNVT = NVT.getVectorElementType();
+ Lo = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltNVT, CastInOp,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltNVT, CastInOp,
+ DAG.getIntPtrConstant(1));
+
+ if (TLI.isBigEndian())
+ std::swap(Lo, Hi);
+
+ return;
+ }
+ }
+
// Lower the bit-convert to a store/load from the stack.
assert(NOutVT.isByteSized() && "Expanded type not byte sized!");
Added: llvm/trunk/test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll?rev=73024&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2009-06-07-ExpandMMXBitcast.ll Sun Jun 7 04:41:57 2009
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc | grep movl | count 2
+
+define i64 @a(i32 %a, i32 %b) nounwind readnone {
+entry:
+ %0 = insertelement <2 x i32> undef, i32 %a, i32 0 ; <<2 x i32>> [#uses=1]
+ %1 = insertelement <2 x i32> %0, i32 %b, i32 1 ; <<2 x i32>> [#uses=1]
+ %conv = bitcast <2 x i32> %1 to i64 ; <i64> [#uses=1]
+ ret i64 %conv
+}
+
More information about the llvm-commits
mailing list