Skip to content

Commit 18b73a6

Browse files
committed
[X86][AVX] Support shuffle combining for VPMOVZX with smaller vector sources
llvm-svn: 352997
1 parent 4a0a64a commit 18b73a6

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6775,13 +6775,21 @@ static bool getFauxShuffleMask(SDValue N, SmallVectorImpl<int> &Mask,
67756775
}
67766776
case ISD::ZERO_EXTEND_VECTOR_INREG:
67776777
case ISD::ZERO_EXTEND: {
6778-
// TODO - add support for VPMOVZX with smaller input vector types.
67796778
SDValue Src = N.getOperand(0);
67806779
MVT SrcVT = Src.getSimpleValueType();
6781-
if (NumSizeInBits != SrcVT.getSizeInBits())
6782-
break;
6783-
DecodeZeroExtendMask(SrcVT.getScalarSizeInBits(), NumBitsPerElt, NumElts,
6784-
Mask);
6780+
unsigned NumSrcBitsPerElt = SrcVT.getScalarSizeInBits();
6781+
DecodeZeroExtendMask(NumSrcBitsPerElt, NumBitsPerElt, NumElts, Mask);
6782+
6783+
if (NumSizeInBits != SrcVT.getSizeInBits()) {
6784+
assert((NumSizeInBits % SrcVT.getSizeInBits()) == 0 &&
6785+
"Illegal zero-extension type");
6786+
SrcVT = MVT::getVectorVT(SrcVT.getScalarType(),
6787+
NumSizeInBits / NumSrcBitsPerElt);
6788+
Src = DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(N), SrcVT,
6789+
DAG.getUNDEF(SrcVT), Src,
6790+
DAG.getIntPtrConstant(0, SDLoc(N)));
6791+
}
6792+
67856793
Ops.push_back(Src);
67866794
return true;
67876795
}

llvm/test/CodeGen/X86/vector-shuffle-256-v8.ll

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,8 @@ define <8 x i32> @shuffle_v8i32_08192a3b(<8 x i32> %a, <8 x i32> %b) {
15261526
;
15271527
; AVX512VL-LABEL: shuffle_v8i32_08192a3b:
15281528
; AVX512VL: # %bb.0:
1529-
; AVX512VL-NEXT: vpmovzxdq {{.*#+}} ymm2 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
1530-
; AVX512VL-NEXT: vmovdqa {{.*#+}} ymm0 = [0,8,2,9,4,10,6,11]
1531-
; AVX512VL-NEXT: vpermi2d %ymm1, %ymm2, %ymm0
1529+
; AVX512VL-NEXT: vmovdqa {{.*#+}} ymm2 = [0,8,1,9,2,10,3,11]
1530+
; AVX512VL-NEXT: vpermt2d %ymm1, %ymm2, %ymm0
15321531
; AVX512VL-NEXT: retq
15331532
%shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
15341533
ret <8 x i32> %shuffle
@@ -1572,11 +1571,23 @@ define <8 x i32> @shuffle_v8i32_091b2d3f(<8 x i32> %a, <8 x i32> %b) {
15721571
; AVX1-NEXT: vblendps {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7]
15731572
; AVX1-NEXT: retq
15741573
;
1575-
; AVX2OR512VL-LABEL: shuffle_v8i32_091b2d3f:
1576-
; AVX2OR512VL: # %bb.0:
1577-
; AVX2OR512VL-NEXT: vpmovzxdq {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
1578-
; AVX2OR512VL-NEXT: vpblendd {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7]
1579-
; AVX2OR512VL-NEXT: retq
1574+
; AVX2-LABEL: shuffle_v8i32_091b2d3f:
1575+
; AVX2: # %bb.0:
1576+
; AVX2-NEXT: vpmovzxdq {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
1577+
; AVX2-NEXT: vpblendd {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7]
1578+
; AVX2-NEXT: retq
1579+
;
1580+
; AVX512VL-SLOW-LABEL: shuffle_v8i32_091b2d3f:
1581+
; AVX512VL-SLOW: # %bb.0:
1582+
; AVX512VL-SLOW-NEXT: vpmovzxdq {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
1583+
; AVX512VL-SLOW-NEXT: vpblendd {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7]
1584+
; AVX512VL-SLOW-NEXT: retq
1585+
;
1586+
; AVX512VL-FAST-LABEL: shuffle_v8i32_091b2d3f:
1587+
; AVX512VL-FAST: # %bb.0:
1588+
; AVX512VL-FAST-NEXT: vmovdqa {{.*#+}} ymm2 = [0,9,1,11,2,13,3,15]
1589+
; AVX512VL-FAST-NEXT: vpermt2d %ymm1, %ymm2, %ymm0
1590+
; AVX512VL-FAST-NEXT: retq
15801591
%shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 9, i32 1, i32 11, i32 2, i32 13, i32 3, i32 15>
15811592
ret <8 x i32> %shuffle
15821593
}

0 commit comments

Comments
 (0)