1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=thumbv7m-none-eabi -run-pass=arm-cp-islands -o - %s | FileCheck %s
3
4--- |
5  define i32* @test_simple(i32* %x, i32 %y) { ret i32* %x }
6  define i32* @test_notfirst(i32* %x, i32 %y) { ret i32* %x }
7  define i32* @test_redefined(i32* %x, i32 %y) { ret i32* %x }
8  define i32* @test_notredefined(i32* %x, i32 %y) { ret i32* %x }
9  define i32* @test_notcmp(i32* %x, i32 %y) { ret i32* %x }
10  define i32* @test_killflag_1(i32* %x, i32 %y) { ret i32* %x }
11  define i32* @test_killflag_2(i32* %x, i32 %y) { ret i32* %x }
12  define i32* @test_cpsr(i32* %x, i32 %y) { ret i32* %x }
13
14  declare dso_local i32 @c(i32 %x)
15...
16---
17name:            test_simple
18tracksRegLiveness: true
19liveins:
20  - { reg: '$r0', virtual-reg: '' }
21  - { reg: '$r1', virtual-reg: '' }
22body:             |
23  ; CHECK-LABEL: name: test_simple
24  ; CHECK: bb.0:
25  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
26  ; CHECK:   liveins: $r0, $r1
27  ; CHECK:   tCBZ renamable $r0, %bb.2
28  ; CHECK: bb.1:
29  ; CHECK:   liveins: $r0
30  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
31  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
32  ; CHECK: bb.2:
33  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
34  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
35  bb.0:
36    successors: %bb.1(0x30000000), %bb.2(0x50000000)
37    liveins: $r0, $r1
38
39    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
40    t2Bcc %bb.1, 0, killed $cpsr
41
42  bb.2:
43    liveins: $r0
44
45    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
46    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
47
48  bb.1:
49    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
50    tBX_RET 14, $noreg, implicit killed $r0
51
52...
53---
54name:            test_notfirst
55tracksRegLiveness: true
56liveins:
57  - { reg: '$r0', virtual-reg: '' }
58  - { reg: '$r1', virtual-reg: '' }
59body:             |
60  ; CHECK-LABEL: name: test_notfirst
61  ; CHECK: bb.0:
62  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
63  ; CHECK:   liveins: $r0, $r1
64  ; CHECK:   renamable $r0, $cpsr = tADDrr killed renamable $r0, renamable $r1, 14 /* CC::al */, $noreg
65  ; CHECK:   renamable $r1 = t2ADDrs renamable $r0, killed renamable $r1, 18, 14 /* CC::al */, $noreg, $noreg
66  ; CHECK:   tCBZ renamable $r0, %bb.2
67  ; CHECK: bb.1:
68  ; CHECK:   liveins: $r0
69  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
70  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
71  ; CHECK: bb.2:
72  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
73  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
74  bb.0:
75    successors: %bb.1(0x30000000), %bb.2(0x50000000)
76    liveins: $r0, $r1
77
78    renamable $r0, $cpsr = tADDrr killed renamable $r0, renamable $r1, 14, $noreg
79    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
80    renamable $r1 = t2ADDrs renamable $r0, killed renamable $r1, 18, 14, $noreg, $noreg
81    t2Bcc %bb.1, 0, killed $cpsr
82
83  bb.2:
84    liveins: $r0
85
86    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
87    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
88
89  bb.1:
90    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
91    tBX_RET 14, $noreg, implicit killed $r0
92
93...
94---
95name:            test_redefined
96tracksRegLiveness: true
97liveins:
98  - { reg: '$r0', virtual-reg: '' }
99  - { reg: '$r1', virtual-reg: '' }
100body:             |
101  ; CHECK-LABEL: name: test_redefined
102  ; CHECK: bb.0:
103  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
104  ; CHECK:   liveins: $r0, $r1
105  ; CHECK:   tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
106  ; CHECK:   renamable $r0 = t2ADDrs killed renamable $r0, killed renamable $r1, 18, 14 /* CC::al */, $noreg, $noreg
107  ; CHECK:   tBcc %bb.2, 0 /* CC::eq */, killed $cpsr
108  ; CHECK: bb.1:
109  ; CHECK:   liveins: $r0
110  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
111  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
112  ; CHECK: bb.2:
113  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
114  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
115  bb.0:
116    successors: %bb.1(0x30000000), %bb.2(0x50000000)
117    liveins: $r0, $r1
118
119    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
120    renamable $r0 = t2ADDrs killed renamable $r0, killed renamable $r1, 18, 14, $noreg, $noreg
121    t2Bcc %bb.1, 0, killed $cpsr
122
123  bb.2:
124    liveins: $r0
125
126    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
127    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
128
129  bb.1:
130    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
131    tBX_RET 14, $noreg, implicit killed $r0
132
133...
134---
135name:            test_notredefined
136tracksRegLiveness: true
137liveins:
138  - { reg: '$r0', virtual-reg: '' }
139  - { reg: '$r1', virtual-reg: '' }
140body:             |
141  ; CHECK-LABEL: name: test_notredefined
142  ; CHECK: bb.0:
143  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
144  ; CHECK:   liveins: $r0, $r1
145  ; CHECK:   renamable $r1 = t2ADDrs renamable $r0, killed renamable $r1, 18, 14 /* CC::al */, $noreg, $noreg
146  ; CHECK:   tCBZ renamable $r0, %bb.2
147  ; CHECK: bb.1:
148  ; CHECK:   liveins: $r0
149  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
150  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
151  ; CHECK: bb.2:
152  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
153  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
154  bb.0:
155    successors: %bb.1(0x30000000), %bb.2(0x50000000)
156    liveins: $r0, $r1
157
158    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
159    renamable $r1 = t2ADDrs renamable $r0, killed renamable $r1, 18, 14, $noreg, $noreg
160    t2Bcc %bb.1, 0, killed $cpsr
161
162  bb.2:
163    liveins: $r0
164
165    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
166    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
167
168  bb.1:
169    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
170    tBX_RET 14, $noreg, implicit killed $r0
171
172...
173---
174name:            test_notcmp
175tracksRegLiveness: true
176liveins:
177  - { reg: '$r0', virtual-reg: '' }
178  - { reg: '$r1', virtual-reg: '' }
179body:             |
180  ; CHECK-LABEL: name: test_notcmp
181  ; CHECK: bb.0:
182  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
183  ; CHECK:   liveins: $r0, $r1
184  ; CHECK:   tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
185  ; CHECK:   renamable $r1, $cpsr = tADDrr renamable $r0, killed renamable $r1, 14 /* CC::al */, $noreg
186  ; CHECK:   tBcc %bb.2, 0 /* CC::eq */, killed $cpsr
187  ; CHECK: bb.1:
188  ; CHECK:   liveins: $r0
189  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
190  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
191  ; CHECK: bb.2:
192  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
193  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
194  bb.0:
195    successors: %bb.1(0x30000000), %bb.2(0x50000000)
196    liveins: $r0, $r1
197
198    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
199    renamable $r1, $cpsr = tADDrr renamable $r0, killed renamable $r1, 14, $noreg
200    t2Bcc %bb.1, 0, killed $cpsr
201
202  bb.2:
203    liveins: $r0
204
205    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
206    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
207
208  bb.1:
209    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
210    tBX_RET 14, $noreg, implicit killed $r0
211
212...
213---
214name:            test_killflag_1
215tracksRegLiveness: true
216liveins:
217  - { reg: '$r0', virtual-reg: '' }
218  - { reg: '$r1', virtual-reg: '' }
219body:             |
220  ; CHECK-LABEL: name: test_killflag_1
221  ; CHECK: bb.0:
222  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
223  ; CHECK:   liveins: $r0, $r1
224  ; CHECK:   renamable $r0 = t2ADDrs killed renamable $r0, killed renamable $r0, 18, 14 /* CC::al */, $noreg, $noreg
225  ; CHECK:   tCBZ killed renamable $r1, %bb.2
226  ; CHECK: bb.1:
227  ; CHECK:   liveins: $r0
228  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
229  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
230  ; CHECK: bb.2:
231  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
232  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
233  bb.0:
234    successors: %bb.1(0x30000000), %bb.2(0x50000000)
235    liveins: $r0, $r1
236
237    tCMPi8 killed renamable $r1, 0, 14, $noreg, implicit-def $cpsr
238    renamable $r0 = t2ADDrs killed renamable $r0, killed renamable $r0, 18, 14, $noreg, $noreg
239    t2Bcc %bb.1, 0, killed $cpsr
240
241  bb.2:
242    liveins: $r0
243
244    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
245    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
246
247  bb.1:
248    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
249    tBX_RET 14, $noreg, implicit killed $r0
250
251...
252---
253name:            test_killflag_2
254tracksRegLiveness: true
255liveins:
256  - { reg: '$r0', virtual-reg: '' }
257  - { reg: '$r1', virtual-reg: '' }
258body:             |
259  ; CHECK-LABEL: name: test_killflag_2
260  ; CHECK: bb.0:
261  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
262  ; CHECK:   liveins: $r0, $r1
263  ; CHECK:   renamable $r0 = t2ADDrs renamable $r1, killed renamable $r0, 18, 14 /* CC::al */, $noreg, $noreg
264  ; CHECK:   tCBZ killed renamable $r1, %bb.2
265  ; CHECK: bb.1:
266  ; CHECK:   liveins: $r0
267  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
268  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
269  ; CHECK: bb.2:
270  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
271  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
272  bb.0:
273    successors: %bb.1(0x30000000), %bb.2(0x50000000)
274    liveins: $r0, $r1
275
276    tCMPi8 renamable $r1, 0, 14, $noreg, implicit-def $cpsr
277    renamable $r0 = t2ADDrs killed renamable $r1, killed renamable $r0, 18, 14, $noreg, $noreg
278    t2Bcc %bb.1, 0, killed $cpsr
279
280  bb.2:
281    liveins: $r0
282
283    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
284    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
285
286  bb.1:
287    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
288    tBX_RET 14, $noreg, implicit killed $r0
289
290...
291---
292name:            test_cpsr
293tracksRegLiveness: true
294liveins:
295  - { reg: '$r0', virtual-reg: '' }
296  - { reg: '$r1', virtual-reg: '' }
297body:             |
298  ; CHECK-LABEL: name: test_cpsr
299  ; CHECK: bb.0:
300  ; CHECK:   successors: %bb.2(0x30000000), %bb.1(0x50000000)
301  ; CHECK:   liveins: $r0, $r1
302  ; CHECK:   tCMPi8 renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr
303  ; CHECK:   t2IT 0, 8, implicit-def $itstate
304  ; CHECK:   renamable $r1 = t2ADDri killed renamable $r1, 1, 1 /* CC::ne */, $cpsr, $noreg, implicit killed $itstate
305  ; CHECK:   tBcc %bb.2, 0 /* CC::eq */, killed $cpsr
306  ; CHECK: bb.1:
307  ; CHECK:   liveins: $r0
308  ; CHECK:   renamable $r0 = tLDRi killed renamable $r0, 0, 14 /* CC::al */, $noreg :: (load (s32) from %ir.x)
309  ; CHECK:   tTAILJMPdND @c, 14 /* CC::al */, $noreg, implicit $sp, implicit $sp, implicit killed $r0
310  ; CHECK: bb.2:
311  ; CHECK:   $r0, dead $cpsr = tMOVi8 0, 14 /* CC::al */, $noreg
312  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit killed $r0
313  bb.0:
314    successors: %bb.1(0x30000000), %bb.2(0x50000000)
315    liveins: $r0, $r1
316
317    tCMPi8 renamable $r0, 0, 14, $noreg, implicit-def $cpsr
318    t2IT 0, 8, implicit-def $itstate
319    renamable $r1 = t2ADDri killed renamable $r1, 1, 1, $cpsr, $noreg, implicit killed $itstate
320    t2Bcc %bb.1, 0, killed $cpsr
321
322  bb.2:
323    liveins: $r0
324
325    renamable $r0 = tLDRi killed renamable $r0, 0, 14, $noreg :: (load (s32) from %ir.x)
326    tTAILJMPdND @c, 14, $noreg, implicit $sp, implicit $sp, implicit killed $r0
327
328  bb.1:
329    $r0, dead $cpsr = tMOVi8 0, 14, $noreg
330    tBX_RET 14, $noreg, implicit killed $r0
331
332...
333
334