llvm.org GIT mirror llvm / stable test / CodeGen / AMDGPU / bswap.ll
stable

Tree @stable (Download .tar.gz)

bswap.ll @stableraw · 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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=amdgcn-- -verify-machineinstrs | FileCheck %s --check-prefixes=FUNC,GCN,SI
; RUN: llc < %s -mtriple=amdgcn-- -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs | FileCheck %s -check-prefixes=FUNC,GCN,VI

declare i16 @llvm.bswap.i16(i16) nounwind readnone
declare i32 @llvm.bswap.i32(i32) nounwind readnone
declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>) nounwind readnone
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) nounwind readnone
declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>) nounwind readnone
declare i64 @llvm.bswap.i64(i64) nounwind readnone
declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>) nounwind readnone
declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>) nounwind readnone

define amdgpu_kernel void @test_bswap_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_i32:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x9
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dword s4, s[2:3], 0x0
; SI-NEXT:    s_mov_b32 s3, 0xf000
; SI-NEXT:    s_mov_b32 s2, -1
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_alignbit_b32 v0, s4, s4, 8
; SI-NEXT:    v_alignbit_b32 v1, s4, s4, 24
; SI-NEXT:    s_mov_b32 s4, 0xff00ff
; SI-NEXT:    v_bfi_b32 v0, s4, v1, v0
; SI-NEXT:    buffer_store_dword v0, off, s[0:3], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_i32:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_load_dword s4, s[6:7], 0x0
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_alignbit_b32 v0, s4, s4, 8
; VI-NEXT:    v_alignbit_b32 v1, s4, s4, 24
; VI-NEXT:    s_mov_b32 s4, 0xff00ff
; VI-NEXT:    v_bfi_b32 v0, s4, v1, v0
; VI-NEXT:    buffer_store_dword v0, off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load i32, i32 addrspace(1)* %in, align 4
  %bswap = call i32 @llvm.bswap.i32(i32 %val) nounwind readnone
  store i32 %bswap, i32 addrspace(1)* %out, align 4
  ret void
}

define amdgpu_kernel void @test_bswap_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_v2i32:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x9
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx2 s[4:5], s[2:3], 0x0
; SI-NEXT:    s_mov_b32 s3, 0xf000
; SI-NEXT:    s_mov_b32 s2, -1
; SI-NEXT:    s_mov_b32 s6, 0xff00ff
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_alignbit_b32 v0, s5, s5, 8
; SI-NEXT:    v_alignbit_b32 v1, s5, s5, 24
; SI-NEXT:    v_alignbit_b32 v2, s4, s4, 8
; SI-NEXT:    v_alignbit_b32 v3, s4, s4, 24
; SI-NEXT:    v_bfi_b32 v1, s6, v1, v0
; SI-NEXT:    v_bfi_b32 v0, s6, v3, v2
; SI-NEXT:    buffer_store_dwordx2 v[0:1], off, s[0:3], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_v2i32:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s8, 0xff00ff
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_load_dwordx2 s[4:5], s[6:7], 0x0
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_alignbit_b32 v0, s5, s5, 8
; VI-NEXT:    v_alignbit_b32 v1, s5, s5, 24
; VI-NEXT:    v_alignbit_b32 v2, s4, s4, 8
; VI-NEXT:    v_alignbit_b32 v3, s4, s4, 24
; VI-NEXT:    v_bfi_b32 v1, s8, v1, v0
; VI-NEXT:    v_bfi_b32 v0, s8, v3, v2
; VI-NEXT:    buffer_store_dwordx2 v[0:1], off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load <2 x i32>, <2 x i32> addrspace(1)* %in, align 8
  %bswap = call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %val) nounwind readnone
  store <2 x i32> %bswap, <2 x i32> addrspace(1)* %out, align 8
  ret void
}

define amdgpu_kernel void @test_bswap_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_v4i32:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x9
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx4 s[4:7], s[2:3], 0x0
; SI-NEXT:    s_mov_b32 s3, 0xf000
; SI-NEXT:    s_mov_b32 s2, -1
; SI-NEXT:    s_mov_b32 s8, 0xff00ff
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_alignbit_b32 v0, s7, s7, 8
; SI-NEXT:    v_alignbit_b32 v1, s7, s7, 24
; SI-NEXT:    v_alignbit_b32 v2, s6, s6, 8
; SI-NEXT:    v_alignbit_b32 v4, s6, s6, 24
; SI-NEXT:    v_alignbit_b32 v5, s5, s5, 8
; SI-NEXT:    v_alignbit_b32 v6, s5, s5, 24
; SI-NEXT:    v_alignbit_b32 v7, s4, s4, 8
; SI-NEXT:    v_alignbit_b32 v8, s4, s4, 24
; SI-NEXT:    v_bfi_b32 v3, s8, v1, v0
; SI-NEXT:    v_bfi_b32 v2, s8, v4, v2
; SI-NEXT:    v_bfi_b32 v1, s8, v6, v5
; SI-NEXT:    v_bfi_b32 v0, s8, v8, v7
; SI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_v4i32:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s8, 0xff00ff
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_load_dwordx4 s[4:7], s[6:7], 0x0
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_alignbit_b32 v0, s7, s7, 8
; VI-NEXT:    v_alignbit_b32 v1, s7, s7, 24
; VI-NEXT:    v_bfi_b32 v3, s8, v1, v0
; VI-NEXT:    v_alignbit_b32 v2, s6, s6, 8
; VI-NEXT:    v_alignbit_b32 v4, s6, s6, 24
; VI-NEXT:    v_alignbit_b32 v0, s5, s5, 8
; VI-NEXT:    v_alignbit_b32 v1, s5, s5, 24
; VI-NEXT:    v_bfi_b32 v2, s8, v4, v2
; VI-NEXT:    v_bfi_b32 v1, s8, v1, v0
; VI-NEXT:    v_alignbit_b32 v0, s4, s4, 8
; VI-NEXT:    v_alignbit_b32 v4, s4, s4, 24
; VI-NEXT:    v_bfi_b32 v0, s8, v4, v0
; VI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load <4 x i32>, <4 x i32> addrspace(1)* %in, align 16
  %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %val) nounwind readnone
  store <4 x i32> %bswap, <4 x i32> addrspace(1)* %out, align 16
  ret void
}

