From: Simon Pilgrim Date: Mon, 1 Jul 2019 16:20:47 +0000 (+0000) Subject: [X86] Add widenSubVector to size in bits helper. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60235d0ed6b0cdacffa64af36928655f9502a1a1;p=llvm [X86] Add widenSubVector to size in bits helper. NFCI. We can already widenSubVector to a specific type (of the same scalar type) - this variant just specifies the target vector size. This will be useful when CombineShuffleWithExtract relaxes the need to have the same scalar type for all shuffle operand subvector sources. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364803 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index dfccda7ccd7..71bab13c427 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -5453,6 +5453,20 @@ static SDValue widenSubVector(MVT VT, SDValue Vec, bool ZeroNewElements, DAG.getIntPtrConstant(0, dl)); } +/// Widen a vector to a larger size with the same scalar type, with the new +/// elements either zero or undef. +static SDValue widenSubVector(SDValue Vec, bool ZeroNewElements, + const X86Subtarget &Subtarget, SelectionDAG &DAG, + const SDLoc &dl, unsigned WideSizeInBits) { + assert(Vec.getValueSizeInBits() < WideSizeInBits && + (WideSizeInBits % Vec.getScalarValueSizeInBits()) == 0 && + "Unsupported vector widening type"); + unsigned WideNumElts = WideSizeInBits / Vec.getScalarValueSizeInBits(); + MVT SVT = Vec.getSimpleValueType().getScalarType(); + MVT VT = MVT::getVectorVT(SVT, WideNumElts); + return widenSubVector(VT, Vec, ZeroNewElements, Subtarget, DAG, dl); +} + // Helper function to collect subvector ops that are concated together, // either by ISD::CONCAT_VECTORS or a ISD::INSERT_SUBVECTOR series. // The subvectors in Ops are guaranteed to be the same type. @@ -32093,12 +32107,10 @@ static SDValue combineX86ShuffleChain(ArrayRef Inputs, SDValue Root, "Shuffle vector size mismatch"); if (Src1SizeInBits != Src2SizeInBits) { if (Src1SizeInBits > Src2SizeInBits) { - Src2 = insertSubVector(DAG.getUNDEF(Src1.getValueType()), Src2, 0, DAG, - DL, Src2SizeInBits); + Src2 = widenSubVector(Src2, false, Subtarget, DAG, DL, Src1SizeInBits); Src2SizeInBits = Src1SizeInBits; } else { - Src1 = insertSubVector(DAG.getUNDEF(Src2.getValueType()), Src1, 0, DAG, - DL, Src1SizeInBits); + Src1 = widenSubVector(Src1, false, Subtarget, DAG, DL, Src2SizeInBits); Src1SizeInBits = Src2SizeInBits; } }