Skip to content

Commit 01494c6

Browse files
committed
[X86] Add tests showing failure to merge shuffles through avx2 shift binops
1 parent ec5b63b commit 01494c6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

llvm/test/CodeGen/X86/combine-avx2-intrinsics.ll

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,55 @@ define <4 x i64> @demandedelts_vpsrlvq(<4 x i64> %a0, <4 x i64> %a1) {
122122
ret <4 x i64> %result
123123
}
124124

125+
;
126+
; isBinOp Handling (TODO)
127+
;
128+
129+
define <4 x i32> @binop_shuffle_vpsllvd(<4 x i32> %a0, <4 x i32> %a1) {
130+
; CHECK-LABEL: binop_shuffle_vpsllvd:
131+
; CHECK: # %bb.0:
132+
; CHECK-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[3,2,1,0]
133+
; CHECK-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[3,2,1,0]
134+
; CHECK-NEXT: vpsllvd %xmm1, %xmm0, %xmm0
135+
; CHECK-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[3,2,1,0]
136+
; CHECK-NEXT: retq
137+
%shuffle0 = shufflevector <4 x i32> %a0, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
138+
%shuffle1 = shufflevector <4 x i32> %a1, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
139+
%shift = call <4 x i32> @llvm.x86.avx2.psllv.d(<4 x i32> %shuffle0, <4 x i32> %shuffle1)
140+
%res = shufflevector <4 x i32> %shift, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
141+
ret <4 x i32> %res
142+
}
143+
144+
define <8 x i32> @binop_shuffle_vpsravd(<8 x i32> %a0, <8 x i32> %a1) {
145+
; CHECK-LABEL: binop_shuffle_vpsravd:
146+
; CHECK: # %bb.0:
147+
; CHECK-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
148+
; CHECK-NEXT: vpshufd {{.*#+}} ymm1 = ymm1[3,2,1,0,7,6,5,4]
149+
; CHECK-NEXT: vpsravd %ymm1, %ymm0, %ymm0
150+
; CHECK-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
151+
; CHECK-NEXT: retq
152+
%shuffle0 = shufflevector <8 x i32> %a0, <8 x i32> undef, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
153+
%shuffle1 = shufflevector <8 x i32> %a1, <8 x i32> undef, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
154+
%shift = call <8 x i32> @llvm.x86.avx2.psrav.d.256(<8 x i32> %shuffle0, <8 x i32> %shuffle1)
155+
%res = shufflevector <8 x i32> %shift, <8 x i32> undef, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
156+
ret <8 x i32> %res
157+
}
158+
159+
define <4 x i64> @binop_shuffle_vpsrlvq(<4 x i64> %a0, <4 x i64> %a1) {
160+
; CHECK-LABEL: binop_shuffle_vpsrlvq:
161+
; CHECK: # %bb.0:
162+
; CHECK-NEXT: vpermq {{.*#+}} ymm0 = ymm0[3,2,1,0]
163+
; CHECK-NEXT: vpermq {{.*#+}} ymm1 = ymm1[3,2,1,0]
164+
; CHECK-NEXT: vpsrlvq %ymm1, %ymm0, %ymm0
165+
; CHECK-NEXT: vpermq {{.*#+}} ymm0 = ymm0[3,2,1,0]
166+
; CHECK-NEXT: retq
167+
%shuffle0 = shufflevector <4 x i64> %a0, <4 x i64> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
168+
%shuffle1 = shufflevector <4 x i64> %a1, <4 x i64> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
169+
%shift = call <4 x i64> @llvm.x86.avx2.psrlv.q.256(<4 x i64> %shuffle0, <4 x i64> %shuffle1)
170+
%res = shufflevector <4 x i64> %shift, <4 x i64> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
171+
ret <4 x i64> %res
172+
}
173+
125174
declare <16 x i16> @llvm.x86.avx2.pblendw(<16 x i16>, <16 x i16>, i32)
126175
declare <4 x i32> @llvm.x86.avx2.pblendd.128(<4 x i32>, <4 x i32>, i32)
127176
declare <8 x i32> @llvm.x86.avx2.pblendd.256(<8 x i32>, <8 x i32>, i32)

0 commit comments

Comments
 (0)