@@ -5601,6 +5601,23 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
5601
5601
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
5602
5602
return V;
5603
5603
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
+
5604
5621
// Before hitting generic lowering fallbacks, try to widen the mask
5605
5622
// to a wider SEW.
5606
5623
if (SDValue V = tryWidenMaskForShuffle(Op, DAG))
@@ -5625,23 +5642,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
5625
5642
DAG.getUNDEF(VT));
5626
5643
}
5627
5644
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
-
5645
5645
if (VT.getScalarSizeInBits() == 8 &&
5646
5646
any_of(Mask, [&](const auto &Idx) { return Idx > 255; })) {
5647
5647
// On such a vector we're unable to use i8 as the index type.
0 commit comments