Skip to content

Commit 8c8eff2

Browse files
committed
[X86] Add test case showing its not always beneficial to fold concat(pack(),pack()) -> pack(concat(),concat())
1 parent ab18cc2 commit 8c8eff2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,23 @@ define <32 x i8> @concat_alignr_unnecessary(<16 x i8> %a0, <16 x i8> noundef %a1
791791
ret <32 x i8> %res
792792
}
793793

794+
; TODO: Not beneficial to concatenate both inputs just to create a 256-bit packss
795+
define <32 x i8> @concat_packsr_unnecessary(<8 x i16> %a0, <8 x i16> %a1, <8 x i16> %a2) nounwind {
796+
; CHECK-LABEL: concat_packsr_unnecessary:
797+
; CHECK: # %bb.0:
798+
; CHECK-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
799+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
800+
; CHECK-NEXT: vinserti128 $1, %xmm2, %ymm1, %ymm1
801+
; CHECK-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm0
802+
; CHECK-NEXT: vpacksswb %ymm1, %ymm0, %ymm0
803+
; CHECK-NEXT: ret{{[l|q]}}
804+
%lo = tail call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> %a0, <8 x i16> %a1)
805+
%hi = tail call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> %a0, <8 x i16> %a2)
806+
%res = shufflevector <16 x i8> %lo, <16 x i8> %hi, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
807+
ret <32 x i8> %res
808+
}
809+
declare <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16>, <8 x i16>)
810+
794811
define <8 x i32> @constant_fold_permd() {
795812
; AVX2-LABEL: constant_fold_permd:
796813
; AVX2: # %bb.0:

0 commit comments

Comments
 (0)