define amdgpu_kernel void @test_bswap_v8i32(<8 x i32> addrspace(1)* %out, <8 x i32> addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_v8i32:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[8:11], s[0:1], 0x9
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx8 s[0:7], s[10:11], 0x0
; SI-NEXT:    s_mov_b32 s11, 0xf000
; SI-NEXT:    s_mov_b32 s10, -1
; SI-NEXT:    s_mov_b32 s12, 0xff00ff
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_alignbit_b32 v0, s3, s3, 8
; SI-NEXT:    v_alignbit_b32 v1, s3, s3, 24
; SI-NEXT:    v_alignbit_b32 v2, s2, s2, 8
; SI-NEXT:    v_alignbit_b32 v4, s2, s2, 24
; SI-NEXT:    v_alignbit_b32 v5, s1, s1, 8
; SI-NEXT:    v_alignbit_b32 v6, s1, s1, 24
; SI-NEXT:    v_alignbit_b32 v7, s0, s0, 8
; SI-NEXT:    v_alignbit_b32 v8, s0, s0, 24
; SI-NEXT:    v_alignbit_b32 v9, s7, s7, 8
; SI-NEXT:    v_alignbit_b32 v10, s7, s7, 24
; SI-NEXT:    v_alignbit_b32 v11, s6, s6, 8
; SI-NEXT:    v_alignbit_b32 v12, s6, s6, 24
; SI-NEXT:    v_alignbit_b32 v13, s5, s5, 8
; SI-NEXT:    v_alignbit_b32 v14, s5, s5, 24
; SI-NEXT:    v_alignbit_b32 v15, s4, s4, 8
; SI-NEXT:    v_alignbit_b32 v16, s4, s4, 24
; SI-NEXT:    v_bfi_b32 v3, s12, v1, v0
; SI-NEXT:    v_bfi_b32 v2, s12, v4, v2
; SI-NEXT:    v_bfi_b32 v1, s12, v6, v5
; SI-NEXT:    v_bfi_b32 v0, s12, v8, v7
; SI-NEXT:    v_bfi_b32 v7, s12, v10, v9
; SI-NEXT:    v_bfi_b32 v6, s12, v12, v11
; SI-NEXT:    v_bfi_b32 v5, s12, v14, v13
; SI-NEXT:    v_bfi_b32 v4, s12, v16, v15
; SI-NEXT:    buffer_store_dwordx4 v[4:7], off, s[8:11], 0 offset:16
; SI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[8:11], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_v8i32:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s12, 0xff00ff
; VI-NEXT:    s_mov_b32 s11, 0xf000
; VI-NEXT:    s_mov_b32 s10, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s8, s0
; VI-NEXT:    s_mov_b32 s9, s1
; VI-NEXT:    s_load_dwordx8 s[0:7], s[2:3], 0x0
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_alignbit_b32 v0, s3, s3, 8
; VI-NEXT:    v_alignbit_b32 v1, s3, s3, 24
; VI-NEXT:    v_bfi_b32 v3, s12, v1, v0
; VI-NEXT:    v_alignbit_b32 v2, s2, s2, 8
; VI-NEXT:    v_alignbit_b32 v4, s2, s2, 24
; VI-NEXT:    v_alignbit_b32 v0, s1, s1, 8
; VI-NEXT:    v_alignbit_b32 v1, s1, s1, 24
; VI-NEXT:    v_bfi_b32 v2, s12, v4, v2
; VI-NEXT:    v_bfi_b32 v1, s12, v1, v0
; VI-NEXT:    v_alignbit_b32 v0, s0, s0, 8
; VI-NEXT:    v_alignbit_b32 v4, s0, s0, 24
; VI-NEXT:    v_bfi_b32 v0, s12, v4, v0
; VI-NEXT:    v_alignbit_b32 v4, s7, s7, 8
; VI-NEXT:    v_alignbit_b32 v5, s7, s7, 24
; VI-NEXT:    v_bfi_b32 v7, s12, v5, v4
; VI-NEXT:    v_alignbit_b32 v4, s6, s6, 8
; VI-NEXT:    v_alignbit_b32 v5, s6, s6, 24
; VI-NEXT:    v_bfi_b32 v6, s12, v5, v4
; VI-NEXT:    v_alignbit_b32 v4, s5, s5, 8
; VI-NEXT:    v_alignbit_b32 v5, s5, s5, 24
; VI-NEXT:    v_bfi_b32 v5, s12, v5, v4
; VI-NEXT:    v_alignbit_b32 v4, s4, s4, 8
; VI-NEXT:    v_alignbit_b32 v8, s4, s4, 24
; VI-NEXT:    v_bfi_b32 v4, s12, v8, v4
; VI-NEXT:    buffer_store_dwordx4 v[4:7], off, s[8:11], 0 offset:16
; VI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[8:11], 0
; VI-NEXT:    s_endpgm
  %val = load <8 x i32>, <8 x i32> addrspace(1)* %in, align 32
  %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %val) nounwind readnone
  store <8 x i32> %bswap, <8 x i32> addrspace(1)* %out, align 32
  ret void
}

