llvm.org GIT mirror llvm / release_90 test / CodeGen / X86 / masked_gather_scatter_widen.ll
release_90

Tree @release_90 (Download .tar.gz)

masked_gather_scatter_widen.ll @release_90raw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512vl -mattr=+avx512dq -x86-experimental-vector-widening-legalization < %s | FileCheck %s --check-prefix=CHECK --check-prefix=WIDEN --check-prefix=WIDEN_SKX
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f -x86-experimental-vector-widening-legalization < %s | FileCheck %s --check-prefix=CHECK --check-prefix=WIDEN --check-prefix=WIDEN_KNL
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512vl -mattr=+avx512dq < %s | FileCheck %s --check-prefix=CHECK --check-prefix=PROMOTE --check-prefix=PROMOTE_SKX
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f < %s | FileCheck %s --check-prefix=CHECK --check-prefix=PROMOTE --check-prefix=PROMOTE_KNL
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake -x86-experimental-vector-widening-legalization < %s | FileCheck %s --check-prefix=WIDEN_AVX2
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck %s --check-prefix=PROMOTE_AVX2

define <2 x double> @test_gather_v2i32_index(double* %base, <2 x i32> %ind, <2 x i1> %mask, <2 x double> %src0) {
; WIDEN_SKX-LABEL: test_gather_v2i32_index:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_SKX-NEXT:    vpmovq2m %xmm1, %k1
; WIDEN_SKX-NEXT:    vgatherdpd (%rdi,%xmm0,8), %xmm2 {%k1}
; WIDEN_SKX-NEXT:    vmovapd %xmm2, %xmm0
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_gather_v2i32_index:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm2 killed $xmm2 def $zmm2
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vgatherdpd (%rdi,%ymm0,8), %zmm2 {%k1}
; WIDEN_KNL-NEXT:    vmovapd %xmm2, %xmm0
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_gather_v2i32_index:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $32, %xmm0, %xmm0
; PROMOTE_SKX-NEXT:    vpsraq $32, %xmm0, %xmm0
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm1, %k1
; PROMOTE_SKX-NEXT:    vgatherqpd (%rdi,%xmm0,8), %xmm2 {%k1}
; PROMOTE_SKX-NEXT:    vmovapd %xmm2, %xmm0
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_gather_v2i32_index:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    # kill: def $xmm2 killed $xmm2 def $zmm2
; PROMOTE_KNL-NEXT:    vpsllq $32, %xmm0, %xmm0
; PROMOTE_KNL-NEXT:    vpsraq $32, %zmm0, %zmm0
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vgatherqpd (%rdi,%zmm0,8), %zmm2 {%k1}
; PROMOTE_KNL-NEXT:    vmovapd %xmm2, %xmm0
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_gather_v2i32_index:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vgatherdpd %xmm1, (%rdi,%xmm0,8), %xmm2
; WIDEN_AVX2-NEXT:    vmovapd %xmm2, %xmm0
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_gather_v2i32_index:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpsllq $32, %xmm0, %xmm3
; PROMOTE_AVX2-NEXT:    vpsrad $31, %xmm3, %xmm3
; PROMOTE_AVX2-NEXT:    vpblendd {{.*#+}} xmm0 = xmm0[0],xmm3[1],xmm0[2],xmm3[3]
; PROMOTE_AVX2-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_AVX2-NEXT:    vgatherqpd %xmm1, (%rdi,%xmm0,8), %xmm2
; PROMOTE_AVX2-NEXT:    vmovapd %xmm2, %xmm0
; PROMOTE_AVX2-NEXT:    retq
  %gep.random = getelementptr double, double* %base, <2 x i32> %ind
  %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)
  ret <2 x double> %res
}

define void @test_scatter_v2i32_index(<2 x double> %a1, double* %base, <2 x i32> %ind, <2 x i1> %mask) {
; WIDEN_SKX-LABEL: test_scatter_v2i32_index:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_SKX-NEXT:    vpmovq2m %xmm2, %k1
; WIDEN_SKX-NEXT:    vscatterdpd %xmm0, (%rdi,%xmm1,8) {%k1}
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_scatter_v2i32_index:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm1 killed $xmm1 def $ymm1
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vscatterdpd %zmm0, (%rdi,%ymm1,8) {%k1}
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_scatter_v2i32_index:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm2, %k1
; PROMOTE_SKX-NEXT:    vpsllq $32, %xmm1, %xmm1
; PROMOTE_SKX-NEXT:    vpsraq $32, %xmm1, %xmm1
; PROMOTE_SKX-NEXT:    vscatterqpd %xmm0, (%rdi,%xmm1,8) {%k1}
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_scatter_v2i32_index:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; PROMOTE_KNL-NEXT:    vpsllq $32, %xmm1, %xmm1
; PROMOTE_KNL-NEXT:    vpsraq $32, %zmm1, %zmm1
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vscatterqpd %zmm0, (%rdi,%zmm1,8) {%k1}
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_scatter_v2i32_index:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vpmovsxdq %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vpsllq $3, %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vmovq %rdi, %xmm3
; WIDEN_AVX2-NEXT:    vpbroadcastq %xmm3, %xmm3
; WIDEN_AVX2-NEXT:    vpaddq %xmm1, %xmm3, %xmm1
; WIDEN_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB1_2
; WIDEN_AVX2-NEXT:  # %bb.1: # %cond.store
; WIDEN_AVX2-NEXT:    vmovq %xmm1, %rax
; WIDEN_AVX2-NEXT:    vmovlps %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB1_2: # %else
; WIDEN_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB1_4
; WIDEN_AVX2-NEXT:  # %bb.3: # %cond.store1
; WIDEN_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; WIDEN_AVX2-NEXT:    vmovhps %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB1_4: # %else2
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_scatter_v2i32_index:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpsllq $32, %xmm1, %xmm3
; PROMOTE_AVX2-NEXT:    vpsrad $31, %xmm3, %xmm3
; PROMOTE_AVX2-NEXT:    vpblendd {{.*#+}} xmm1 = xmm1[0],xmm3[1],xmm1[2],xmm3[3]
; PROMOTE_AVX2-NEXT:    vpsllq $3, %xmm1, %xmm1
; PROMOTE_AVX2-NEXT:    vmovq %rdi, %xmm3
; PROMOTE_AVX2-NEXT:    vpbroadcastq %xmm3, %xmm3
; PROMOTE_AVX2-NEXT:    vpaddq %xmm1, %xmm3, %xmm1
; PROMOTE_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB1_2
; PROMOTE_AVX2-NEXT:  # %bb.1: # %cond.store
; PROMOTE_AVX2-NEXT:    vmovq %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vmovlps %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB1_2: # %else
; PROMOTE_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB1_4
; PROMOTE_AVX2-NEXT:  # %bb.3: # %cond.store1
; PROMOTE_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vmovhps %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB1_4: # %else2
; PROMOTE_AVX2-NEXT:    retq
  %gep = getelementptr double, double *%base, <2 x i32> %ind
  call void @llvm.masked.scatter.v2f64.v2p0f64(<2 x double> %a1, <2 x double*> %gep, i32 4, <2 x i1> %mask)
  ret void
}

define <2 x i32> @test_gather_v2i32_data(<2 x i32*> %ptr, <2 x i1> %mask, <2 x i32> %src0) {
; WIDEN_SKX-LABEL: test_gather_v2i32_data:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_SKX-NEXT:    vpmovq2m %xmm1, %k1
; WIDEN_SKX-NEXT:    vpgatherqd (,%xmm0), %xmm2 {%k1}
; WIDEN_SKX-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_gather_v2i32_data:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm2 killed $xmm2 def $ymm2
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vpgatherqd (,%zmm0), %ymm2 {%k1}
; WIDEN_KNL-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_gather_v2i32_data:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm1, %k1
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpgatherqd (,%xmm0), %xmm1 {%k1}
; PROMOTE_SKX-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm1[0],zero,xmm1[1],zero
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_gather_v2i32_data:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vpgatherqd (,%zmm0), %ymm1 {%k1}
; PROMOTE_KNL-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm1[0],zero,xmm1[1],zero
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_gather_v2i32_data:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
; WIDEN_AVX2-NEXT:    vpslld $31, %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vpgatherqd %xmm1, (,%xmm0), %xmm2
; WIDEN_AVX2-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_gather_v2i32_data:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]
; PROMOTE_AVX2-NEXT:    vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
; PROMOTE_AVX2-NEXT:    vpslld $31, %xmm1, %xmm1
; PROMOTE_AVX2-NEXT:    vpgatherqd %xmm1, (,%xmm0), %xmm2
; PROMOTE_AVX2-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm2[0],zero,xmm2[1],zero
; PROMOTE_AVX2-NEXT:    retq
  %res = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %ptr, i32 4, <2 x i1> %mask, <2 x i32> %src0)
  ret <2 x i32>%res
}

define void @test_scatter_v2i32_data(<2 x i32>%a1, <2 x i32*> %ptr, <2 x i1>%mask) {
; WIDEN_SKX-LABEL: test_scatter_v2i32_data:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_SKX-NEXT:    vpmovq2m %xmm2, %k1
; WIDEN_SKX-NEXT:    vpscatterqd %xmm0, (,%xmm1) {%k1}
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_scatter_v2i32_data:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm1 killed $xmm1 def $zmm1
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $ymm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vpscatterqd %ymm0, (,%zmm1) {%k1}
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_scatter_v2i32_data:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm2, %k1
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpscatterqd %xmm0, (,%xmm1) {%k1}
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_scatter_v2i32_data:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    # kill: def $xmm1 killed $xmm1 def $zmm1
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vpscatterqd %ymm0, (,%zmm1) {%k1}
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_scatter_v2i32_data:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB3_2
; WIDEN_AVX2-NEXT:  # %bb.1: # %cond.store
; WIDEN_AVX2-NEXT:    vmovq %xmm1, %rax
; WIDEN_AVX2-NEXT:    vmovss %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB3_2: # %else
; WIDEN_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB3_4
; WIDEN_AVX2-NEXT:  # %bb.3: # %cond.store1
; WIDEN_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; WIDEN_AVX2-NEXT:    vextractps $1, %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB3_4: # %else2
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_scatter_v2i32_data:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB3_2
; PROMOTE_AVX2-NEXT:  # %bb.1: # %cond.store
; PROMOTE_AVX2-NEXT:    vmovq %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vmovss %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB3_2: # %else
; PROMOTE_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB3_4
; PROMOTE_AVX2-NEXT:  # %bb.3: # %cond.store1
; PROMOTE_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vextractps $2, %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB3_4: # %else2
; PROMOTE_AVX2-NEXT:    retq
  call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %a1, <2 x i32*> %ptr, i32 4, <2 x i1> %mask)
  ret void
}

