Skip to content

Commit 6db0725

Browse files
RKSimonc-rhodes
authored andcommitted
[X86] lowerV64I8Shuffle - avoid lowerShuffleAsRepeatedMaskAndLanePermute call on VBMI targets (#183109)
Shuffle combining fails to fold the inner shuffles first, but luckily the LanePermuteAnd* methods are enough if we have VPERMB as a fallback Fixes #137422 (cherry picked from commit 1b9fea0)
1 parent c43c9b4 commit 6db0725

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18004,9 +18004,12 @@ static SDValue lowerV64I8Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
1800418004

1800518005
// Try to create an in-lane repeating shuffle mask and then shuffle the
1800618006
// results into the target lanes.
18007-
if (SDValue V = lowerShuffleAsRepeatedMaskAndLanePermute(
18008-
DL, MVT::v64i8, V1, V2, Mask, Subtarget, DAG))
18009-
return V;
18007+
// FIXME: Avoid on VBMI targets as the post lane permute often interferes
18008+
// with shuffle combining (should be fixed by topological DAG sorting).
18009+
if (!Subtarget.hasVBMI())
18010+
if (SDValue V = lowerShuffleAsRepeatedMaskAndLanePermute(
18011+
DL, MVT::v64i8, V1, V2, Mask, Subtarget, DAG))
18012+
return V;
1801018013

1801118014
if (SDValue Result = lowerShuffleAsLanePermuteAndPermute(
1801218015
DL, MVT::v64i8, V1, V2, Mask, DAG, Subtarget))
@@ -18047,7 +18050,8 @@ static SDValue lowerV64I8Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
1804718050
if (Subtarget.hasVBMI())
1804818051
return lowerShuffleWithPERMV(DL, MVT::v64i8, Mask, V1, V2, Subtarget, DAG);
1804918052

18050-
return splitAndLowerShuffle(DL, MVT::v64i8, V1, V2, Mask, DAG, /*SimpleOnly*/ false);
18053+
return splitAndLowerShuffle(DL, MVT::v64i8, V1, V2, Mask, DAG,
18054+
/*SimpleOnly*/ false);
1805118055
}
1805218056

1805318057
/// High-level routine to lower various 512-bit x86 vector shuffles.

llvm/test/CodeGen/X86/vector-shuffle-512-v64.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,11 +2043,11 @@ define <64 x i8> @narrow_u32x16x4_to_u8x64(<64 x i8> %x0, <64 x i8> %x1, <64 x i
20432043
;
20442044
; AVX512VBMI-LABEL: narrow_u32x16x4_to_u8x64:
20452045
; AVX512VBMI: # %bb.0:
2046-
; AVX512VBMI-NEXT: vmovdqa64 {{.*#+}} zmm4 = [0,4,8,12,64,68,72,76,u,u,u,u,u,u,u,u,16,20,24,28,80,84,88,92,u,u,u,u,u,u,u,u,32,36,40,44,96,100,104,108,u,u,u,u,u,u,u,u,48,52,56,60,112,116,120,124,u,u,u,u,u,u,u,u]
2046+
; AVX512VBMI-NEXT: vbroadcasti64x4 {{.*#+}} zmm4 = [0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124]
2047+
; AVX512VBMI-NEXT: # zmm4 = mem[0,1,2,3,0,1,2,3]
20472048
; AVX512VBMI-NEXT: vpermt2b %zmm1, %zmm4, %zmm0
20482049
; AVX512VBMI-NEXT: vpermt2b %zmm3, %zmm4, %zmm2
2049-
; AVX512VBMI-NEXT: vpmovsxbd {{.*#+}} zmm1 = [0,4,8,12,1,5,9,13,16,20,24,28,17,21,25,29]
2050-
; AVX512VBMI-NEXT: vpermt2d %zmm2, %zmm1, %zmm0
2050+
; AVX512VBMI-NEXT: vshufi64x2 {{.*#+}} zmm0 = zmm0[0,1,2,3],zmm2[4,5,6,7]
20512051
; AVX512VBMI-NEXT: retq
20522052
%lo = shufflevector <64 x i8> %x0, <64 x i8> %x1, <64 x i32> <i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60, i32 64, i32 68, i32 72, i32 76, i32 80, i32 84, i32 88, i32 92, i32 96, i32 100, i32 104, i32 108, i32 112, i32 116, i32 120, i32 124, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
20532053
%hi = shufflevector <64 x i8> %x2, <64 x i8> %x3, <64 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 0, i32 4, i32 8, i32 12, i32 16, i32 20, i32 24, i32 28, i32 32, i32 36, i32 40, i32 44, i32 48, i32 52, i32 56, i32 60, i32 64, i32 68, i32 72, i32 76, i32 80, i32 84, i32 88, i32 92, i32 96, i32 100, i32 104, i32 108, i32 112, i32 116, i32 120, i32 124>

0 commit comments

Comments
 (0)