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:            atomic_cmpxchg_s32_region
11legalized:       true
12regBankSelected: true
13tracksRegLiveness: true
14body:             |
15  bb.0:
16    liveins: $vgpr0, $vgpr1, $vgpr2
17
18    ; GFX6-LABEL: name: atomic_cmpxchg_s32_region
19    ; GFX6: liveins: $vgpr0, $vgpr1, $vgpr2
20    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
21    ; GFX6: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
22    ; GFX6: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
23    ; GFX6: $m0 = S_MOV_B32 -1
24    ; GFX6: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
25    ; GFX6: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
26    ; GFX7-LABEL: name: atomic_cmpxchg_s32_region
27    ; GFX7: liveins: $vgpr0, $vgpr1, $vgpr2
28    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
29    ; GFX7: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
30    ; GFX7: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
31    ; GFX7: $m0 = S_MOV_B32 -1
32    ; GFX7: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
33    ; GFX7: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
34    ; GFX9-LABEL: name: atomic_cmpxchg_s32_region
35    ; GFX9: liveins: $vgpr0, $vgpr1, $vgpr2
36    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
37    ; GFX9: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
38    ; GFX9: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
39    ; GFX9: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
40    ; GFX9: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
41    %0:vgpr(p2) = COPY $vgpr0
42    %1:vgpr(s32) = COPY $vgpr1
43    %2:vgpr(s32) = COPY $vgpr2
44    %3:vgpr(s32) = G_ATOMIC_CMPXCHG %0, %1, %2 :: (load store seq_cst 4, addrspace 2)
45    $vgpr0 = COPY %3
46
47...
48
49---
50name:            atomic_cmpxchg_s32_region_gep4
51legalized:       true
52regBankSelected: true
53tracksRegLiveness: true
54body:             |
55  bb.0:
56    liveins: $vgpr0, $vgpr1, $vgpr2
57
58    ; GFX6-LABEL: name: atomic_cmpxchg_s32_region_gep4
59    ; GFX6: liveins: $vgpr0, $vgpr1, $vgpr2
60    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
61    ; GFX6: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
62    ; GFX6: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
63    ; GFX6: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 4, implicit $exec
64    ; GFX6: %4:vgpr_32, dead %6:sreg_64_xexec = V_ADD_CO_U32_e64 [[COPY]], [[V_MOV_B32_e32_]], 0, implicit $exec
65    ; GFX6: $m0 = S_MOV_B32 -1
66    ; GFX6: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 %4, [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
67    ; GFX6: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
68    ; GFX7-LABEL: name: atomic_cmpxchg_s32_region_gep4
69    ; GFX7: liveins: $vgpr0, $vgpr1, $vgpr2
70    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
71    ; GFX7: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
72    ; GFX7: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
73    ; GFX7: $m0 = S_MOV_B32 -1
74    ; GFX7: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 [[COPY]], [[COPY1]], [[COPY2]], 4, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
75    ; GFX7: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
76    ; GFX9-LABEL: name: atomic_cmpxchg_s32_region_gep4
77    ; GFX9: liveins: $vgpr0, $vgpr1, $vgpr2
78    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
79    ; GFX9: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
80    ; GFX9: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
81    ; GFX9: [[DS_CMPST_RTN_B32_:%[0-9]+]]:vgpr_32 = DS_CMPST_RTN_B32 [[COPY]], [[COPY1]], [[COPY2]], 4, 1, implicit $m0, implicit $exec :: (load store seq_cst 4, addrspace 2)
82    ; GFX9: $vgpr0 = COPY [[DS_CMPST_RTN_B32_]]
83    %0:vgpr(p2) = COPY $vgpr0
84    %1:vgpr(s32) = COPY $vgpr1
85    %2:vgpr(s32) = COPY $vgpr2
86    %3:vgpr(s32) = G_CONSTANT i32 4
87    %4:vgpr(p2) = G_PTR_ADD %0, %3
88    %5:vgpr(s32) = G_ATOMIC_CMPXCHG %4, %1, %2 :: (load store seq_cst 4, addrspace 2)
89    $vgpr0 = COPY %5
90
91...
92
93---
94name:            atomic_cmpxchg_s64_region
95legalized:       true
96regBankSelected: true
97tracksRegLiveness: true
98body:             |
99  bb.0:
100    liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
101
102    ; GFX6-LABEL: name: atomic_cmpxchg_s64_region
103    ; GFX6: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
104    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
105    ; GFX6: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
106    ; GFX6: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
107    ; GFX6: $m0 = S_MOV_B32 -1
108    ; GFX6: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
109    ; GFX6: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
110    ; GFX7-LABEL: name: atomic_cmpxchg_s64_region
111    ; GFX7: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
112    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
113    ; GFX7: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
114    ; GFX7: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
115    ; GFX7: $m0 = S_MOV_B32 -1
116    ; GFX7: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
117    ; GFX7: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
118    ; GFX9-LABEL: name: atomic_cmpxchg_s64_region
119    ; GFX9: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
120    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
121    ; GFX9: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
122    ; GFX9: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
123    ; GFX9: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
124    ; GFX9: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
125    %0:vgpr(p2) = COPY $vgpr0
126    %1:vgpr(s64) = COPY $vgpr1_vgpr2
127    %2:vgpr(s64) = COPY $vgpr3_vgpr4
128    %3:vgpr(s64) = G_ATOMIC_CMPXCHG %0, %1, %2 :: (load store seq_cst 8, addrspace 2)
129    $vgpr0_vgpr1 = COPY %3
130
131...
132
133---
134name:            atomic_cmpxchg_s64_region_gep4
135legalized:       true
136regBankSelected: true
137tracksRegLiveness: true
138body:             |
139  bb.0:
140    liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
141
142    ; GFX6-LABEL: name: atomic_cmpxchg_s64_region_gep4
143    ; GFX6: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
144    ; GFX6: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
145    ; GFX6: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
146    ; GFX6: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
147    ; GFX6: $m0 = S_MOV_B32 -1
148    ; GFX6: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
149    ; GFX6: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
150    ; GFX7-LABEL: name: atomic_cmpxchg_s64_region_gep4
151    ; GFX7: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
152    ; GFX7: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
153    ; GFX7: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
154    ; GFX7: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
155    ; GFX7: $m0 = S_MOV_B32 -1
156    ; GFX7: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
157    ; GFX7: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
158    ; GFX9-LABEL: name: atomic_cmpxchg_s64_region_gep4
159    ; GFX9: liveins: $vgpr0, $vgpr1_vgpr2, $vgpr3_vgpr4
160    ; GFX9: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
161    ; GFX9: [[COPY1:%[0-9]+]]:vreg_64 = COPY $vgpr1_vgpr2
162    ; GFX9: [[COPY2:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
163    ; GFX9: [[DS_CMPST_RTN_B64_:%[0-9]+]]:vreg_64 = DS_CMPST_RTN_B64 [[COPY]], [[COPY1]], [[COPY2]], 0, 1, implicit $m0, implicit $exec :: (load store seq_cst 8, addrspace 2)
164    ; GFX9: $vgpr0_vgpr1 = COPY [[DS_CMPST_RTN_B64_]]
165    %0:vgpr(p2) = COPY $vgpr0
166    %1:vgpr(s64) = COPY $vgpr1_vgpr2
167    %2:vgpr(s64) = COPY $vgpr3_vgpr4
168    %3:vgpr(s32) = G_CONSTANT i32 4
169    %4:vgpr(p2) = G_PTR_ADD %0, %3
170    %5:vgpr(s64) = G_ATOMIC_CMPXCHG %0, %1, %2 :: (load store seq_cst 8, addrspace 2)
171    $vgpr0_vgpr1 = COPY %5
172
173...
174