Skip to content

Commit 1a529f5

Browse files
committedFeb 1, 2019
[X86][AVX] Combine INSERT_SUBVECTOR(SRC0, BITCAST(SHUFFLE(EXTRACT_SUBVECTOR(SRC1)))
Enable peeking through one use bitcasts to the subvector shuffle. This still depends on the subvector being the same scalar-size but D57514 has already helped with the more tricky patterns llvm-svn: 352879
1 parent 05a3f99 commit 1a529f5

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed
 

‎llvm/lib/Target/X86/X86ISelLowering.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -6592,7 +6592,6 @@ static bool getFauxShuffleMask(SDValue N, SmallVectorImpl<int> &Mask,
65926592
case ISD::INSERT_SUBVECTOR: {
65936593
// Handle INSERT_SUBVECTOR(SRC0, SHUFFLE(EXTRACT_SUBVECTOR(SRC1)) where
65946594
// SRC0/SRC1 are both of the same valuetype VT.
6595-
// TODO - add peekThroughOneUseBitcasts support.
65966595
SDValue Src = N.getOperand(0);
65976596
SDValue Sub = N.getOperand(1);
65986597
EVT SubVT = Sub.getValueType();
@@ -6602,8 +6601,10 @@ static bool getFauxShuffleMask(SDValue N, SmallVectorImpl<int> &Mask,
66026601
return false;
66036602
SmallVector<int, 64> SubMask;
66046603
SmallVector<SDValue, 2> SubInputs;
6605-
if (!resolveTargetShuffleInputs(Sub, SubInputs, SubMask, DAG) ||
6606-
SubMask.size() != NumSubElts)
6604+
if (!resolveTargetShuffleInputs(peekThroughOneUseBitcasts(Sub), SubInputs,
6605+
SubMask, DAG))
6606+
return false;
6607+
if (SubMask.size() != NumSubElts)
66076608
return false;
66086609
Ops.push_back(Src);
66096610
for (SDValue &SubInput : SubInputs) {

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

+16-9
Original file line numberDiff line numberDiff line change
@@ -1553,12 +1553,19 @@ define <8 x i32> @shuffle_v8i32_08991abb(<8 x i32> %a, <8 x i32> %b) {
15531553
; AVX2-NEXT: vpblendd {{.*#+}} ymm0 = ymm0[0],ymm1[1,2,3],ymm0[4],ymm1[5,6,7]
15541554
; AVX2-NEXT: retq
15551555
;
1556-
; AVX512VL-LABEL: shuffle_v8i32_08991abb:
1557-
; AVX512VL: # %bb.0:
1558-
; AVX512VL-NEXT: vpmovzxdq {{.*#+}} xmm2 = xmm0[0],zero,xmm0[1],zero
1559-
; AVX512VL-NEXT: vmovdqa {{.*#+}} ymm0 = [8,0,1,1,10,2,3,3]
1560-
; AVX512VL-NEXT: vpermi2d %ymm2, %ymm1, %ymm0
1561-
; AVX512VL-NEXT: retq
1556+
; AVX512VL-SLOW-LABEL: shuffle_v8i32_08991abb:
1557+
; AVX512VL-SLOW: # %bb.0:
1558+
; AVX512VL-SLOW-NEXT: vpmovzxdq {{.*#+}} xmm2 = xmm0[0],zero,xmm0[1],zero
1559+
; AVX512VL-SLOW-NEXT: vmovdqa {{.*#+}} ymm0 = [8,0,1,1,10,2,3,3]
1560+
; AVX512VL-SLOW-NEXT: vpermi2d %ymm2, %ymm1, %ymm0
1561+
; AVX512VL-SLOW-NEXT: retq
1562+
;
1563+
; AVX512VL-FAST-LABEL: shuffle_v8i32_08991abb:
1564+
; AVX512VL-FAST: # %bb.0:
1565+
; AVX512VL-FAST-NEXT: vmovdqa {{.*#+}} ymm2 = [8,0,1,1,9,2,3,3]
1566+
; AVX512VL-FAST-NEXT: vpermi2d %ymm0, %ymm1, %ymm2
1567+
; AVX512VL-FAST-NEXT: vmovdqa %ymm2, %ymm0
1568+
; AVX512VL-FAST-NEXT: retq
15621569
%shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 8, i32 9, i32 9, i32 1, i32 10, i32 11, i32 11>
15631570
ret <8 x i32> %shuffle
15641571
}
@@ -1605,9 +1612,9 @@ define <8 x i32> @shuffle_v8i32_09ab1def(<8 x i32> %a, <8 x i32> %b) {
16051612
;
16061613
; AVX512VL-FAST-LABEL: shuffle_v8i32_09ab1def:
16071614
; AVX512VL-FAST: # %bb.0:
1608-
; AVX512VL-FAST-NEXT: vpmovzxdq {{.*#+}} xmm2 = xmm0[0],zero,xmm0[1],zero
1609-
; AVX512VL-FAST-NEXT: vmovdqa {{.*#+}} ymm0 = [8,1,2,3,10,5,6,7]
1610-
; AVX512VL-FAST-NEXT: vpermi2d %ymm2, %ymm1, %ymm0
1615+
; AVX512VL-FAST-NEXT: vmovdqa {{.*#+}} ymm2 = [8,1,2,3,9,5,6,7]
1616+
; AVX512VL-FAST-NEXT: vpermi2d %ymm0, %ymm1, %ymm2
1617+
; AVX512VL-FAST-NEXT: vmovdqa %ymm2, %ymm0
16111618
; AVX512VL-FAST-NEXT: retq
16121619
%shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 9, i32 10, i32 11, i32 1, i32 13, i32 14, i32 15>
16131620
ret <8 x i32> %shuffle

0 commit comments

Comments
 (0)
Please sign in to comment.