@@ -5601,6 +5601,23 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
56015601 if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
56025602 return V;
56035603
5604+ // Match a spread(4,8) which can be done via extend and shift. Spread(2)
5605+ // is fully covered in interleave(2) above, so it is ignored here.
5606+ if (VT.getScalarSizeInBits() < Subtarget.getELen()) {
5607+ unsigned MaxFactor = Subtarget.getELen() / VT.getScalarSizeInBits();
5608+ assert(MaxFactor == 2 || MaxFactor == 4 || MaxFactor == 8);
5609+ for (unsigned Factor = 4; Factor <= MaxFactor; Factor <<= 1) {
5610+ unsigned Index;
5611+ if (isSpreadMask(Mask, Factor, Index)) {
5612+ MVT NarrowVT =
5613+ MVT::getVectorVT(VT.getVectorElementType(), NumElts / Factor);
5614+ SDValue Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowVT, V1,
5615+ DAG.getVectorIdxConstant(0, DL));
5616+ return getWideningSpread(Src, Factor, Index, DL, DAG);
5617+ }
5618+ }
5619+ }
5620+
56045621 // Before hitting generic lowering fallbacks, try to widen the mask
56055622 // to a wider SEW.
56065623 if (SDValue V = tryWidenMaskForShuffle(Op, DAG))
@@ -5625,23 +5642,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
56255642 DAG.getUNDEF(VT));
56265643 }
56275644
5628- // Match a spread(4,8) which can be done via extend and shift. Spread(2)
5629- // is fully covered in interleave(2) above, so it is ignored here.
5630- if (VT.getScalarSizeInBits() < Subtarget.getELen()) {
5631- unsigned MaxFactor = Subtarget.getELen() / VT.getScalarSizeInBits();
5632- assert(MaxFactor == 2 || MaxFactor == 4 || MaxFactor == 8);
5633- for (unsigned Factor = 4; Factor <= MaxFactor; Factor <<= 1) {
5634- unsigned Index;
5635- if (isSpreadMask(Mask, Factor, Index)) {
5636- MVT NarrowVT =
5637- MVT::getVectorVT(VT.getVectorElementType(), NumElts / Factor);
5638- SDValue Src = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, NarrowVT, V1,
5639- DAG.getVectorIdxConstant(0, DL));
5640- return getWideningSpread(Src, Factor, Index, DL, DAG);
5641- }
5642- }
5643- }
5644-
56455645 if (VT.getScalarSizeInBits() == 8 &&
56465646 any_of(Mask, [&](const auto &Idx) { return Idx > 255; })) {
56475647 // On such a vector we're unable to use i8 as the index type.
0 commit comments