1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -verify-machineinstrs -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=regallocfast -o - %s | FileCheck -check-prefix=GCN %s
3
4---
5name: self_loop_single_def_use
6tracksRegLiveness: true
7machineFunctionInfo:
8  isEntryFunction: true
9  scratchRSrcReg:  '$sgpr0_sgpr1_sgpr2_sgpr3'
10  stackPtrOffsetReg: '$sgpr32'
11body:             |
12  ; GCN-LABEL: name: self_loop_single_def_use
13  ; GCN: bb.0:
14  ; GCN:   successors: %bb.1(0x80000000)
15  ; GCN:   liveins: $vgpr0_vgpr1
16  ; GCN:   SI_SPILL_V64_SAVE killed $vgpr0_vgpr1, %stack.0, $sgpr32, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
17  ; GCN: bb.1:
18  ; GCN:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
19  ; GCN:   $vgpr0_vgpr1 = SI_SPILL_V64_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
20  ; GCN:   renamable $vgpr2 = GLOBAL_LOAD_DWORD renamable $vgpr0_vgpr1, 0, 0, 0, 0, implicit $exec
21  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, killed renamable $vgpr2, 0, 0, 0, 0, implicit $exec
22  ; GCN:   S_CBRANCH_EXECZ %bb.1, implicit $exec
23  ; GCN: bb.2:
24  ; GCN:   S_ENDPGM 0
25  bb.0:
26    liveins: $vgpr0_vgpr1
27    %0:vreg_64 = COPY $vgpr0_vgpr1
28
29  bb.1:
30    %1:vgpr_32 = GLOBAL_LOAD_DWORD %0, 0, 0, 0, 0, implicit $exec
31    GLOBAL_STORE_DWORD %0, %1, 0, 0, 0, 0, implicit $exec
32    S_CBRANCH_EXECZ %bb.1, implicit $exec
33
34  bb.2:
35    S_ENDPGM 0
36
37...
38
39---
40name: self_loop_multi_def
41tracksRegLiveness: true
42machineFunctionInfo:
43  isEntryFunction: true
44  scratchRSrcReg:  '$sgpr0_sgpr1_sgpr2_sgpr3'
45  stackPtrOffsetReg: '$sgpr32'
46body:             |
47  ; GCN-LABEL: name: self_loop_multi_def
48  ; GCN: bb.0:
49  ; GCN:   successors: %bb.1(0x80000000)
50  ; GCN:   liveins: $vgpr0_vgpr1
51  ; GCN:   SI_SPILL_V64_SAVE killed $vgpr0_vgpr1, %stack.0, $sgpr32, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
52  ; GCN: bb.1:
53  ; GCN:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
54  ; GCN:   $vgpr0_vgpr1 = SI_SPILL_V64_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
55  ; GCN:   renamable $vgpr2 = GLOBAL_LOAD_DWORD renamable $vgpr0_vgpr1, 0, 0, 0, 0, implicit $exec
56  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, renamable $vgpr2, 0, 0, 0, 0, implicit $exec
57  ; GCN:   renamable $vgpr2 = GLOBAL_LOAD_DWORD renamable $vgpr0_vgpr1, 0, 0, 0, 0, implicit $exec
58  ; GCN:   SI_SPILL_V32_SAVE $vgpr2, %stack.1, $sgpr32, 0, implicit $exec :: (store 4 into %stack.1, addrspace 5)
59  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, renamable $vgpr2, 0, 0, 0, 0, implicit $exec
60  ; GCN:   S_CBRANCH_EXECZ %bb.1, implicit $exec
61  ; GCN: bb.2:
62  ; GCN:   S_ENDPGM 0
63  bb.0:
64    liveins: $vgpr0_vgpr1
65    %0:vreg_64 = COPY $vgpr0_vgpr1
66
67  bb.1:
68    %1:vgpr_32 = GLOBAL_LOAD_DWORD %0, 0, 0, 0, 0, implicit $exec
69    GLOBAL_STORE_DWORD %0, %1, 0, 0, 0, 0, implicit $exec
70    %1:vgpr_32 = GLOBAL_LOAD_DWORD %0, 0, 0, 0, 0, implicit $exec
71    GLOBAL_STORE_DWORD %0, %1, 0, 0, 0, 0, implicit $exec
72    S_CBRANCH_EXECZ %bb.1, implicit $exec
73
74  bb.2:
75    S_ENDPGM 0
76
77...
78
79# There's a single def inside the self loop, but it's also a use.
80
81---
82name: self_loop_def_use_same_inst
83tracksRegLiveness: true
84machineFunctionInfo:
85  isEntryFunction: true
86  scratchRSrcReg:  '$sgpr0_sgpr1_sgpr2_sgpr3'
87  stackPtrOffsetReg: '$sgpr32'
88body:             |
89  ; GCN-LABEL: name: self_loop_def_use_same_inst
90  ; GCN: bb.0:
91  ; GCN:   successors: %bb.1(0x80000000)
92  ; GCN:   liveins: $vgpr0_vgpr1
93  ; GCN:   SI_SPILL_V64_SAVE killed $vgpr0_vgpr1, %stack.0, $sgpr32, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
94  ; GCN: bb.1:
95  ; GCN:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
96  ; GCN:   $vgpr0_vgpr1 = SI_SPILL_V64_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
97  ; GCN:   renamable $vgpr2 = V_ADD_U32_e32 1, undef $vgpr0, implicit $exec
98  ; GCN:   SI_SPILL_V32_SAVE $vgpr2, %stack.1, $sgpr32, 0, implicit $exec :: (store 4 into %stack.1, addrspace 5)
99  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, renamable $vgpr2, 0, 0, 0, 0, implicit $exec
100  ; GCN:   S_CBRANCH_EXECZ %bb.1, implicit $exec
101  ; GCN: bb.2:
102  ; GCN:   S_ENDPGM 0
103  bb.0:
104    liveins: $vgpr0_vgpr1
105    %0:vreg_64 = COPY $vgpr0_vgpr1
106
107  bb.1:
108    %1:vgpr_32 = V_ADD_U32_e32 1, undef %1, implicit $exec
109    GLOBAL_STORE_DWORD %0, %1, 0, 0, 0, 0, implicit $exec
110    S_CBRANCH_EXECZ %bb.1, implicit $exec
111
112  bb.2:
113    S_ENDPGM 0
114
115...
116
117---
118name: self_loop_def_after_use
119tracksRegLiveness: true
120machineFunctionInfo:
121  isEntryFunction: true
122  scratchRSrcReg:  '$sgpr0_sgpr1_sgpr2_sgpr3'
123  stackPtrOffsetReg: '$sgpr32'
124body:             |
125  ; GCN-LABEL: name: self_loop_def_after_use
126  ; GCN: bb.0:
127  ; GCN:   successors: %bb.1(0x80000000)
128  ; GCN:   liveins: $vgpr0_vgpr1
129  ; GCN:   SI_SPILL_V64_SAVE killed $vgpr0_vgpr1, %stack.0, $sgpr32, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
130  ; GCN: bb.1:
131  ; GCN:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
132  ; GCN:   $vgpr0_vgpr1 = SI_SPILL_V64_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
133  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, undef renamable $vgpr0, 0, 0, 0, 0, implicit $exec
134  ; GCN:   renamable $vgpr0 = V_ADD_U32_e64 1, 1, 0, implicit $exec
135  ; GCN:   SI_SPILL_V32_SAVE killed $vgpr0, %stack.1, $sgpr32, 0, implicit $exec :: (store 4 into %stack.1, addrspace 5)
136  ; GCN:   S_CBRANCH_EXECZ %bb.1, implicit $exec
137  ; GCN: bb.2:
138  ; GCN:   S_ENDPGM 0
139  bb.0:
140    liveins: $vgpr0_vgpr1
141    %0:vreg_64 = COPY $vgpr0_vgpr1
142
143  bb.1:
144    GLOBAL_STORE_DWORD %0, undef %1, 0, 0, 0, 0, implicit $exec
145    %1:vgpr_32 = V_ADD_U32_e64 1, 1, 0, implicit $exec
146    S_CBRANCH_EXECZ %bb.1, implicit $exec
147
148  bb.2:
149    S_ENDPGM 0
150
151...
152
153---
154name: self_loop_single_subreg_def_use
155tracksRegLiveness: true
156machineFunctionInfo:
157  isEntryFunction: true
158  scratchRSrcReg:  '$sgpr0_sgpr1_sgpr2_sgpr3'
159  stackPtrOffsetReg: '$sgpr32'
160body:             |
161  ; GCN-LABEL: name: self_loop_single_subreg_def_use
162  ; GCN: bb.0:
163  ; GCN:   successors: %bb.1(0x80000000)
164  ; GCN:   liveins: $vgpr0_vgpr1
165  ; GCN:   SI_SPILL_V64_SAVE killed $vgpr0_vgpr1, %stack.0, $sgpr32, 0, implicit $exec :: (store 8 into %stack.0, align 4, addrspace 5)
166  ; GCN: bb.1:
167  ; GCN:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
168  ; GCN:   $vgpr0_vgpr1 = SI_SPILL_V64_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load 8 from %stack.0, align 4, addrspace 5)
169  ; GCN:   undef renamable $vgpr3 = GLOBAL_LOAD_DWORD renamable $vgpr0_vgpr1, 0, 0, 0, 0, implicit $exec, implicit-def dead $vgpr2_vgpr3
170  ; GCN:   GLOBAL_STORE_DWORD renamable $vgpr0_vgpr1, undef renamable $vgpr1, 0, 0, 0, 0, implicit $exec
171  ; GCN:   S_CBRANCH_EXECZ %bb.1, implicit $exec
172  ; GCN: bb.2:
173  ; GCN:   S_ENDPGM 0
174  bb.0:
175    liveins: $vgpr0_vgpr1
176    %0:vreg_64 = COPY $vgpr0_vgpr1
177
178  bb.1:
179    undef %1.sub1:vreg_64 = GLOBAL_LOAD_DWORD %0, 0, 0, 0, 0, implicit $exec
180    GLOBAL_STORE_DWORD %0, undef %1.sub1, 0, 0, 0, 0, implicit $exec
181    S_CBRANCH_EXECZ %bb.1, implicit $exec
182
183  bb.2:
184    S_ENDPGM 0
185
186...
187