define <2 x i32> @test_gather_v2i32_data_index(i32* %base, <2 x i32> %ind, <2 x i1> %mask, <2 x i32> %src0) {
; WIDEN_SKX-LABEL: test_gather_v2i32_data_index:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_SKX-NEXT:    vpmovq2m %xmm1, %k1
; WIDEN_SKX-NEXT:    vpgatherdd (%rdi,%xmm0,4), %xmm2 {%k1}
; WIDEN_SKX-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_gather_v2i32_data_index:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm2 killed $xmm2 def $zmm2
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; WIDEN_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vpgatherdd (%rdi,%zmm0,4), %zmm2 {%k1}
; WIDEN_KNL-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_gather_v2i32_data_index:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm1, %k1
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpgatherdd (%rdi,%xmm0,4), %xmm1 {%k1}
; PROMOTE_SKX-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm1[0],zero,xmm1[1],zero
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_gather_v2i32_data_index:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm1, %xmm1
; PROMOTE_KNL-NEXT:    vptestmq %zmm1, %zmm1, %k0
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vpgatherdd (%rdi,%zmm0,4), %zmm1 {%k1}
; PROMOTE_KNL-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm1[0],zero,xmm1[1],zero
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_gather_v2i32_data_index:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vinsertps {{.*#+}} xmm1 = xmm1[0,2],zero,zero
; WIDEN_AVX2-NEXT:    vpslld $31, %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vpgatherdd %xmm1, (%rdi,%xmm0,4), %xmm2
; WIDEN_AVX2-NEXT:    vmovdqa %xmm2, %xmm0
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_gather_v2i32_data_index:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_AVX2-NEXT:    vpshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]
; PROMOTE_AVX2-NEXT:    vinsertps {{.*#+}} xmm1 = xmm1[0,2],zero,zero
; PROMOTE_AVX2-NEXT:    vpslld $31, %xmm1, %xmm1
; PROMOTE_AVX2-NEXT:    vpgatherdd %xmm1, (%rdi,%xmm0,4), %xmm2
; PROMOTE_AVX2-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm2[0],zero,xmm2[1],zero
; PROMOTE_AVX2-NEXT:    retq
  %gep.random = getelementptr i32, i32* %base, <2 x i32> %ind
  %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)
  ret <2 x i32> %res
}

define void @test_scatter_v2i32_data_index(<2 x i32> %a1, i32* %base, <2 x i32> %ind, <2 x i1> %mask) {
; WIDEN_SKX-LABEL: test_scatter_v2i32_data_index:
; WIDEN_SKX:       # %bb.0:
; WIDEN_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_SKX-NEXT:    vpmovq2m %xmm2, %k1
; WIDEN_SKX-NEXT:    vpscatterdd %xmm0, (%rdi,%xmm1,4) {%k1}
; WIDEN_SKX-NEXT:    retq
;
; WIDEN_KNL-LABEL: test_scatter_v2i32_data_index:
; WIDEN_KNL:       # %bb.0:
; WIDEN_KNL-NEXT:    # kill: def $xmm1 killed $xmm1 def $zmm1
; WIDEN_KNL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
; WIDEN_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; WIDEN_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; WIDEN_KNL-NEXT:    kshiftlw $14, %k0, %k0
; WIDEN_KNL-NEXT:    kshiftrw $14, %k0, %k1
; WIDEN_KNL-NEXT:    vpscatterdd %zmm0, (%rdi,%zmm1,4) {%k1}
; WIDEN_KNL-NEXT:    vzeroupper
; WIDEN_KNL-NEXT:    retq
;
; PROMOTE_SKX-LABEL: test_scatter_v2i32_data_index:
; PROMOTE_SKX:       # %bb.0:
; PROMOTE_SKX-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_SKX-NEXT:    vpmovq2m %xmm2, %k1
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
; PROMOTE_SKX-NEXT:    vpscatterdd %xmm0, (%rdi,%xmm1,4) {%k1}
; PROMOTE_SKX-NEXT:    retq
;
; PROMOTE_KNL-LABEL: test_scatter_v2i32_data_index:
; PROMOTE_KNL:       # %bb.0:
; PROMOTE_KNL-NEXT:    vpsllq $63, %xmm2, %xmm2
; PROMOTE_KNL-NEXT:    vptestmq %zmm2, %zmm2, %k0
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
; PROMOTE_KNL-NEXT:    vpshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
; PROMOTE_KNL-NEXT:    kshiftlw $14, %k0, %k0
; PROMOTE_KNL-NEXT:    kshiftrw $14, %k0, %k1
; PROMOTE_KNL-NEXT:    vpscatterdd %zmm0, (%rdi,%zmm1,4) {%k1}
; PROMOTE_KNL-NEXT:    vzeroupper
; PROMOTE_KNL-NEXT:    retq
;
; WIDEN_AVX2-LABEL: test_scatter_v2i32_data_index:
; WIDEN_AVX2:       # %bb.0:
; WIDEN_AVX2-NEXT:    vpmovsxdq %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vpsllq $2, %xmm1, %xmm1
; WIDEN_AVX2-NEXT:    vmovq %rdi, %xmm3
; WIDEN_AVX2-NEXT:    vpbroadcastq %xmm3, %xmm3
; WIDEN_AVX2-NEXT:    vpaddq %xmm1, %xmm3, %xmm1
; WIDEN_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB5_2
; WIDEN_AVX2-NEXT:  # %bb.1: # %cond.store
; WIDEN_AVX2-NEXT:    vmovq %xmm1, %rax
; WIDEN_AVX2-NEXT:    vmovss %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB5_2: # %else
; WIDEN_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; WIDEN_AVX2-NEXT:    testb $1, %al
; WIDEN_AVX2-NEXT:    je .LBB5_4
; WIDEN_AVX2-NEXT:  # %bb.3: # %cond.store1
; WIDEN_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; WIDEN_AVX2-NEXT:    vextractps $1, %xmm0, (%rax)
; WIDEN_AVX2-NEXT:  .LBB5_4: # %else2
; WIDEN_AVX2-NEXT:    retq
;
; PROMOTE_AVX2-LABEL: test_scatter_v2i32_data_index:
; PROMOTE_AVX2:       # %bb.0:
; PROMOTE_AVX2-NEXT:    vpsllq $32, %xmm1, %xmm3
; PROMOTE_AVX2-NEXT:    vpsrad $31, %xmm3, %xmm3
; PROMOTE_AVX2-NEXT:    vpblendd {{.*#+}} xmm1 = xmm1[0],xmm3[1],xmm1[2],xmm3[3]
; PROMOTE_AVX2-NEXT:    vpsllq $2, %xmm1, %xmm1
; PROMOTE_AVX2-NEXT:    vmovq %rdi, %xmm3
; PROMOTE_AVX2-NEXT:    vpbroadcastq %xmm3, %xmm3
; PROMOTE_AVX2-NEXT:    vpaddq %xmm1, %xmm3, %xmm1
; PROMOTE_AVX2-NEXT:    vpextrb $0, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB5_2
; PROMOTE_AVX2-NEXT:  # %bb.1: # %cond.store
; PROMOTE_AVX2-NEXT:    vmovq %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vmovss %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB5_2: # %else
; PROMOTE_AVX2-NEXT:    vpextrb $8, %xmm2, %eax
; PROMOTE_AVX2-NEXT:    testb $1, %al
; PROMOTE_AVX2-NEXT:    je .LBB5_4
; PROMOTE_AVX2-NEXT:  # %bb.3: # %cond.store1
; PROMOTE_AVX2-NEXT:    vpextrq $1, %xmm1, %rax
; PROMOTE_AVX2-NEXT:    vextractps $2, %xmm0, (%rax)
; PROMOTE_AVX2-NEXT:  .LBB5_4: # %else2
; PROMOTE_AVX2-NEXT:    retq
  %gep = getelementptr i32, i32 *%base, <2 x i32> %ind
  call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %a1, <2 x i32*> %gep, i32 4, <2 x i1> %mask)
  ret void
}

declare <2 x double> @llvm.masked.gather.v2f64.v2p0f64(<2 x double*>, i32, <2 x i1>, <2 x double>)
declare void @llvm.masked.scatter.v2f64.v2p0f64(<2 x double>, <2 x double*>, i32, <2 x i1>)
declare <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*>, i32, <2 x i1>, <2 x i32>)
declare void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> , <2 x i32*> , i32 , <2 x i1>)