1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs -run-pass=si-fold-operands %s -o - | FileCheck -check-prefix=GCN %s
5 define amdgpu_kernel void @redef_m0_same_copy() { ret void }
6 define amdgpu_kernel void @multi_redef_m0_same_copy() { ret void }
7 define amdgpu_kernel void @redef_m0_different_copy() { ret void }
8 define amdgpu_kernel void @redef_m0_mixed_copy0() { ret void }
9 define amdgpu_kernel void @redef_m0_mixed_copy1() { ret void }
10 define amdgpu_kernel void @redef_m0_same_mov_imm() { ret void }
11 define amdgpu_kernel void @redef_m0_different_inst0() { ret void }
12 define amdgpu_kernel void @redef_m0_different_inst1() { ret void }
13 define amdgpu_kernel void @redef_m0_mixed_read_m0() { ret void }
14 define amdgpu_kernel void @redef_m0_same_copy_call() { ret void }
15 define amdgpu_kernel void @redef_m0_same_copy_multi_block() { ret void }
16 define amdgpu_kernel void @redef_m0_copy_self() { ret void }
17 define amdgpu_kernel void @redef_m0_copy_physreg() { ret void }
23 name: redef_m0_same_copy
24 tracksRegLiveness: true
29 liveins: $vgpr0, $sgpr0
31 ; GCN-LABEL: name: redef_m0_same_copy
32 ; GCN: liveins: $vgpr0, $sgpr0
34 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
35 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
36 ; GCN-NEXT: $m0 = COPY [[COPY1]]
37 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
38 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
39 %0:vgpr_32 = COPY $vgpr0
40 %1:sgpr_32 = COPY $sgpr0
42 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
44 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
49 name: multi_redef_m0_same_copy
50 tracksRegLiveness: true
55 liveins: $vgpr0, $sgpr0
57 ; GCN-LABEL: name: multi_redef_m0_same_copy
58 ; GCN: liveins: $vgpr0, $sgpr0
60 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
61 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
62 ; GCN-NEXT: $m0 = COPY [[COPY1]]
63 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
64 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
65 %0:vgpr_32 = COPY $vgpr0
66 %1:sgpr_32 = COPY $sgpr0
68 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
71 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
76 name: redef_m0_different_copy
77 tracksRegLiveness: true
82 liveins: $vgpr0, $sgpr0, $sgpr1
84 ; GCN-LABEL: name: redef_m0_different_copy
85 ; GCN: liveins: $vgpr0, $sgpr0, $sgpr1
87 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
88 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
89 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY $sgpr1
90 ; GCN-NEXT: $m0 = COPY [[COPY1]]
91 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
92 ; GCN-NEXT: $m0 = COPY [[COPY2]]
93 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
94 %0:vgpr_32 = COPY $vgpr0
95 %1:sgpr_32 = COPY $sgpr0
96 %2:sgpr_32 = COPY $sgpr1
98 %3:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
100 %4:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
105 name: redef_m0_mixed_copy0
106 tracksRegLiveness: true
108 isEntryFunction: true
111 liveins: $vgpr0, $sgpr0, $sgpr1
113 ; GCN-LABEL: name: redef_m0_mixed_copy0
114 ; GCN: liveins: $vgpr0, $sgpr0, $sgpr1
116 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
117 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
118 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY $sgpr1
119 ; GCN-NEXT: $m0 = COPY [[COPY1]]
120 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
121 ; GCN-NEXT: $m0 = COPY [[COPY2]]
122 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
123 %0:vgpr_32 = COPY $vgpr0
124 %1:sgpr_32 = COPY $sgpr0
125 %2:sgpr_32 = COPY $sgpr1
127 %3:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
130 %4:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
135 name: redef_m0_mixed_copy1
136 tracksRegLiveness: true
139 isEntryFunction: true
142 liveins: $vgpr0, $sgpr0, $sgpr1
144 ; GCN-LABEL: name: redef_m0_mixed_copy1
145 ; GCN: liveins: $vgpr0, $sgpr0, $sgpr1
147 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
148 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
149 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY $sgpr1
150 ; GCN-NEXT: $m0 = COPY [[COPY1]]
151 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
152 ; GCN-NEXT: $m0 = COPY [[COPY2]]
153 ; GCN-NEXT: $m0 = COPY [[COPY1]]
154 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
155 %0:vgpr_32 = COPY $vgpr0
156 %1:sgpr_32 = COPY $sgpr0
157 %2:sgpr_32 = COPY $sgpr1
159 %3:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
162 %4:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
167 name: redef_m0_same_mov_imm
168 tracksRegLiveness: true
170 isEntryFunction: true
173 liveins: $vgpr0, $sgpr0
175 ; GCN-LABEL: name: redef_m0_same_mov_imm
176 ; GCN: liveins: $vgpr0, $sgpr0
178 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
179 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
180 ; GCN-NEXT: $m0 = S_MOV_B32 -1
181 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
182 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
183 %0:vgpr_32 = COPY $vgpr0
184 %1:sgpr_32 = COPY $sgpr0
186 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
188 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
193 name: redef_m0_different_inst0
194 tracksRegLiveness: true
196 isEntryFunction: true
199 liveins: $vgpr0, $sgpr0
201 ; GCN-LABEL: name: redef_m0_different_inst0
202 ; GCN: liveins: $vgpr0, $sgpr0
204 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
205 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
206 ; GCN-NEXT: $m0 = COPY [[COPY1]]
207 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
208 ; GCN-NEXT: $m0 = IMPLICIT_DEF
209 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
210 %0:vgpr_32 = COPY $vgpr0
211 %1:sgpr_32 = COPY $sgpr0
213 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
215 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
220 name: redef_m0_different_inst1
221 tracksRegLiveness: true
223 isEntryFunction: true
226 liveins: $vgpr0, $sgpr0
228 ; GCN-LABEL: name: redef_m0_different_inst1
229 ; GCN: liveins: $vgpr0, $sgpr0
231 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
232 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
233 ; GCN-NEXT: $m0 = COPY [[COPY1]]
234 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
235 ; GCN-NEXT: S_NOP 0, implicit-def $m0
236 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
237 %0:vgpr_32 = COPY $vgpr0
238 %1:sgpr_32 = COPY $sgpr0
240 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
241 S_NOP 0, implicit-def $m0
242 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
247 name: redef_m0_mixed_read_m0
248 tracksRegLiveness: true
250 isEntryFunction: true
253 liveins: $vgpr0, $sgpr0, $sgpr1
255 ; GCN-LABEL: name: redef_m0_mixed_read_m0
256 ; GCN: liveins: $vgpr0, $sgpr0, $sgpr1
258 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
259 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
260 ; GCN-NEXT: [[COPY2:%[0-9]+]]:sgpr_32 = COPY $sgpr1
261 ; GCN-NEXT: $m0 = COPY [[COPY1]]
262 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
263 ; GCN-NEXT: $m0 = COPY [[COPY2]]
264 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
265 ; GCN-NEXT: [[DS_READ_B32_2:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 128, 0, implicit $m0, implicit $exec :: (load (s32))
266 %0:vgpr_32 = COPY $vgpr0
267 %1:sgpr_32 = COPY $sgpr0
268 %2:sgpr_32 = COPY $sgpr1
270 %3:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
272 %4:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
274 %5:vgpr_32 = DS_READ_B32 %0, 128, 0, implicit $m0, implicit $exec :: (load (s32))
278 name: redef_m0_same_copy_call
279 tracksRegLiveness: true
281 isEntryFunction: true
284 liveins: $vgpr0, $sgpr0
286 ; GCN-LABEL: name: redef_m0_same_copy_call
287 ; GCN: liveins: $vgpr0, $sgpr0
289 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
290 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
291 ; GCN-NEXT: $m0 = COPY [[COPY1]]
292 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
293 ; GCN-NEXT: dead $sgpr30_sgpr31 = SI_CALL undef $sgpr6_sgpr7, @func, csr_amdgpu
294 ; GCN-NEXT: $m0 = COPY [[COPY1]]
295 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
296 %0:vgpr_32 = COPY $vgpr0
297 %1:sgpr_32 = COPY $sgpr0
299 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
300 dead $sgpr30_sgpr31 = SI_CALL undef $sgpr6_sgpr7, @func, csr_amdgpu
302 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
307 name: redef_m0_same_copy_multi_block
308 tracksRegLiveness: true
310 isEntryFunction: true
312 ; GCN-LABEL: name: redef_m0_same_copy_multi_block
314 ; GCN-NEXT: successors: %bb.1(0x80000000)
315 ; GCN-NEXT: liveins: $vgpr0, $sgpr0
317 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
318 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
319 ; GCN-NEXT: $m0 = COPY [[COPY1]]
320 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
323 ; GCN-NEXT: $m0 = COPY [[COPY1]]
324 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
326 liveins: $vgpr0, $sgpr0
328 %0:vgpr_32 = COPY $vgpr0
329 %1:sgpr_32 = COPY $sgpr0
331 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
335 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
340 name: redef_m0_copy_self
341 tracksRegLiveness: true
343 isEntryFunction: true
346 liveins: $vgpr0, $sgpr0
348 ; GCN-LABEL: name: redef_m0_copy_self
349 ; GCN: liveins: $vgpr0, $sgpr0
351 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
352 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
353 ; GCN-NEXT: $m0 = COPY [[COPY1]]
354 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
355 ; GCN-NEXT: $m0 = COPY $m0
356 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
357 %0:vgpr_32 = COPY $vgpr0
358 %1:sgpr_32 = COPY $sgpr0
360 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
362 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))
367 name: redef_m0_copy_physreg
368 tracksRegLiveness: true
370 isEntryFunction: true
373 liveins: $vgpr0, $sgpr0
375 ; GCN-LABEL: name: redef_m0_copy_physreg
376 ; GCN: liveins: $vgpr0, $sgpr0
378 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
379 ; GCN-NEXT: [[COPY1:%[0-9]+]]:sgpr_32 = COPY $sgpr0
380 ; GCN-NEXT: $m0 = COPY $sgpr0
381 ; GCN-NEXT: [[DS_READ_B32_:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 0, 0, implicit $m0, implicit $exec :: (load (s32))
382 ; GCN-NEXT: $sgpr0 = S_MOV_B32 0
383 ; GCN-NEXT: $m0 = COPY $sgpr0
384 ; GCN-NEXT: [[DS_READ_B32_1:%[0-9]+]]:vgpr_32 = DS_READ_B32 [[COPY]], 64, 0, implicit $m0, implicit $exec :: (load (s32))
385 %0:vgpr_32 = COPY $vgpr0
386 %1:sgpr_32 = COPY $sgpr0
388 %2:vgpr_32 = DS_READ_B32 %0, 0, 0, implicit $m0, implicit $exec :: (load (s32))
391 %3:vgpr_32 = DS_READ_B32 %0, 64, 0, implicit $m0, implicit $exec :: (load (s32))