Skip to content

Commit

Permalink
[X86] combineBlendOfPermutes - allow whole-lane permutation on AVX1 t…
Browse files Browse the repository at this point in the history
…argets.

dd4bf22 fixed #91433 but meant we couldn't use vperm2f128 to permute entire 128-bit lanes - if the new 256-bit permutation mask can be scaled to 2x128-bit elements, then we can still fold.
  • Loading branch information
RKSimon committed May 8, 2024
1 parent a617190 commit 5636eb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40161,9 +40161,12 @@ combineBlendOfPermutes(MVT VT, SDValue N0, SDValue N1, ArrayRef<int> BlendMask,
return SDValue();
}

// Don't introduce lane-crossing permutes without AVX2.
// Don't introduce lane-crossing permutes without AVX2, unless it can be
// widened to a lane permute (vperm2f128).
if (VT.is256BitVector() && !Subtarget.hasAVX2() &&
isLaneCrossingShuffleMask(128, VT.getScalarSizeInBits(), NewPermuteMask))
isLaneCrossingShuffleMask(128, VT.getScalarSizeInBits(),
NewPermuteMask) &&
!canScaleShuffleElements(NewPermuteMask, 2))
return SDValue();

SDValue NewBlend =
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/X86/vector-shuffle-combining-avx.ll
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ define <4 x float> @combine_vpermilvar_4f32_as_insertps(<4 x float> %a0) {
define <8 x i32> @combine_blend_of_permutes_v8i32(<4 x i64> %a0, <4 x i64> %a1) {
; AVX1-LABEL: combine_blend_of_permutes_v8i32:
; AVX1: # %bb.0:
; AVX1-NEXT: vblendps {{.*#+}} ymm0 = ymm1[0],ymm0[1,2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7]
; AVX1-NEXT: vperm2f128 {{.*#+}} ymm0 = ymm0[2,3,0,1]
; AVX1-NEXT: vperm2f128 {{.*#+}} ymm1 = ymm1[2,3,0,1]
; AVX1-NEXT: vblendps {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3,4],ymm0[5,6],ymm1[7]
; AVX1-NEXT: ret{{[l|q]}}
;
; AVX2-LABEL: combine_blend_of_permutes_v8i32:
Expand Down

0 comments on commit 5636eb8

Please sign in to comment.