define amdgpu_kernel void @test_bswap_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_i64:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x9
; SI-NEXT:    s_mov_b32 s7, 0xf000
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx2 s[2:3], s[2:3], 0x0
; SI-NEXT:    s_mov_b32 s6, -1
; SI-NEXT:    s_mov_b32 s19, 0xff0000
; SI-NEXT:    s_mov_b32 s9, 0
; SI-NEXT:    s_mov_b32 s15, 0xff00
; SI-NEXT:    s_mov_b32 s11, s9
; SI-NEXT:    s_mov_b32 s12, s9
; SI-NEXT:    s_mov_b32 s14, s9
; SI-NEXT:    s_mov_b32 s16, s9
; SI-NEXT:    s_mov_b32 s18, s9
; SI-NEXT:    s_mov_b32 s4, s0
; SI-NEXT:    s_mov_b32 s5, s1
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_mov_b32_e32 v0, s2
; SI-NEXT:    v_alignbit_b32 v1, s3, v0, 24
; SI-NEXT:    v_alignbit_b32 v0, s3, v0, 8
; SI-NEXT:    s_lshr_b32 s8, s3, 24
; SI-NEXT:    s_lshr_b32 s10, s3, 8
; SI-NEXT:    s_lshl_b64 s[0:1], s[2:3], 8
; SI-NEXT:    s_lshl_b64 s[20:21], s[2:3], 24
; SI-NEXT:    s_lshl_b32 s17, s2, 24
; SI-NEXT:    s_lshl_b32 s0, s2, 8
; SI-NEXT:    v_and_b32_e32 v1, s19, v1
; SI-NEXT:    v_and_b32_e32 v0, 0xff000000, v0
; SI-NEXT:    s_and_b32 s10, s10, s15
; SI-NEXT:    s_and_b32 s13, s1, 0xff
; SI-NEXT:    s_and_b32 s15, s21, s15
; SI-NEXT:    s_and_b32 s19, s0, s19
; SI-NEXT:    v_or_b32_e32 v0, v0, v1
; SI-NEXT:    s_or_b64 s[0:1], s[10:11], s[8:9]
; SI-NEXT:    s_or_b64 s[2:3], s[14:15], s[12:13]
; SI-NEXT:    s_or_b64 s[8:9], s[16:17], s[18:19]
; SI-NEXT:    v_or_b32_e32 v0, s0, v0
; SI-NEXT:    v_mov_b32_e32 v1, s1
; SI-NEXT:    s_or_b64 s[0:1], s[8:9], s[2:3]
; SI-NEXT:    v_or_b32_e32 v0, s0, v0
; SI-NEXT:    v_or_b32_e32 v1, s1, v1
; SI-NEXT:    buffer_store_dwordx2 v[0:1], off, s[4:7], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_i64:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s12, 0xff0000
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_load_dwordx2 s[6:7], s[6:7], 0x0
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_mov_b32 s5, 0
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_mov_b32 s9, s5
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_mov_b32_e32 v0, s6
; VI-NEXT:    v_alignbit_b32 v1, s7, v0, 24
; VI-NEXT:    v_alignbit_b32 v0, s7, v0, 8
; VI-NEXT:    s_bfe_u32 s8, s7, 0x80010
; VI-NEXT:    v_and_b32_e32 v1, s12, v1
; VI-NEXT:    v_and_b32_e32 v0, 0xff000000, v0
; VI-NEXT:    s_lshr_b32 s4, s7, 24
; VI-NEXT:    s_lshl_b32 s8, s8, 8
; VI-NEXT:    s_or_b64 s[8:9], s[8:9], s[4:5]
; VI-NEXT:    v_or_b32_e32 v0, v0, v1
; VI-NEXT:    s_lshl_b64 s[10:11], s[6:7], 24
; VI-NEXT:    v_or_b32_e32 v0, s8, v0
; VI-NEXT:    v_mov_b32_e32 v1, s9
; VI-NEXT:    s_lshl_b64 s[8:9], s[6:7], 8
; VI-NEXT:    s_lshl_b32 s4, s6, 8
; VI-NEXT:    s_and_b32 s9, s9, 0xff
; VI-NEXT:    s_mov_b32 s8, s5
; VI-NEXT:    s_and_b32 s11, s11, 0xff00
; VI-NEXT:    s_mov_b32 s10, s5
; VI-NEXT:    s_or_b64 s[8:9], s[10:11], s[8:9]
; VI-NEXT:    s_lshl_b32 s11, s6, 24
; VI-NEXT:    s_and_b32 s7, s4, s12
; VI-NEXT:    s_mov_b32 s6, s5
; VI-NEXT:    s_or_b64 s[4:5], s[10:11], s[6:7]
; VI-NEXT:    s_or_b64 s[4:5], s[4:5], s[8:9]
; VI-NEXT:    v_or_b32_e32 v0, s4, v0
; VI-NEXT:    v_or_b32_e32 v1, s5, v1
; VI-NEXT:    buffer_store_dwordx2 v[0:1], off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load i64, i64 addrspace(1)* %in, align 8
  %bswap = call i64 @llvm.bswap.i64(i64 %val) nounwind readnone
  store i64 %bswap, i64 addrspace(1)* %out, align 8
  ret void
}

