1 # RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass=postra-machine-sink -verify-machineinstrs -o - %s | FileCheck %s
5 # CHECK-LABEL: name: sinkcopy1
7 # CHECK-NOT: $w19 = COPY killed $w0
9 # CHECK: liveins: $w0, $w1
10 # CHECK: renamable $w19 = COPY killed $w0
13 tracksRegLiveness: true
17 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
18 renamable $w19 = COPY killed $w0
19 Bcc 11, %bb.1, implicit $nzcv
24 $w0 = ADDWrr $w1, $w19
34 # CHECK-LABEL: name: sinkcopy2
36 # CHECK-NOT: renamable $w19 = COPY killed $w0
38 # CHECK: liveins: $w0, $w1
39 # CHECK: renamable $w19 = COPY killed $w0
41 tracksRegLiveness: true
45 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
46 renamable $w19 = COPY killed $w0
47 Bcc 11, %bb.2, implicit $nzcv
56 $w0 = ADDWrr $w1, $w19
61 # Sink w19 and w20 to %bb.1.
62 # CHECK-LABEL: name: sinkcopy3
64 # CHECK-NOT: renamable $w19 = COPY killed $w0
66 # CHECK: liveins: $w0, $w1
67 # CHECK: renamable $w19 = COPY killed $w0
68 # CHECK: renamable $w20 = COPY killed $w1
70 tracksRegLiveness: true
74 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
75 renamable $w19 = COPY killed $w0
76 renamable $w20 = COPY killed $w1
86 # Sink w19 to %bb.1 and w20 to %bb.2.
87 # CHECK-LABEL: name: sinkcopy4
89 # CHECK-NOT: renamable $w19 = COPY $w0
90 # CHECK-NOT: renamable $w20 = COPY $w1
92 # CHECK: liveins: $w0, $w1
93 # CHECK: renamable $w19 = COPY $w0
95 # CHECK: liveins: $w0, $w1
96 # CHECK: renamable $w20 = COPY $w1
98 tracksRegLiveness: true
102 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
103 renamable $w19 = COPY $w0
104 renamable $w20 = COPY $w1
105 Bcc 11, %bb.2, implicit $nzcv
110 $w0 = ADDWrr $w1, $w19
115 $w0 = ADDWrr $w0, $w20
119 # Sink w19 to %bb.3 through %bb.2.
120 # CHECK-LABEL: name: sinkcopy5
122 # CHECK-NOT: renamable $w19 = COPY $w0
124 # CHECK: $w1 = ADDWrr $w1, $w0
126 # CHECK: liveins: $w0, $w1
127 # CHECK: renamable $w19 = COPY killed $w0
129 tracksRegLiveness: true
133 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
134 renamable $w19 = COPY $w0
135 Bcc 11, %bb.2, implicit $nzcv
143 liveins: $w0, $w1, $w19
144 $w1 = ADDWrr $w1, killed $w0
148 $w0 = ADDWrr $w1, $w19
152 # Sink w19 to %bb.3, but through %bb.2.
153 # CHECK-LABEL: name: sinkcopy6
155 # CHECK-NOT: renamable $w19 = COPY $w0
156 # CHECK-NOT: renamable $w20 = COPY $w0
158 # CHECK: liveins: $w0, $w1
159 # CHECK: renamable $w19 = COPY $w0
160 # CHECK: renamable $w20 = COPY $w19
162 tracksRegLiveness: true
166 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
167 renamable $w19 = COPY $w0
168 renamable $w20 = COPY $w19
169 Bcc 11, %bb.2, implicit $nzcv
177 $w0 = ADDWrr killed $w1, $w20
182 # Sink w19 regardless of the def of wzr in bb.0.
183 # CHECK-LABEL: name: sinkcopy7
185 # CHECK-NOT: renamable $w19 = COPY $w0
187 # CHECK: renamable $w19 = COPY $wzr
189 tracksRegLiveness: true
193 renamable $w19 = COPY $wzr
194 $wzr = SUBSWri $w1, 1, 0, implicit-def $nzcv
195 Bcc 11, %bb.2, implicit $nzcv
204 $w0 = ADDWrr $w0, $w19
209 # Sink w19 to %bb.3 through %bb.2.
210 # CHECK-LABEL: name: sinkcopy8
212 # CHECK-NOT: renamable $w19 = COPY $w0, implicit-def $x19
214 # CHECK: $w1 = ADDWrr $w1, $w0, implicit $x0
216 # CHECK: liveins: $w0, $x1
217 # CHECK: renamable $w19 = COPY killed $w0, implicit-def $x19
219 tracksRegLiveness: true
223 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
224 renamable $w19 = COPY $w0, implicit-def $x19
225 Bcc 11, %bb.2, implicit $nzcv
233 liveins: $w0, $x1, $x19
234 $w1 = ADDWrr $w1, $w0, implicit killed $x0
238 $x0 = ADDXrr $x1, $x19
243 # Don't sink w19 as w0 is defined in bb.0.
244 # CHECK-LABEL: name: donotsinkcopy1
246 # CHECK: renamable $w19 = COPY $w0
247 # CHECK: $w0 = LDRWui $sp, 0
249 tracksRegLiveness: true
253 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
254 renamable $w19 = COPY $w0
255 $w0 = LDRWui $sp, 0 :: (load (s32))
256 Bcc 11, %bb.2, implicit $nzcv
265 $w0 = ADDWrr $w0, $w19
270 # Don't sink w19 as w19 is used in bb.0.
271 # CHECK-LABEL: name: donotsinkcopy2
273 # CHECK: renamable $w19 = COPY $w0
274 # CHECK: STRWui $w1, $x19, 0
276 tracksRegLiveness: true
280 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
281 renamable $w19 = COPY $w0
282 STRWui $w1, $x19, 0 :: (store (s32))
283 Bcc 11, %bb.2, implicit $nzcv
292 $w0 = ADDWrr $w0, $w19
297 # Don't sink w19 as w19 is used in both %bb.1 and %bb.2.
298 # CHECK-LABEL: name: donotsinkcopy3
300 # CHECK: renamable $w19 = COPY $w0
302 tracksRegLiveness: true
306 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
307 renamable $w19 = COPY $w0
308 Bcc 11, %bb.2, implicit $nzcv
318 $w0 = ADDWrr $w0, $w19
323 # Don't sink w19 as %bb.2 has multiple predecessors.
324 # CHECK-LABEL: name: donotsinkcopy4
326 # CHECK: renamable $w19 = COPY $w0
328 tracksRegLiveness: true
332 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
333 renamable $w19 = COPY $w0
334 Bcc 11, %bb.2, implicit $nzcv
344 $w0 = ADDWrr $w0, $w19
349 # Don't sink w19 after sinking w20.
350 # CHECK-LABEL: name: donotsinkcopy5
352 # CHECK: renamable $w19 = COPY $w0
354 # CHECK: liveins: $w0, $w19
355 # CHECK: renamable $w20 = COPY $w19
357 tracksRegLiveness: true
361 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
362 renamable $w19 = COPY $w0
363 renamable $w20 = COPY $w19
364 Bcc 11, %bb.2, implicit $nzcv
373 $w0 = ADDWrr killed $w0, $w20
378 # Don't sink w19 as x19 is live-in in %bb.2.
379 # CHECK-LABEL: name: donotsinkcopy6
382 tracksRegLiveness: true
386 $w1 = SUBSWri $w1, 1, 0, implicit-def $nzcv
387 renamable $x19 = COPY $x0
388 Bcc 11, %bb.2, implicit $nzcv
398 $x0 = ADDXrr $x0, $x19