1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512vl -mattr=+avx512dq < %s | FileCheck %s --check-prefix=CHECK --check-prefix=WIDEN --check-prefix=WIDEN_SKX
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f < %s | FileCheck %s --check-prefix=CHECK --check-prefix=WIDEN --check-prefix=WIDEN_KNL
4 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck %s --check-prefix=WIDEN_AVX2
6 define <2 x double> @test_gather_v2i32_index(double* %base, <2 x i32> %ind, <2 x i1> %mask, <2 x double> %src0) {
7 ; WIDEN_SKX-LABEL: test_gather_v2i32_index:
9 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm1, %xmm1
10 ; WIDEN_SKX-NEXT: vpmovq2m %xmm1, %k1
11 ; WIDEN_SKX-NEXT: vgatherdpd (%rdi,%xmm0,8), %xmm2 {%k1}
12 ; WIDEN_SKX-NEXT: vmovapd %xmm2, %xmm0
13 ; WIDEN_SKX-NEXT: retq
15 ; WIDEN_KNL-LABEL: test_gather_v2i32_index:
17 ; WIDEN_KNL-NEXT: # kill: def $xmm2 killed $xmm2 def $zmm2
18 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
19 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm1, %xmm1
20 ; WIDEN_KNL-NEXT: vptestmq %zmm1, %zmm1, %k0
21 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
22 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
23 ; WIDEN_KNL-NEXT: vgatherdpd (%rdi,%ymm0,8), %zmm2 {%k1}
24 ; WIDEN_KNL-NEXT: vmovapd %xmm2, %xmm0
25 ; WIDEN_KNL-NEXT: vzeroupper
26 ; WIDEN_KNL-NEXT: retq
28 ; WIDEN_AVX2-LABEL: test_gather_v2i32_index:
29 ; WIDEN_AVX2: # %bb.0:
30 ; WIDEN_AVX2-NEXT: vpsllq $63, %xmm1, %xmm1
31 ; WIDEN_AVX2-NEXT: vgatherdpd %xmm1, (%rdi,%xmm0,8), %xmm2
32 ; WIDEN_AVX2-NEXT: vmovapd %xmm2, %xmm0
33 ; WIDEN_AVX2-NEXT: retq
34 %gep.random = getelementptr double, double* %base, <2 x i32> %ind
35 %res = call <2 x double> @llvm.masked.gather.v2f64.v2p0f64(<2 x double*> %gep.random, i32 4, <2 x i1> %mask, <2 x double> %src0)
39 define void @test_scatter_v2i32_index(<2 x double> %a1, double* %base, <2 x i32> %ind, <2 x i1> %mask) {
40 ; WIDEN_SKX-LABEL: test_scatter_v2i32_index:
42 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm2, %xmm2
43 ; WIDEN_SKX-NEXT: vpmovq2m %xmm2, %k1
44 ; WIDEN_SKX-NEXT: vscatterdpd %xmm0, (%rdi,%xmm1,8) {%k1}
45 ; WIDEN_SKX-NEXT: retq
47 ; WIDEN_KNL-LABEL: test_scatter_v2i32_index:
49 ; WIDEN_KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
50 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
51 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm2, %xmm2
52 ; WIDEN_KNL-NEXT: vptestmq %zmm2, %zmm2, %k0
53 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
54 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
55 ; WIDEN_KNL-NEXT: vscatterdpd %zmm0, (%rdi,%ymm1,8) {%k1}
56 ; WIDEN_KNL-NEXT: vzeroupper
57 ; WIDEN_KNL-NEXT: retq
59 ; WIDEN_AVX2-LABEL: test_scatter_v2i32_index:
60 ; WIDEN_AVX2: # %bb.0:
61 ; WIDEN_AVX2-NEXT: vpmovsxdq %xmm1, %xmm1
62 ; WIDEN_AVX2-NEXT: vpsllq $3, %xmm1, %xmm1
63 ; WIDEN_AVX2-NEXT: vmovq %rdi, %xmm3
64 ; WIDEN_AVX2-NEXT: vpbroadcastq %xmm3, %xmm3
65 ; WIDEN_AVX2-NEXT: vpaddq %xmm1, %xmm3, %xmm1
66 ; WIDEN_AVX2-NEXT: vpsllq $63, %xmm2, %xmm2
67 ; WIDEN_AVX2-NEXT: vmovmskpd %xmm2, %eax
68 ; WIDEN_AVX2-NEXT: testb $1, %al
69 ; WIDEN_AVX2-NEXT: jne .LBB1_1
70 ; WIDEN_AVX2-NEXT: # %bb.2: # %else
71 ; WIDEN_AVX2-NEXT: testb $2, %al
72 ; WIDEN_AVX2-NEXT: jne .LBB1_3
73 ; WIDEN_AVX2-NEXT: .LBB1_4: # %else2
74 ; WIDEN_AVX2-NEXT: retq
75 ; WIDEN_AVX2-NEXT: .LBB1_1: # %cond.store
76 ; WIDEN_AVX2-NEXT: vmovq %xmm1, %rcx
77 ; WIDEN_AVX2-NEXT: vmovlps %xmm0, (%rcx)
78 ; WIDEN_AVX2-NEXT: testb $2, %al
79 ; WIDEN_AVX2-NEXT: je .LBB1_4
80 ; WIDEN_AVX2-NEXT: .LBB1_3: # %cond.store1
81 ; WIDEN_AVX2-NEXT: vpextrq $1, %xmm1, %rax
82 ; WIDEN_AVX2-NEXT: vmovhps %xmm0, (%rax)
83 ; WIDEN_AVX2-NEXT: retq
84 %gep = getelementptr double, double *%base, <2 x i32> %ind
85 call void @llvm.masked.scatter.v2f64.v2p0f64(<2 x double> %a1, <2 x double*> %gep, i32 4, <2 x i1> %mask)
89 define <2 x i32> @test_gather_v2i32_data(<2 x i32*> %ptr, <2 x i1> %mask, <2 x i32> %src0) {
90 ; WIDEN_SKX-LABEL: test_gather_v2i32_data:
92 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm1, %xmm1
93 ; WIDEN_SKX-NEXT: vpmovq2m %xmm1, %k1
94 ; WIDEN_SKX-NEXT: vpgatherqd (,%xmm0), %xmm2 {%k1}
95 ; WIDEN_SKX-NEXT: vmovdqa %xmm2, %xmm0
96 ; WIDEN_SKX-NEXT: retq
98 ; WIDEN_KNL-LABEL: test_gather_v2i32_data:
100 ; WIDEN_KNL-NEXT: # kill: def $xmm2 killed $xmm2 def $ymm2
101 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
102 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm1, %xmm1
103 ; WIDEN_KNL-NEXT: vptestmq %zmm1, %zmm1, %k0
104 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
105 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
106 ; WIDEN_KNL-NEXT: vpgatherqd (,%zmm0), %ymm2 {%k1}
107 ; WIDEN_KNL-NEXT: vmovdqa %xmm2, %xmm0
108 ; WIDEN_KNL-NEXT: vzeroupper
109 ; WIDEN_KNL-NEXT: retq
111 ; WIDEN_AVX2-LABEL: test_gather_v2i32_data:
112 ; WIDEN_AVX2: # %bb.0:
113 ; WIDEN_AVX2-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
114 ; WIDEN_AVX2-NEXT: vpslld $31, %xmm1, %xmm1
115 ; WIDEN_AVX2-NEXT: vpgatherqd %xmm1, (,%xmm0), %xmm2
116 ; WIDEN_AVX2-NEXT: vmovdqa %xmm2, %xmm0
117 ; WIDEN_AVX2-NEXT: retq
118 %res = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %ptr, i32 4, <2 x i1> %mask, <2 x i32> %src0)
122 define void @test_scatter_v2i32_data(<2 x i32>%a1, <2 x i32*> %ptr, <2 x i1>%mask) {
123 ; WIDEN_SKX-LABEL: test_scatter_v2i32_data:
124 ; WIDEN_SKX: # %bb.0:
125 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm2, %xmm2
126 ; WIDEN_SKX-NEXT: vpmovq2m %xmm2, %k1
127 ; WIDEN_SKX-NEXT: vpscatterqd %xmm0, (,%xmm1) {%k1}
128 ; WIDEN_SKX-NEXT: retq
130 ; WIDEN_KNL-LABEL: test_scatter_v2i32_data:
131 ; WIDEN_KNL: # %bb.0:
132 ; WIDEN_KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
133 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
134 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm2, %xmm2
135 ; WIDEN_KNL-NEXT: vptestmq %zmm2, %zmm2, %k0
136 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
137 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
138 ; WIDEN_KNL-NEXT: vpscatterqd %ymm0, (,%zmm1) {%k1}
139 ; WIDEN_KNL-NEXT: vzeroupper
140 ; WIDEN_KNL-NEXT: retq
142 ; WIDEN_AVX2-LABEL: test_scatter_v2i32_data:
143 ; WIDEN_AVX2: # %bb.0:
144 ; WIDEN_AVX2-NEXT: vpsllq $63, %xmm2, %xmm2
145 ; WIDEN_AVX2-NEXT: vmovmskpd %xmm2, %eax
146 ; WIDEN_AVX2-NEXT: testb $1, %al
147 ; WIDEN_AVX2-NEXT: jne .LBB3_1
148 ; WIDEN_AVX2-NEXT: # %bb.2: # %else
149 ; WIDEN_AVX2-NEXT: testb $2, %al
150 ; WIDEN_AVX2-NEXT: jne .LBB3_3
151 ; WIDEN_AVX2-NEXT: .LBB3_4: # %else2
152 ; WIDEN_AVX2-NEXT: retq
153 ; WIDEN_AVX2-NEXT: .LBB3_1: # %cond.store
154 ; WIDEN_AVX2-NEXT: vmovq %xmm1, %rcx
155 ; WIDEN_AVX2-NEXT: vmovss %xmm0, (%rcx)
156 ; WIDEN_AVX2-NEXT: testb $2, %al
157 ; WIDEN_AVX2-NEXT: je .LBB3_4
158 ; WIDEN_AVX2-NEXT: .LBB3_3: # %cond.store1
159 ; WIDEN_AVX2-NEXT: vpextrq $1, %xmm1, %rax
160 ; WIDEN_AVX2-NEXT: vextractps $1, %xmm0, (%rax)
161 ; WIDEN_AVX2-NEXT: retq
162 call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %a1, <2 x i32*> %ptr, i32 4, <2 x i1> %mask)
166 define <2 x i32> @test_gather_v2i32_data_index(i32* %base, <2 x i32> %ind, <2 x i1> %mask, <2 x i32> %src0) {
167 ; WIDEN_SKX-LABEL: test_gather_v2i32_data_index:
168 ; WIDEN_SKX: # %bb.0:
169 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm1, %xmm1
170 ; WIDEN_SKX-NEXT: vpmovq2m %xmm1, %k1
171 ; WIDEN_SKX-NEXT: vpgatherdd (%rdi,%xmm0,4), %xmm2 {%k1}
172 ; WIDEN_SKX-NEXT: vmovdqa %xmm2, %xmm0
173 ; WIDEN_SKX-NEXT: retq
175 ; WIDEN_KNL-LABEL: test_gather_v2i32_data_index:
176 ; WIDEN_KNL: # %bb.0:
177 ; WIDEN_KNL-NEXT: # kill: def $xmm2 killed $xmm2 def $zmm2
178 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
179 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm1, %xmm1
180 ; WIDEN_KNL-NEXT: vptestmq %zmm1, %zmm1, %k0
181 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
182 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
183 ; WIDEN_KNL-NEXT: vpgatherdd (%rdi,%zmm0,4), %zmm2 {%k1}
184 ; WIDEN_KNL-NEXT: vmovdqa %xmm2, %xmm0
185 ; WIDEN_KNL-NEXT: vzeroupper
186 ; WIDEN_KNL-NEXT: retq
188 ; WIDEN_AVX2-LABEL: test_gather_v2i32_data_index:
189 ; WIDEN_AVX2: # %bb.0:
190 ; WIDEN_AVX2-NEXT: vinsertps {{.*#+}} xmm1 = xmm1[0,2],zero,zero
191 ; WIDEN_AVX2-NEXT: vpslld $31, %xmm1, %xmm1
192 ; WIDEN_AVX2-NEXT: vpgatherdd %xmm1, (%rdi,%xmm0,4), %xmm2
193 ; WIDEN_AVX2-NEXT: vmovdqa %xmm2, %xmm0
194 ; WIDEN_AVX2-NEXT: retq
195 %gep.random = getelementptr i32, i32* %base, <2 x i32> %ind
196 %res = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %gep.random, i32 4, <2 x i1> %mask, <2 x i32> %src0)
200 define void @test_scatter_v2i32_data_index(<2 x i32> %a1, i32* %base, <2 x i32> %ind, <2 x i1> %mask) {
201 ; WIDEN_SKX-LABEL: test_scatter_v2i32_data_index:
202 ; WIDEN_SKX: # %bb.0:
203 ; WIDEN_SKX-NEXT: vpsllq $63, %xmm2, %xmm2
204 ; WIDEN_SKX-NEXT: vpmovq2m %xmm2, %k1
205 ; WIDEN_SKX-NEXT: vpscatterdd %xmm0, (%rdi,%xmm1,4) {%k1}
206 ; WIDEN_SKX-NEXT: retq
208 ; WIDEN_KNL-LABEL: test_scatter_v2i32_data_index:
209 ; WIDEN_KNL: # %bb.0:
210 ; WIDEN_KNL-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
211 ; WIDEN_KNL-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
212 ; WIDEN_KNL-NEXT: vpsllq $63, %xmm2, %xmm2
213 ; WIDEN_KNL-NEXT: vptestmq %zmm2, %zmm2, %k0
214 ; WIDEN_KNL-NEXT: kshiftlw $14, %k0, %k0
215 ; WIDEN_KNL-NEXT: kshiftrw $14, %k0, %k1
216 ; WIDEN_KNL-NEXT: vpscatterdd %zmm0, (%rdi,%zmm1,4) {%k1}
217 ; WIDEN_KNL-NEXT: vzeroupper
218 ; WIDEN_KNL-NEXT: retq
220 ; WIDEN_AVX2-LABEL: test_scatter_v2i32_data_index:
221 ; WIDEN_AVX2: # %bb.0:
222 ; WIDEN_AVX2-NEXT: vpmovsxdq %xmm1, %xmm1
223 ; WIDEN_AVX2-NEXT: vpsllq $2, %xmm1, %xmm1
224 ; WIDEN_AVX2-NEXT: vmovq %rdi, %xmm3
225 ; WIDEN_AVX2-NEXT: vpbroadcastq %xmm3, %xmm3
226 ; WIDEN_AVX2-NEXT: vpaddq %xmm1, %xmm3, %xmm1
227 ; WIDEN_AVX2-NEXT: vpsllq $63, %xmm2, %xmm2
228 ; WIDEN_AVX2-NEXT: vmovmskpd %xmm2, %eax
229 ; WIDEN_AVX2-NEXT: testb $1, %al
230 ; WIDEN_AVX2-NEXT: jne .LBB5_1
231 ; WIDEN_AVX2-NEXT: # %bb.2: # %else
232 ; WIDEN_AVX2-NEXT: testb $2, %al
233 ; WIDEN_AVX2-NEXT: jne .LBB5_3
234 ; WIDEN_AVX2-NEXT: .LBB5_4: # %else2
235 ; WIDEN_AVX2-NEXT: retq
236 ; WIDEN_AVX2-NEXT: .LBB5_1: # %cond.store
237 ; WIDEN_AVX2-NEXT: vmovq %xmm1, %rcx
238 ; WIDEN_AVX2-NEXT: vmovss %xmm0, (%rcx)
239 ; WIDEN_AVX2-NEXT: testb $2, %al
240 ; WIDEN_AVX2-NEXT: je .LBB5_4
241 ; WIDEN_AVX2-NEXT: .LBB5_3: # %cond.store1
242 ; WIDEN_AVX2-NEXT: vpextrq $1, %xmm1, %rax
243 ; WIDEN_AVX2-NEXT: vextractps $1, %xmm0, (%rax)
244 ; WIDEN_AVX2-NEXT: retq
245 %gep = getelementptr i32, i32 *%base, <2 x i32> %ind
246 call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %a1, <2 x i32*> %gep, i32 4, <2 x i1> %mask)
250 declare <2 x double> @llvm.masked.gather.v2f64.v2p0f64(<2 x double*>, i32, <2 x i1>, <2 x double>)
251 declare void @llvm.masked.scatter.v2f64.v2p0f64(<2 x double>, <2 x double*>, i32, <2 x i1>)
252 declare <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*>, i32, <2 x i1>, <2 x i32>)
253 declare void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> , <2 x i32*> , i32 , <2 x i1>)