define amdgpu_kernel void @test_bswap_v2i64(<2 x i64> addrspace(1)* %out, <2 x i64> addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_v2i64:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[8:11], s[0:1], 0x9
; SI-NEXT:    s_mov_b32 s3, 0xf000
; SI-NEXT:    s_mov_b32 s2, -1
; SI-NEXT:    s_mov_b32 s31, 0xff0000
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx4 s[4:7], s[10:11], 0x0
; SI-NEXT:    s_mov_b32 s11, 0
; SI-NEXT:    s_mov_b32 s22, 0xff000000
; SI-NEXT:    s_mov_b32 s27, 0xff00
; SI-NEXT:    s_movk_i32 s25, 0xff
; SI-NEXT:    s_mov_b32 s13, s11
; SI-NEXT:    s_mov_b32 s14, s11
; SI-NEXT:    s_mov_b32 s16, s11
; SI-NEXT:    s_mov_b32 s18, s11
; SI-NEXT:    s_mov_b32 s20, s11
; SI-NEXT:    s_mov_b32 s23, s11
; SI-NEXT:    s_mov_b32 s24, s11
; SI-NEXT:    s_mov_b32 s26, s11
; SI-NEXT:    s_mov_b32 s28, s11
; SI-NEXT:    s_mov_b32 s30, s11
; SI-NEXT:    s_mov_b32 s0, s8
; SI-NEXT:    s_mov_b32 s1, s9
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_mov_b32_e32 v0, s6
; SI-NEXT:    v_alignbit_b32 v1, s7, v0, 24
; SI-NEXT:    v_alignbit_b32 v0, s7, v0, 8
; SI-NEXT:    s_lshr_b32 s10, s7, 24
; SI-NEXT:    s_lshr_b32 s12, s7, 8
; SI-NEXT:    s_lshl_b64 s[8:9], s[6:7], 8
; SI-NEXT:    s_lshl_b64 s[32:33], s[6:7], 24
; SI-NEXT:    s_lshl_b32 s19, s6, 24
; SI-NEXT:    s_lshl_b32 s21, s6, 8
; SI-NEXT:    v_mov_b32_e32 v2, s4
; SI-NEXT:    v_alignbit_b32 v3, s5, v2, 24
; SI-NEXT:    v_alignbit_b32 v2, s5, v2, 8
; SI-NEXT:    s_lshr_b32 s32, s5, 8
; SI-NEXT:    s_lshl_b64 s[6:7], s[4:5], 8
; SI-NEXT:    s_and_b32 s15, s9, s25
; SI-NEXT:    s_lshl_b64 s[8:9], s[4:5], 24
; SI-NEXT:    s_lshl_b32 s29, s4, 24
; SI-NEXT:    s_lshl_b32 s4, s4, 8
; SI-NEXT:    v_and_b32_e32 v1, s31, v1
; SI-NEXT:    v_and_b32_e32 v0, s22, v0
; SI-NEXT:    s_and_b32 s12, s12, s27
; SI-NEXT:    s_and_b32 s17, s33, s27
; SI-NEXT:    s_and_b32 s21, s21, s31
; SI-NEXT:    v_and_b32_e32 v3, s31, v3
; SI-NEXT:    v_and_b32_e32 v2, s22, v2
; SI-NEXT:    s_and_b32 s22, s32, s27
; SI-NEXT:    s_and_b32 s25, s7, s25
; SI-NEXT:    s_and_b32 s27, s9, s27
; SI-NEXT:    s_and_b32 s31, s4, s31
; SI-NEXT:    v_or_b32_e32 v0, v0, v1
; SI-NEXT:    s_or_b64 s[6:7], s[12:13], s[10:11]
; SI-NEXT:    s_or_b64 s[8:9], s[16:17], s[14:15]
; SI-NEXT:    s_or_b64 s[12:13], s[18:19], s[20:21]
; SI-NEXT:    v_or_b32_e32 v1, v2, v3
; SI-NEXT:    s_lshr_b32 s10, s5, 24
; SI-NEXT:    s_or_b64 s[4:5], s[26:27], s[24:25]
; SI-NEXT:    s_or_b64 s[14:15], s[28:29], s[30:31]
; SI-NEXT:    v_or_b32_e32 v0, s6, v0
; SI-NEXT:    v_mov_b32_e32 v3, s7
; SI-NEXT:    s_or_b64 s[6:7], s[12:13], s[8:9]
; SI-NEXT:    s_or_b64 s[8:9], s[22:23], s[10:11]
; SI-NEXT:    s_or_b64 s[4:5], s[14:15], s[4:5]
; SI-NEXT:    v_or_b32_e32 v2, s6, v0
; SI-NEXT:    v_or_b32_e32 v3, s7, v3
; SI-NEXT:    v_or_b32_e32 v0, s8, v1
; SI-NEXT:    v_mov_b32_e32 v1, s9
; SI-NEXT:    v_or_b32_e32 v0, s4, v0
; SI-NEXT:    v_or_b32_e32 v1, s5, v1
; SI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_v2i64:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s9, 0
; VI-NEXT:    s_mov_b32 s14, 0xff0000
; VI-NEXT:    s_mov_b32 s15, 0xff000000
; VI-NEXT:    s_mov_b32 s11, s9
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_load_dwordx4 s[4:7], s[6:7], 0x0
; VI-NEXT:    s_movk_i32 s16, 0xff
; VI-NEXT:    s_mov_b32 s17, 0xff00
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_mov_b32_e32 v0, s6
; VI-NEXT:    v_alignbit_b32 v1, s7, v0, 24
; VI-NEXT:    v_alignbit_b32 v0, s7, v0, 8
; VI-NEXT:    s_bfe_u32 s10, s7, 0x80010
; VI-NEXT:    v_and_b32_e32 v1, s14, v1
; VI-NEXT:    v_and_b32_e32 v0, s15, v0
; VI-NEXT:    s_lshr_b32 s8, s7, 24
; VI-NEXT:    s_lshl_b32 s10, s10, 8
; VI-NEXT:    s_or_b64 s[10:11], s[10:11], s[8:9]
; VI-NEXT:    v_or_b32_e32 v0, v0, v1
; VI-NEXT:    s_lshl_b64 s[12:13], s[6:7], 24
; VI-NEXT:    v_or_b32_e32 v0, s10, v0
; VI-NEXT:    v_mov_b32_e32 v1, s11
; VI-NEXT:    s_lshl_b64 s[10:11], s[6:7], 8
; VI-NEXT:    s_and_b32 s11, s11, s16
; VI-NEXT:    s_mov_b32 s10, s9
; VI-NEXT:    s_and_b32 s13, s13, s17
; VI-NEXT:    s_mov_b32 s12, s9
; VI-NEXT:    s_or_b64 s[10:11], s[12:13], s[10:11]
; VI-NEXT:    s_lshl_b32 s13, s6, 24
; VI-NEXT:    s_lshl_b32 s6, s6, 8
; VI-NEXT:    s_and_b32 s7, s6, s14
; VI-NEXT:    s_mov_b32 s6, s9
; VI-NEXT:    s_or_b64 s[6:7], s[12:13], s[6:7]
; VI-NEXT:    s_or_b64 s[6:7], s[6:7], s[10:11]
; VI-NEXT:    v_or_b32_e32 v2, s6, v0
; VI-NEXT:    v_mov_b32_e32 v0, s4
; VI-NEXT:    v_or_b32_e32 v3, s7, v1
; VI-NEXT:    v_alignbit_b32 v1, s5, v0, 24
; VI-NEXT:    v_alignbit_b32 v0, s5, v0, 8
; VI-NEXT:    s_bfe_u32 s6, s5, 0x80010
; VI-NEXT:    v_and_b32_e32 v1, s14, v1
; VI-NEXT:    v_and_b32_e32 v0, s15, v0
; VI-NEXT:    s_lshr_b32 s8, s5, 24
; VI-NEXT:    s_lshl_b32 s6, s6, 8
; VI-NEXT:    s_mov_b32 s7, s9
; VI-NEXT:    v_or_b32_e32 v0, v0, v1
; VI-NEXT:    s_or_b64 s[6:7], s[6:7], s[8:9]
; VI-NEXT:    s_lshl_b64 s[10:11], s[4:5], 24
; VI-NEXT:    v_or_b32_e32 v0, s6, v0
; VI-NEXT:    v_mov_b32_e32 v1, s7
; VI-NEXT:    s_lshl_b64 s[6:7], s[4:5], 8
; VI-NEXT:    s_and_b32 s7, s7, s16
; VI-NEXT:    s_mov_b32 s6, s9
; VI-NEXT:    s_and_b32 s11, s11, s17
; VI-NEXT:    s_mov_b32 s10, s9
; VI-NEXT:    s_or_b64 s[6:7], s[10:11], s[6:7]
; VI-NEXT:    s_lshl_b32 s11, s4, 24
; VI-NEXT:    s_lshl_b32 s4, s4, 8
; VI-NEXT:    s_and_b32 s5, s4, s14
; VI-NEXT:    s_mov_b32 s4, s9
; VI-NEXT:    s_or_b64 s[4:5], s[10:11], s[4:5]
; VI-NEXT:    s_or_b64 s[4:5], s[4:5], s[6:7]
; VI-NEXT:    v_or_b32_e32 v0, s4, v0
; VI-NEXT:    v_or_b32_e32 v1, s5, v1
; VI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load <2 x i64>, <2 x i64> addrspace(1)* %in, align 16
  %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %val) nounwind readnone
  store <2 x i64> %bswap, <2 x i64> addrspace(1)* %out, align 16
  ret void
}

define amdgpu_kernel void @test_bswap_v4i64(<4 x i64> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) nounwind {
; SI-LABEL: test_bswap_v4i64:
; SI:       ; %bb.0:
; SI-NEXT:    s_load_dwordx4 s[12:15], s[0:1], 0x9
; SI-NEXT:    s_mov_b32 s3, 0xf000
; SI-NEXT:    s_mov_b32 s2, -1
; SI-NEXT:    s_mov_b32 s31, 0xff0000
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    s_load_dwordx8 s[4:11], s[14:15], 0x0
; SI-NEXT:    s_mov_b32 s27, 0xff000000
; SI-NEXT:    s_mov_b32 s34, 0xff00
; SI-NEXT:    s_mov_b32 s14, 0
; SI-NEXT:    s_movk_i32 s36, 0xff
; SI-NEXT:    s_mov_b32 s16, s14
; SI-NEXT:    s_mov_b32 s18, s14
; SI-NEXT:    s_mov_b32 s20, s14
; SI-NEXT:    s_mov_b32 s22, s14
; SI-NEXT:    s_mov_b32 s24, s14
; SI-NEXT:    s_mov_b32 s26, s14
; SI-NEXT:    s_mov_b32 s28, s14
; SI-NEXT:    s_mov_b32 s30, s14
; SI-NEXT:    s_mov_b32 s0, s12
; SI-NEXT:    s_mov_b32 s1, s13
; SI-NEXT:    s_waitcnt lgkmcnt(0)
; SI-NEXT:    v_mov_b32_e32 v0, s6
; SI-NEXT:    v_alignbit_b32 v1, s7, v0, 24
; SI-NEXT:    v_alignbit_b32 v0, s7, v0, 8
; SI-NEXT:    s_lshr_b32 s35, s7, 24
; SI-NEXT:    s_lshr_b32 s37, s7, 8
; SI-NEXT:    v_mov_b32_e32 v2, s4
; SI-NEXT:    v_alignbit_b32 v3, s5, v2, 24
; SI-NEXT:    v_alignbit_b32 v2, s5, v2, 8
; SI-NEXT:    s_lshr_b32 s38, s5, 24
; SI-NEXT:    s_lshr_b32 s39, s5, 8
; SI-NEXT:    s_lshl_b64 s[12:13], s[6:7], 8
; SI-NEXT:    s_lshl_b64 s[32:33], s[6:7], 24
; SI-NEXT:    s_lshl_b32 s7, s6, 8
; SI-NEXT:    s_and_b32 s15, s13, s36
; SI-NEXT:    s_lshl_b64 s[12:13], s[4:5], 8
; SI-NEXT:    s_and_b32 s17, s33, s34
; SI-NEXT:    s_lshl_b64 s[32:33], s[4:5], 24
; SI-NEXT:    s_lshl_b32 s5, s4, 8
; SI-NEXT:    v_mov_b32_e32 v4, s10
; SI-NEXT:    v_alignbit_b32 v5, s11, v4, 24
; SI-NEXT:    v_alignbit_b32 v4, s11, v4, 8
; SI-NEXT:    s_and_b32 s21, s33, s34
; SI-NEXT:    s_lshl_b64 s[32:33], s[10:11], 24
; SI-NEXT:    s_and_b32 s25, s33, s34
; SI-NEXT:    s_lshl_b64 s[32:33], s[8:9], 24
; SI-NEXT:    s_and_b32 s29, s33, s34
; SI-NEXT:    s_lshr_b32 s12, s11, 24
; SI-NEXT:    s_lshr_b32 s40, s11, 8
; SI-NEXT:    v_mov_b32_e32 v6, s8
; SI-NEXT:    v_alignbit_b32 v7, s9, v6, 24
; SI-NEXT:    v_alignbit_b32 v6, s9, v6, 8
; SI-NEXT:    s_and_b32 s19, s7, s31
; SI-NEXT:    s_lshr_b32 s7, s9, 24
; SI-NEXT:    s_and_b32 s23, s5, s31
; SI-NEXT:    s_lshr_b32 s5, s9, 8
; SI-NEXT:    v_and_b32_e32 v0, s27, v0
; SI-NEXT:    v_and_b32_e32 v2, s27, v2
; SI-NEXT:    v_and_b32_e32 v4, s27, v4
; SI-NEXT:    v_and_b32_e32 v6, s27, v6
; SI-NEXT:    s_lshl_b32 s27, s10, 8
; SI-NEXT:    s_and_b32 s27, s27, s31
; SI-NEXT:    s_lshl_b32 s32, s8, 8
; SI-NEXT:    v_and_b32_e32 v1, s31, v1
; SI-NEXT:    v_and_b32_e32 v3, s31, v3
; SI-NEXT:    v_and_b32_e32 v5, s31, v5
; SI-NEXT:    v_and_b32_e32 v7, s31, v7
; SI-NEXT:    s_and_b32 s31, s32, s31
; SI-NEXT:    s_lshl_b64 s[32:33], s[10:11], 8
; SI-NEXT:    s_and_b32 s11, s37, s34
; SI-NEXT:    s_and_b32 s32, s39, s34
; SI-NEXT:    s_and_b32 s37, s40, s34
; SI-NEXT:    s_and_b32 s5, s5, s34
; SI-NEXT:    s_or_b32 s11, s11, s35
; SI-NEXT:    s_lshl_b64 s[34:35], s[8:9], 8
; SI-NEXT:    v_or_b32_e32 v0, v0, v1
; SI-NEXT:    v_or_b32_e32 v1, v2, v3
; SI-NEXT:    s_or_b32 s9, s32, s38
; SI-NEXT:    s_or_b64 s[16:17], s[16:17], s[14:15]
; SI-NEXT:    s_lshl_b32 s15, s6, 24
; SI-NEXT:    v_or_b32_e32 v3, v4, v5
; SI-NEXT:    s_or_b32 s12, s37, s12
; SI-NEXT:    v_or_b32_e32 v4, v6, v7
; SI-NEXT:    s_or_b32 s32, s5, s7
; SI-NEXT:    v_or_b32_e32 v2, s11, v0
; SI-NEXT:    v_or_b32_e32 v0, s9, v1
; SI-NEXT:    s_or_b64 s[6:7], s[14:15], s[18:19]
; SI-NEXT:    s_and_b32 s15, s13, s36
; SI-NEXT:    v_or_b32_e32 v6, s12, v3
; SI-NEXT:    s_or_b64 s[6:7], s[6:7], s[16:17]
; SI-NEXT:    s_or_b64 s[12:13], s[20:21], s[14:15]
; SI-NEXT:    s_lshl_b32 s15, s4, 24
; SI-NEXT:    s_or_b64 s[4:5], s[14:15], s[22:23]
; SI-NEXT:    s_and_b32 s15, s33, s36
; SI-NEXT:    s_or_b64 s[4:5], s[4:5], s[12:13]
; SI-NEXT:    s_or_b64 s[12:13], s[24:25], s[14:15]
; SI-NEXT:    s_lshl_b32 s15, s10, 24
; SI-NEXT:    s_or_b64 s[10:11], s[14:15], s[26:27]
; SI-NEXT:    s_and_b32 s15, s35, s36
; SI-NEXT:    s_or_b64 s[10:11], s[10:11], s[12:13]
; SI-NEXT:    s_or_b64 s[12:13], s[28:29], s[14:15]
; SI-NEXT:    s_lshl_b32 s15, s8, 24
; SI-NEXT:    s_or_b64 s[8:9], s[14:15], s[30:31]
; SI-NEXT:    s_or_b64 s[8:9], s[8:9], s[12:13]
; SI-NEXT:    v_or_b32_e32 v4, s32, v4
; SI-NEXT:    v_mov_b32_e32 v3, s7
; SI-NEXT:    v_mov_b32_e32 v1, s5
; SI-NEXT:    v_mov_b32_e32 v7, s11
; SI-NEXT:    v_mov_b32_e32 v5, s9
; SI-NEXT:    buffer_store_dwordx4 v[4:7], off, s[0:3], 0 offset:16
; SI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; SI-NEXT:    s_endpgm
;
; VI-LABEL: test_bswap_v4i64:
; VI:       ; %bb.0:
; VI-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x24
; VI-NEXT:    s_mov_b32 s16, 0xff0000
; VI-NEXT:    s_mov_b32 s17, 0xff000000
; VI-NEXT:    s_movk_i32 s18, 0xff
; VI-NEXT:    s_mov_b32 s19, 0xff00
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    s_mov_b32 s0, s4
; VI-NEXT:    s_mov_b32 s1, s5
; VI-NEXT:    s_load_dwordx8 s[4:11], s[6:7], 0x0
; VI-NEXT:    s_mov_b32 s3, 0xf000
; VI-NEXT:    s_mov_b32 s2, -1
; VI-NEXT:    s_waitcnt lgkmcnt(0)
; VI-NEXT:    v_mov_b32_e32 v0, s6
; VI-NEXT:    v_alignbit_b32 v1, s7, v0, 24
; VI-NEXT:    v_alignbit_b32 v0, s7, v0, 8
; VI-NEXT:    s_bfe_u32 s13, s7, 0x80010
; VI-NEXT:    v_and_b32_e32 v1, s16, v1
; VI-NEXT:    v_and_b32_e32 v0, s17, v0
; VI-NEXT:    s_lshr_b32 s12, s7, 24
; VI-NEXT:    s_lshl_b32 s13, s13, 8
; VI-NEXT:    s_or_b32 s12, s13, s12
; VI-NEXT:    v_or_b32_e32 v0, v0, v1
; VI-NEXT:    v_or_b32_e32 v2, s12, v0
; VI-NEXT:    v_mov_b32_e32 v0, s4
; VI-NEXT:    v_alignbit_b32 v1, s5, v0, 24
; VI-NEXT:    v_alignbit_b32 v0, s5, v0, 8
; VI-NEXT:    s_bfe_u32 s13, s5, 0x80010
; VI-NEXT:    v_and_b32_e32 v1, s16, v1
; VI-NEXT:    v_and_b32_e32 v0, s17, v0
; VI-NEXT:    s_lshr_b32 s12, s5, 24
; VI-NEXT:    s_lshl_b32 s13, s13, 8
; VI-NEXT:    v_or_b32_e32 v0, v0, v1
; VI-NEXT:    s_or_b32 s12, s13, s12
; VI-NEXT:    v_or_b32_e32 v0, s12, v0
; VI-NEXT:    s_lshl_b64 s[12:13], s[6:7], 8
; VI-NEXT:    s_lshl_b64 s[14:15], s[6:7], 24
; VI-NEXT:    s_mov_b32 s12, 0
; VI-NEXT:    s_and_b32 s13, s13, s18
; VI-NEXT:    s_and_b32 s15, s15, s19
; VI-NEXT:    s_mov_b32 s14, s12
; VI-NEXT:    s_or_b64 s[14:15], s[14:15], s[12:13]
; VI-NEXT:    s_lshl_b32 s13, s6, 24
; VI-NEXT:    s_lshl_b32 s6, s6, 8
; VI-NEXT:    s_and_b32 s7, s6, s16
; VI-NEXT:    s_mov_b32 s6, s12
; VI-NEXT:    s_or_b64 s[6:7], s[12:13], s[6:7]
; VI-NEXT:    s_or_b64 s[6:7], s[6:7], s[14:15]
; VI-NEXT:    s_lshl_b64 s[14:15], s[4:5], 8
; VI-NEXT:    s_and_b32 s13, s15, s18
; VI-NEXT:    s_lshl_b64 s[14:15], s[4:5], 24
; VI-NEXT:    s_and_b32 s15, s15, s19
; VI-NEXT:    s_mov_b32 s14, s12
; VI-NEXT:    s_or_b64 s[14:15], s[14:15], s[12:13]
; VI-NEXT:    s_lshl_b32 s13, s4, 24
; VI-NEXT:    s_lshl_b32 s4, s4, 8
; VI-NEXT:    s_and_b32 s5, s4, s16
; VI-NEXT:    s_mov_b32 s4, s12
; VI-NEXT:    s_or_b64 s[4:5], s[12:13], s[4:5]
; VI-NEXT:    v_mov_b32_e32 v1, s10
; VI-NEXT:    v_alignbit_b32 v3, s11, v1, 24
; VI-NEXT:    s_or_b64 s[4:5], s[4:5], s[14:15]
; VI-NEXT:    v_alignbit_b32 v1, s11, v1, 8
; VI-NEXT:    s_bfe_u32 s6, s11, 0x80010
; VI-NEXT:    v_and_b32_e32 v3, s16, v3
; VI-NEXT:    v_and_b32_e32 v1, s17, v1
; VI-NEXT:    s_lshr_b32 s4, s11, 24
; VI-NEXT:    s_lshl_b32 s6, s6, 8
; VI-NEXT:    s_or_b32 s4, s6, s4
; VI-NEXT:    v_or_b32_e32 v1, v1, v3
; VI-NEXT:    v_or_b32_e32 v5, s4, v1
; VI-NEXT:    v_mov_b32_e32 v1, s8
; VI-NEXT:    v_alignbit_b32 v3, s9, v1, 24
; VI-NEXT:    v_alignbit_b32 v1, s9, v1, 8
; VI-NEXT:    s_bfe_u32 s6, s9, 0x80010
; VI-NEXT:    s_lshl_b64 s[14:15], s[10:11], 8
; VI-NEXT:    v_and_b32_e32 v3, s16, v3
; VI-NEXT:    v_and_b32_e32 v1, s17, v1
; VI-NEXT:    s_lshr_b32 s4, s9, 24
; VI-NEXT:    s_lshl_b32 s6, s6, 8
; VI-NEXT:    s_and_b32 s13, s15, s18
; VI-NEXT:    s_lshl_b64 s[14:15], s[10:11], 24
; VI-NEXT:    v_or_b32_e32 v1, v1, v3
; VI-NEXT:    s_or_b32 s4, s6, s4
; VI-NEXT:    v_or_b32_e32 v3, s4, v1
; VI-NEXT:    s_lshl_b32 s4, s10, 8
; VI-NEXT:    s_and_b32 s15, s15, s19
; VI-NEXT:    s_mov_b32 s14, s12
; VI-NEXT:    s_or_b64 s[14:15], s[14:15], s[12:13]
; VI-NEXT:    s_lshl_b32 s13, s10, 24
; VI-NEXT:    s_and_b32 s11, s4, s16
; VI-NEXT:    s_mov_b32 s10, s12
; VI-NEXT:    s_or_b64 s[10:11], s[12:13], s[10:11]
; VI-NEXT:    s_or_b64 s[10:11], s[10:11], s[14:15]
; VI-NEXT:    s_lshl_b64 s[14:15], s[8:9], 8
; VI-NEXT:    s_and_b32 s13, s15, s18
; VI-NEXT:    s_lshl_b64 s[14:15], s[8:9], 24
; VI-NEXT:    s_lshl_b32 s4, s8, 8
; VI-NEXT:    s_and_b32 s15, s15, s19
; VI-NEXT:    s_mov_b32 s14, s12
; VI-NEXT:    s_or_b64 s[14:15], s[14:15], s[12:13]
; VI-NEXT:    s_lshl_b32 s13, s8, 24
; VI-NEXT:    s_and_b32 s9, s4, s16
; VI-NEXT:    s_mov_b32 s8, s12
; VI-NEXT:    s_or_b64 s[8:9], s[12:13], s[8:9]
; VI-NEXT:    s_or_b64 s[8:9], s[8:9], s[14:15]
; VI-NEXT:    v_mov_b32_e32 v4, s9
; VI-NEXT:    v_mov_b32_e32 v6, s11
; VI-NEXT:    buffer_store_dwordx4 v[3:6], off, s[0:3], 0 offset:16
; VI-NEXT:    v_mov_b32_e32 v1, s5
; VI-NEXT:    v_mov_b32_e32 v3, s7
; VI-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
; VI-NEXT:    s_endpgm
  %val = load <4 x i64>, <4 x i64> addrspace(1)* %in, align 32
  %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %val) nounwind readnone
  store <4 x i64> %bswap, <4 x i64> addrspace(1)* %out, align 32
  ret void
}

define float @missing_truncate_promote_bswap(i32 %arg) {
; SI-LABEL: missing_truncate_promote_bswap:
; SI:       ; %bb.0: ; %bb
; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NEXT:    v_alignbit_b32 v1, v0, v0, 8
; SI-NEXT:    v_alignbit_b32 v0, v0, v0, 24
; SI-NEXT:    s_mov_b32 s6, 0xff00ff
; SI-NEXT:    v_bfi_b32 v0, s6, v0, v1
; SI-NEXT:    v_lshrrev_b32_e32 v0, 16, v0
; SI-NEXT:    v_cvt_f32_f16_e32 v0, v0
; SI-NEXT:    s_setpc_b64 s[30:31]
;
; VI-LABEL: missing_truncate_promote_bswap:
; VI:       ; %bb.0: ; %bb
; VI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NEXT:    v_and_b32_e32 v0, 0xffff, v0
; VI-NEXT:    v_alignbit_b32 v1, v0, v0, 8
; VI-NEXT:    v_alignbit_b32 v0, v0, v0, 24
; VI-NEXT:    s_mov_b32 s6, 0xff00ff
; VI-NEXT:    v_bfi_b32 v0, s6, v0, v1
; VI-NEXT:    v_cvt_f32_f16_sdwa v0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
; VI-NEXT:    s_setpc_b64 s[30:31]
bb:
  %tmp = trunc i32 %arg to i16
  %tmp1 = call i16 @llvm.bswap.i16(i16 %tmp)
  %tmp2 = bitcast i16 %tmp1 to half
  %tmp3 = fpext half %tmp2 to float
  ret float %tmp3
}