1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -O3 -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
3# RUN: -mcpu=pwr9 -simplify-mir -run-pass=machine-cp %s -o - | FileCheck %s
4
5
6# Normal case
7---
8name: test0
9alignment: 4
10tracksRegLiveness: true
11body: |
12  bb.0.entry:
13    ; CHECK-LABEL: name: test0
14    ; CHECK: $x3 = LI8 1024
15    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
16    renamable $x4 = LI8 1024
17    $x3 = COPY renamable killed $x4
18    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
19
20...
21
22# Not in terminal BBs
23---
24name: test1
25alignment: 4
26tracksRegLiveness: true
27body: |
28  ; CHECK-LABEL: name: test1
29  ; CHECK: bb.0.entry:
30  ; CHECK:   renamable $x4 = LI8 42
31  ; CHECK:   B %bb.1
32  ; CHECK: bb.1:
33  ; CHECK:   liveins: $x4
34  ; CHECK:   $x3 = COPY killed renamable $x4
35  ; CHECK:   BLR8 implicit $lr8, implicit undef $rm, implicit $x3
36  bb.0.entry:
37    successors: %bb.1
38
39    renamable $x5 = LI8 42
40    renamable $x4 = COPY renamable killed $x5
41    B %bb.1
42
43  bb.1:
44    liveins: $x4
45    $x3 = COPY renamable killed $x4
46    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
47
48...
49
50# Use reserved register
51---
52name: test2
53alignment: 4
54tracksRegLiveness: true
55body: |
56  bb.0.entry:
57    ; CHECK-LABEL: name: test2
58    ; CHECK: renamable $x4 = LI8 1024
59    ; CHECK: $x13 = COPY killed renamable $x4
60    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit undef $x3
61    renamable $x4 = LI8 1024
62    $x13 = COPY renamable killed $x4
63    BLR8 implicit $lr8, implicit undef $rm, implicit undef $x3
64
65...
66
67# Intermediate read of copy's src
68---
69name: test3
70alignment: 4
71tracksRegLiveness: true
72body: |
73  bb.0.entry:
74    ; CHECK-LABEL: name: test3
75    ; CHECK: renamable $x4 = LI8 0
76    ; CHECK: renamable $x5 = ADDI8 $x4, 1
77    ; CHECK: $x3 = COPY killed renamable $x4
78    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
79    renamable $x4 = LI8 0
80    renamable $x5 = ADDI8 $x4, 1
81    $x3 = COPY renamable killed $x4
82    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
83
84...
85
86# Intermediate read of copy's def
87---
88name: test4
89alignment: 4
90tracksRegLiveness: true
91body: |
92  bb.0.entry:
93    liveins: $x3
94
95    ; CHECK-LABEL: name: test4
96    ; CHECK: liveins: $x3
97    ; CHECK: renamable $x4 = LI8 0
98    ; CHECK: renamable $x5 = ADDI8 $x3, 1
99    ; CHECK: $x3 = COPY killed renamable $x4
100    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
101    renamable $x4 = LI8 0
102    renamable $x5 = ADDI8 $x3, 1
103    $x3 = COPY renamable killed $x4
104    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
105
106...
107
108# Intermiediate clobber of copy's def
109---
110name: test5
111alignment: 4
112tracksRegLiveness: true
113body: |
114  bb.0.entry:
115    liveins: $x3, $x5
116
117    ; CHECK-LABEL: name: test5
118    ; CHECK: liveins: $x3, $x5
119    ; CHECK: renamable $x4 = LI8 0
120    ; CHECK: renamable $x3 = ADDI8 $x5, 1
121    ; CHECK: $x3 = COPY killed renamable $x4
122    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
123    renamable $x4 = LI8 0
124    renamable $x3 = ADDI8 $x5, 1
125    $x3 = COPY renamable killed $x4
126    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
127
128...
129
130---
131name: iterative_deletion
132alignment: 4
133tracksRegLiveness: true
134body: |
135  bb.0.entry:
136    liveins: $x5
137
138    ; CHECK-LABEL: name: iterative_deletion
139    ; CHECK: liveins: $x5
140    ; CHECK: renamable $x4 = ADDI8 killed renamable $x5, 1
141    ; CHECK: $x3 = COPY $x4
142    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
143    renamable $x6 = ADDI8 renamable killed $x5, 1
144    renamable $x4 = COPY renamable killed $x6
145    renamable $x7 = COPY renamable killed $x4
146    $x3 = COPY renamable killed $x7
147    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
148
149...
150
151---
152name: Enter
153alignment: 4
154tracksRegLiveness: true
155body: |
156  bb.0.entry:
157    liveins: $x4, $x7
158    ; CHECK-LABEL: name: Enter
159    ; CHECK: liveins: $x4, $x7
160    ; CHECK: renamable $x5 = COPY killed renamable $x7
161    ; CHECK: renamable $x7 = ADDI8 killed renamable $x4, 1
162    ; CHECK: $x3 = ADD8 killed renamable $x5, killed renamable $x7
163    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
164    renamable $x5 = COPY killed renamable $x7
165    renamable $x6 = ADDI8 killed renamable $x4, 1
166    renamable $x7 = COPY killed renamable $x6
167    $x3 = ADD8 renamable killed $x5, renamable killed $x7
168    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
169
170...
171
172---
173name: foo
174alignment: 4
175tracksRegLiveness: true
176body: |
177  bb.0.entry:
178    liveins: $x4, $x7
179    ; CHECK-LABEL: name: foo
180    ; CHECK: liveins: $x4, $x7
181    ; CHECK: renamable $x5 = COPY killed renamable $x7
182    ; CHECK: renamable $x7 = ADDI8 renamable $x4, 1
183    ; CHECK: renamable $x6 = ADDI8 killed $x4, 2
184    ; CHECK: $x3 = ADD8 killed renamable $x5, killed renamable $x6
185    ; CHECK: $x3 = ADD8 $x3, killed renamable $x7
186    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
187    renamable $x5 = COPY killed renamable $x7
188    renamable $x6 = ADDI8 renamable $x4, 1
189    renamable $x7 = COPY killed renamable $x6
190    renamable $x8 = ADDI8 killed $x4, 2
191    renamable $x6 = COPY killed renamable $x8
192    $x3 = ADD8 renamable killed $x5, renamable killed $x6
193    $x3 = ADD8 $x3, renamable killed $x7
194    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
195
196...
197
198---
199name: bar
200alignment: 4
201tracksRegLiveness: true
202body: |
203  bb.0.entry:
204    liveins: $x4, $x7
205    ; CHECK-LABEL: name: bar
206    ; CHECK: liveins: $x4, $x7
207    ; CHECK: renamable $x5 = COPY killed renamable $x7
208    ; CHECK: renamable $x7 = ADDI8 renamable $x4, 1
209    ; CHECK: renamable $x8 = COPY killed renamable $x7
210    ; CHECK: renamable $x7 = ADDI8 renamable $x5, 2
211    ; CHECK: $x3 = ADD8 killed renamable $x5, killed renamable $x7
212    ; CHECK: $x3 = ADD8 $x3, killed renamable $x8
213    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
214    renamable $x5 = COPY killed renamable $x7
215    renamable $x6 = ADDI8 renamable $x4, 1
216    renamable $x7 = COPY killed renamable $x6
217    renamable $x8 = COPY killed renamable $x7
218    renamable $x6 = ADDI8 renamable $x5, 2
219    renamable $x7 = COPY killed renamable $x6
220    $x3 = ADD8 renamable killed $x5, renamable killed $x7
221    $x3 = ADD8 $x3, renamable killed $x8
222    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
223
224...
225
226---
227name: bogus
228alignment: 4
229tracksRegLiveness: true
230body: |
231  bb.0.entry:
232    liveins: $x7
233    ; CHECK-LABEL: name: bogus
234    ; CHECK: liveins: $x7
235    ; CHECK: renamable $x5 = COPY renamable $x7
236    ; CHECK: renamable $x4 = ADDI8 $x7, 1
237    ; CHECK: renamable $x6 = ADDI8 renamable $x5, 2
238    ; CHECK: $x3 = ADD8 killed renamable $x4, killed renamable $x5
239    ; CHECK: $x3 = ADD8 $x3, killed renamable $x6
240    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
241    renamable $x5 = COPY killed renamable $x7
242    renamable $x6 = ADDI8 renamable $x5, 1
243    renamable $x4 = COPY killed renamable $x6
244    renamable $x7 = COPY killed renamable $x4
245    renamable $x6 = ADDI8 renamable $x5, 2
246    renamable $x4 = COPY killed renamable $x7
247    $x3 = ADD8 renamable killed $x4, renamable killed $x5
248    $x3 = ADD8 $x3, renamable killed $x6
249    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
250
251...
252
253---
254name: foobar
255alignment: 4
256tracksRegLiveness: true
257body: |
258  bb.0.entry:
259    liveins: $x7
260    ; CHECK-LABEL: name: foobar
261    ; CHECK: liveins: $x7
262    ; CHECK: renamable $x4 = ADDI8 $x7, 1
263    ; CHECK: renamable $x8 = COPY killed renamable $x4
264    ; CHECK: renamable $x4 = ADDI8 $x7, 2
265    ; CHECK: $x3 = ADD8 killed renamable $x4, $x7
266    ; CHECK: $x3 = ADD8 $x3, killed renamable $x8
267    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
268    renamable $x5 = COPY killed renamable $x7
269    renamable $x6 = ADDI8 renamable $x5, 1
270    renamable $x4 = COPY killed renamable $x6
271    renamable $x8 = COPY killed renamable $x4
272    renamable $x6 = ADDI8 renamable $x5, 2
273    renamable $x4 = COPY killed renamable $x6
274    $x3 = ADD8 renamable killed $x4, renamable killed $x5
275    $x3 = ADD8 $x3, renamable killed $x8
276    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
277
278...
279
280---
281name: cross_call
282alignment: 4
283tracksRegLiveness: true
284body: |
285  bb.0.entry:
286    liveins: $x2, $x3, $x20
287    ; CHECK-LABEL: name: cross_call
288    ; CHECK: liveins: $x2, $x3, $x20
289    ; CHECK: renamable $x20 = LI8 1024
290    ; CHECK: BL8_NOP @foo, csr_svr464_altivec, implicit-def $lr8, implicit $rm, implicit $x3, implicit-def $x3, implicit $x2
291    ; CHECK: $x3 = COPY killed renamable $x20
292    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
293    renamable $x20 = LI8 1024
294    BL8_NOP @foo, csr_svr464_altivec, implicit-def $lr8, implicit $rm, implicit $x3, implicit-def $x3, implicit $x2
295    $x3 = COPY renamable killed $x20
296    BLR8 implicit $lr8, implicit undef $rm, implicit $x3
297...
298