Changes in directory llvm/lib/Target/X86:
X86ISelLowering.cpp updated: 1.396 -> 1.397 X86ISelLowering.h updated: 1.99 -> 1.100 --- Log message: Support for the special case of a vector with the canonical form: vector_shuffle v1, v2, <2, 6, 3, 7> I.e. vector_shuffle v, undef, <2, 2, 3, 3> MMX only has a shuffle for v4i16 vectors. It needs to use the unpackh for this type of operation. --- Diffs of the changes: (+35 -2) X86ISelLowering.cpp | 32 ++++++++++++++++++++++++++++++-- X86ISelLowering.h | 5 +++++ 2 files changed, 35 insertions(+), 2 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.396 llvm/lib/Target/X86/X86ISelLowering.cpp:1.397 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.396 Sun Apr 22 17:50:52 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Tue Apr 24 16:16:55 2007 @@ -379,6 +379,8 @@ setOperationAction(ISD::SCALAR_TO_VECTOR, MVT::v8i8, Custom); setOperationAction(ISD::SCALAR_TO_VECTOR, MVT::v4i16, Custom); + setOperationAction(ISD::SCALAR_TO_VECTOR, MVT::v2i32, Custom); + setOperationAction(ISD::SCALAR_TO_VECTOR, MVT::v1i64, Custom); } if (Subtarget->hasSSE1()) { @@ -1776,7 +1778,7 @@ assert(N->getOpcode() == ISD::BUILD_VECTOR); unsigned NumElems = N->getNumOperands(); - if (NumElems != 4 && NumElems != 8 && NumElems != 16) + if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) return false; for (unsigned i = 0, j = 0; i != NumElems; i += 2, ++j) { @@ -1792,6 +1794,29 @@ return true; } +/// isUNPCKH_v_undef_Mask - Special case of isUNPCKHMask for canonical form +/// of vector_shuffle v, v, <2, 6, 3, 7>, i.e. vector_shuffle v, undef, +/// <2, 2, 3, 3> +bool X86::isUNPCKH_v_undef_Mask(SDNode *N) { + assert(N->getOpcode() == ISD::BUILD_VECTOR); + + unsigned NumElems = N->getNumOperands(); + if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) + return false; + + for (unsigned i = 0, j = NumElems / 2; i != NumElems; i += 2, ++j) { + SDOperand BitI = N->getOperand(i); + SDOperand BitI1 = N->getOperand(i + 1); + + if (!isUndefOrEqual(BitI, j)) + return false; + if (!isUndefOrEqual(BitI1, j)) + return false; + } + + return true; +} + /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to MOVSS, /// MOVSD, and MOVD, i.e. setting the lowest element. @@ -2432,7 +2457,7 @@ } } - // Let legalizer expand 2-wide build_vector's. + // Let legalizer expand 2-wide build_vectors. if (EVTBits == 64) return SDOperand(); @@ -2591,6 +2616,7 @@ } if (X86::isUNPCKL_v_undef_Mask(PermMask.Val) || + X86::isUNPCKH_v_undef_Mask(PermMask.Val) || X86::isUNPCKLMask(PermMask.Val) || X86::isUNPCKHMask(PermMask.Val)) return Op; @@ -2619,6 +2645,7 @@ // Commute is back and try unpck* again. Op = CommuteVectorShuffle(Op, V1, V2, PermMask, DAG); if (X86::isUNPCKL_v_undef_Mask(PermMask.Val) || + X86::isUNPCKH_v_undef_Mask(PermMask.Val) || X86::isUNPCKLMask(PermMask.Val) || X86::isUNPCKHMask(PermMask.Val)) return Op; @@ -4231,6 +4258,7 @@ isPSHUFHW_PSHUFLWMask(Mask.Val) || X86::isUNPCKLMask(Mask.Val) || X86::isUNPCKL_v_undef_Mask(Mask.Val) || + X86::isUNPCKH_v_undef_Mask(Mask.Val) || X86::isUNPCKHMask(Mask.Val)); } Index: llvm/lib/Target/X86/X86ISelLowering.h diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.99 llvm/lib/Target/X86/X86ISelLowering.h:1.100 --- llvm/lib/Target/X86/X86ISelLowering.h:1.99 Fri Apr 20 16:38:10 2007 +++ llvm/lib/Target/X86/X86ISelLowering.h Tue Apr 24 16:16:55 2007 @@ -231,6 +231,11 @@ /// <0, 0, 1, 1> bool isUNPCKL_v_undef_Mask(SDNode *N); + /// isUNPCKH_v_undef_Mask - Special case of isUNPCKHMask for canonical form + /// of vector_shuffle v, v, <2, 6, 3, 7>, i.e. vector_shuffle v, undef, + /// <2, 2, 3, 3> + bool isUNPCKH_v_undef_Mask(SDNode *N); + /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to MOVSS, /// MOVSD, and MOVD, i.e. setting the lowest element. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits