1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -march=amdgcn -mcpu=tahiti -run-pass=instruction-select -verify-machineinstrs  -global-isel-abort=0 -o - %s | FileCheck -check-prefix=GFX6 %s
3# RUN: llc -march=amdgcn -mcpu=hawaii -run-pass=instruction-select -verify-machineinstrs  -global-isel-abort=0 -o - %s | FileCheck -check-prefix=GFX7 %s
4# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=instruction-select -verify-machineinstrs  -global-isel-abort=0 -o - %s | FileCheck -check-prefix=GFX7 %s
5# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass=instruction-select -verify-machineinstrs -global-isel-abort=0 -o - %s | FileCheck -check-prefix=GFX9 %s
6# RUN: llc -march=amdgcn -mcpu=gfx1010 -run-pass=instruction-select -verify-machineinstrs -global-isel-abort=0 -o - %s | FileCheck -check-prefix=GFX9 %s
7
8
9---
10name:            atomicrmw_xchg_s32_local
11legalized:       true
12regBankSelected: true
13tracksRegLiveness: true
14body:             |
15  bb.0:
16    liveins: $vgpr0, $vgpr1
17
18    ; GFX6-LABEL: name: atomicrmw_xchg_s32_local
19    ; GFX6: liveins: $vgpr0, $vgpr1
20    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
21    ; GFX6: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
22    ; GFX6: $m0 = S_MOV_B32 -1
23    ; GFX6: [[DS_WRXCHG_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32 [[COPY]], [[COPY1]], 0, 0, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 3)
24    ; GFX6: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_]]
25    ; GFX7-LABEL: name: atomicrmw_xchg_s32_local
26    ; GFX7: liveins: $vgpr0, $vgpr1
27    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
28    ; GFX7: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
29    ; GFX7: $m0 = S_MOV_B32 -1
30    ; GFX7: [[DS_WRXCHG_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32 [[COPY]], [[COPY1]], 0, 0, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 3)
31    ; GFX7: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_]]
32    ; GFX9-LABEL: name: atomicrmw_xchg_s32_local
33    ; GFX9: liveins: $vgpr0, $vgpr1
34    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
35    ; GFX9: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
36    ; GFX9: [[DS_WRXCHG_RTN_B32_gfx9_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32_gfx9 [[COPY]], [[COPY1]], 0, 0, implicit $exec :: (load store seq_cst 4, addrspace 3)
37    ; GFX9: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_gfx9_]]
38    %0:vgpr(p3) = COPY $vgpr0
39    %1:vgpr(s32) = COPY $vgpr1
40    %2:vgpr(s32) = G_ATOMICRMW_XCHG %0(p3), %1 :: (load store seq_cst 4, addrspace 3)
41    $vgpr0 = COPY %2
42
43...
44
45---
46name:            atomicrmw_xchg_s32_local_gep4
47legalized:       true
48regBankSelected: true
49tracksRegLiveness: true
50body:             |
51  bb.0:
52    liveins: $vgpr0, $vgpr1
53
54    ; GFX6-LABEL: name: atomicrmw_xchg_s32_local_gep4
55    ; GFX6: liveins: $vgpr0, $vgpr1
56    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
57    ; GFX6: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
58    ; GFX6: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 4, implicit $exec
59    ; GFX6: %3:vgpr_32, dead %5:sreg_64_xexec = V_ADD_CO_U32_e64 [[COPY]], [[V_MOV_B32_e32_]], 0, implicit $exec
60    ; GFX6: $m0 = S_MOV_B32 -1
61    ; GFX6: [[DS_WRXCHG_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32 %3, [[COPY1]], 0, 0, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 3)
62    ; GFX6: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_]]
63    ; GFX7-LABEL: name: atomicrmw_xchg_s32_local_gep4
64    ; GFX7: liveins: $vgpr0, $vgpr1
65    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
66    ; GFX7: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
67    ; GFX7: $m0 = S_MOV_B32 -1
68    ; GFX7: [[DS_WRXCHG_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32 [[COPY]], [[COPY1]], 4, 0, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 3)
69    ; GFX7: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_]]
70    ; GFX9-LABEL: name: atomicrmw_xchg_s32_local_gep4
71    ; GFX9: liveins: $vgpr0, $vgpr1
72    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
73    ; GFX9: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
74    ; GFX9: [[DS_WRXCHG_RTN_B32_gfx9_:%[0-9]+]]:vgpr_32 = DS_WRXCHG_RTN_B32_gfx9 [[COPY]], [[COPY1]], 4, 0, implicit $exec :: (load store seq_cst 4, addrspace 3)
75    ; GFX9: $vgpr0 = COPY [[DS_WRXCHG_RTN_B32_gfx9_]]
76    %0:vgpr(p3) = COPY $vgpr0
77    %1:vgpr(s32) = COPY $vgpr1
78    %2:vgpr(s32) = G_CONSTANT i32 4
79    %3:vgpr(p3) = G_PTR_ADD %0, %2
80    %4:vgpr(s32) = G_ATOMICRMW_XCHG %3(p3), %1 :: (load store seq_cst 4, addrspace 3)
81    $vgpr0 = COPY %4
82
83...
84