1 # RUN: llc -mtriple=aarch64--linux-gnu -run-pass=aarch64-copyelim %s -verify-machineinstrs -o - | FileCheck %s
3 # CHECK-LABEL: name: test1
4 # CHECK: ANDSWri $w0, 1, implicit-def $nzcv
8 tracksRegLiveness: true
11 liveins: $w0, $x1, $x2
13 $w0 = ANDSWri $w0, 1, implicit-def $nzcv
14 STRWui killed $w0, killed $x1, 0
15 Bcc 1, %bb.2, implicit killed $nzcv
22 STRWui killed $w0, killed $x2, 0
27 # CHECK-LABEL: name: test2
28 # CHECK: ANDSXri $x0, 1, implicit-def $nzcv
30 # CHECK-NOT: COPY $xzr
32 tracksRegLiveness: true
35 liveins: $x0, $x1, $x2
37 $x0 = ANDSXri $x0, 1, implicit-def $nzcv
38 STRXui killed $x0, killed $x1, 0
39 Bcc 1, %bb.2, implicit killed $nzcv
46 STRXui killed $x0, killed $x2, 0
51 # CHECK-LABEL: name: test3
52 # CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
54 # CHECK-NOT: COPY $wzr
56 tracksRegLiveness: true
59 liveins: $w0, $x1, $x2
61 $w0 = ADDSWri $w0, 1, 0, implicit-def $nzcv
62 STRWui killed $w0, killed $x1, 0
63 Bcc 1, %bb.2, implicit killed $nzcv
70 STRWui killed $w0, killed $x2, 0
75 # CHECK-LABEL: name: test4
76 # CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
78 # CHECK-NOT: COPY $xzr
80 tracksRegLiveness: true
83 liveins: $x0, $x1, $x2
85 $x0 = ADDSXri $x0, 1, 0, implicit-def $nzcv
86 STRXui killed $x0, killed $x1, 0
87 Bcc 1, %bb.2, implicit killed $nzcv
94 STRXui killed $x0, killed $x2, 0
99 # CHECK-LABEL: name: test5
100 # CHECK: SUBSWri $w0, 1, 0, implicit-def $nzcv
102 # CHECK-NOT: COPY $wzr
104 tracksRegLiveness: true
107 liveins: $w0, $x1, $x2
109 $w0 = SUBSWri $w0, 1, 0, implicit-def $nzcv
110 STRWui killed $w0, killed $x1, 0
111 Bcc 1, %bb.2, implicit killed $nzcv
118 STRWui killed $w0, killed $x2, 0
123 # CHECK-LABEL: name: test6
124 # CHECK: SUBSXri $x0, 1, 0, implicit-def $nzcv
126 # CHECK-NOT: COPY $xzr
128 tracksRegLiveness: true
131 liveins: $x0, $x1, $x2
133 $x0 = SUBSXri $x0, 1, 0, implicit-def $nzcv
134 STRXui killed $x0, killed $x1, 0
135 Bcc 1, %bb.2, implicit killed $nzcv
142 STRXui killed $x0, killed $x2, 0
147 # CHECK-LABEL: name: test7
148 # CHECK: ADDSWrr $w0, $w1, implicit-def $nzcv
150 # CHECK-NOT: COPY $wzr
152 tracksRegLiveness: true
155 liveins: $w0, $w1, $x2, $x3
157 $w0 = ADDSWrr $w0, $w1, implicit-def $nzcv
158 STRWui killed $w0, killed $x2, 0
159 Bcc 1, %bb.2, implicit killed $nzcv
166 STRWui killed $w0, killed $x3, 0
171 # CHECK-LABEL: name: test8
172 # CHECK: ADDSXrr $x0, $x1, implicit-def $nzcv
174 # CHECK-NOT: COPY $xzr
176 tracksRegLiveness: true
179 liveins: $x0, $x1, $x2, $x3
181 $x0 = ADDSXrr $x0, $x1, implicit-def $nzcv
182 STRXui killed $x0, killed $x2, 0
183 Bcc 1, %bb.2, implicit killed $nzcv
190 STRXui killed $x0, killed $x3, 0
195 # CHECK-LABEL: name: test9
196 # CHECK: ANDSWrr $w0, $w1, implicit-def $nzcv
198 # CHECK-NOT: COPY $wzr
200 tracksRegLiveness: true
203 liveins: $w0, $w1, $x2, $x3
205 $w0 = ANDSWrr $w0, $w1, implicit-def $nzcv
206 STRWui killed $w0, killed $x2, 0
207 Bcc 1, %bb.2, implicit killed $nzcv
214 STRWui killed $w0, killed $x3, 0
219 # CHECK-LABEL: name: test10
220 # CHECK: ANDSXrr $x0, $x1, implicit-def $nzcv
222 # CHECK-NOT: COPY $xzr
224 tracksRegLiveness: true
227 liveins: $x0, $x1, $x2, $x3
229 $x0 = ANDSXrr $x0, $x1, implicit-def $nzcv
230 STRXui killed $x0, killed $x2, 0
231 Bcc 1, %bb.2, implicit killed $nzcv
238 STRXui killed $x0, killed $x3, 0
243 # CHECK-LABEL: name: test11
244 # CHECK: BICSWrr $w0, $w1, implicit-def $nzcv
246 # CHECK-NOT: COPY $wzr
248 tracksRegLiveness: true
251 liveins: $w0, $w1, $x2, $x3
253 $w0 = BICSWrr $w0, $w1, implicit-def $nzcv
254 STRWui killed $w0, killed $x2, 0
255 Bcc 1, %bb.2, implicit killed $nzcv
262 STRWui killed $w0, killed $x3, 0
267 # CHECK-LABEL: name: test12
268 # CHECK: BICSXrr $x0, $x1, implicit-def $nzcv
270 # CHECK-NOT: COPY $xzr
272 tracksRegLiveness: true
275 liveins: $x0, $x1, $x2, $x3
277 $x0 = BICSXrr $x0, $x1, implicit-def $nzcv
278 STRXui killed $x0, killed $x2, 0
279 Bcc 1, %bb.2, implicit killed $nzcv
286 STRXui killed $x0, killed $x3, 0
291 # CHECK-LABEL: name: test13
292 # CHECK: SUBSWrr $w0, $w1, implicit-def $nzcv
294 # CHECK-NOT: COPY $wzr
296 tracksRegLiveness: true
299 liveins: $w0, $w1, $x2, $x3
301 $w0 = SUBSWrr $w0, $w1, implicit-def $nzcv
302 STRWui killed $w0, killed $x2, 0
303 Bcc 1, %bb.2, implicit killed $nzcv
310 STRWui killed $w0, killed $x3, 0
315 # CHECK-LABEL: name: test14
316 # CHECK: SUBSXrr $x0, $x1, implicit-def $nzcv
318 # CHECK-NOT: COPY $xzr
320 tracksRegLiveness: true
323 liveins: $x0, $x1, $x2, $x3
325 $x0 = SUBSXrr $x0, $x1, implicit-def $nzcv
326 STRXui killed $x0, killed $x2, 0
327 Bcc 1, %bb.2, implicit killed $nzcv
334 STRXui killed $x0, killed $x3, 0
339 # CHECK-LABEL: name: test15
340 # CHECK: ADDSWrs $w0, $w1, 0, implicit-def $nzcv
342 # CHECK-NOT: COPY $wzr
344 tracksRegLiveness: true
347 liveins: $w0, $w1, $x2, $x3
349 $w0 = ADDSWrs $w0, $w1, 0, implicit-def $nzcv
350 STRWui killed $w0, killed $x2, 0
351 Bcc 1, %bb.2, implicit killed $nzcv
358 STRWui killed $w0, killed $x3, 0
363 # CHECK-LABEL: name: test16
364 # CHECK: ADDSXrs $x0, $x1, 0, implicit-def $nzcv
366 # CHECK-NOT: COPY $xzr
368 tracksRegLiveness: true
371 liveins: $x0, $x1, $x2, $x3
373 $x0 = ADDSXrs $x0, $x1, 0, implicit-def $nzcv
374 STRXui killed $x0, killed $x2, 0
375 Bcc 1, %bb.2, implicit killed $nzcv
382 STRXui killed $x0, killed $x3, 0
387 # CHECK-LABEL: name: test17
388 # CHECK: ANDSWrs $w0, $w1, 0, implicit-def $nzcv
390 # CHECK-NOT: COPY $wzr
392 tracksRegLiveness: true
395 liveins: $w0, $w1, $x2, $x3
397 $w0 = ANDSWrs $w0, $w1, 0, implicit-def $nzcv
398 STRWui killed $w0, killed $x2, 0
399 Bcc 1, %bb.2, implicit killed $nzcv
406 STRWui killed $w0, killed $x3, 0
411 # CHECK-LABEL: name: test18
412 # CHECK: ANDSXrs $x0, $x1, 0, implicit-def $nzcv
414 # CHECK-NOT: COPY $xzr
416 tracksRegLiveness: true
419 liveins: $x0, $x1, $x2, $x3
421 $x0 = ANDSXrs $x0, $x1, 0, implicit-def $nzcv
422 STRXui killed $x0, killed $x2, 0
423 Bcc 1, %bb.2, implicit killed $nzcv
430 STRXui killed $x0, killed $x3, 0
435 # CHECK-LABEL: name: test19
436 # CHECK: BICSWrs $w0, $w1, 0, implicit-def $nzcv
438 # CHECK-NOT: COPY $wzr
440 tracksRegLiveness: true
443 liveins: $w0, $w1, $x2, $x3
445 $w0 = BICSWrs $w0, $w1, 0, implicit-def $nzcv
446 STRWui killed $w0, killed $x2, 0
447 Bcc 1, %bb.2, implicit killed $nzcv
454 STRWui killed $w0, killed $x3, 0
459 # Unicorn test - we can remove a redundant copy and a redundant mov
460 # CHECK-LABEL: name: test20
461 # CHECK: SUBSWri $w1, 1, 0, implicit-def $nzcv
463 # CHECK-NOT: $w0 = COPY $wzr
464 # CHECK-NOT: $w1 = MOVi32imm 1
466 tracksRegLiveness: true
471 $w0 = SUBSWri $w1, 1, 0, implicit-def $nzcv
472 Bcc 1, %bb.2, implicit killed $nzcv
480 STRWui killed $w0, $x2, 0
481 STRWui killed $w1, killed $x2, 1
487 # Negative test - MOVi32imm clobbers $w0
488 # CHECK-LABEL: name: test21
489 # CHECK: ANDSWri $w0, 1, implicit-def $nzcv
491 # CHECK: $w0 = COPY $wzr
493 tracksRegLiveness: true
496 liveins: $w0, $x1, $x2
498 $w0 = ANDSWri $w0, 1, implicit-def $nzcv
499 STRWui killed $w0, $x1, 0
501 STRWui killed $w0, killed $x1, 1
502 Bcc 1, %bb.2, implicit killed $nzcv
509 STRWui killed $w0, killed $x2, 0
514 # Negative test - SUBSXri self-clobbers x0, so MOVi64imm can't be removed
515 # CHECK-LABEL: name: test22
516 # CHECK: SUBSXri $x0, 1, 0, implicit-def $nzcv
518 # CHECK: $x0 = MOVi64imm 1
520 tracksRegLiveness: true
523 liveins: $x0, $x1, $x2
525 $x0 = SUBSXri $x0, 1, 0, implicit-def $nzcv
526 STRXui killed $x0, killed $x1, 0
527 Bcc 1, %bb.2, implicit killed $nzcv
534 STRXui killed $x0, killed $x2, 0
539 # Negative test - bb.1 has multiple preds
540 # CHECK-LABEL: name: test23
541 # CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
545 tracksRegLiveness: true
548 liveins: $w0, $x1, $x2
550 $w0 = ADDSWri $w0, 1, 0, implicit-def $nzcv
551 STRWui killed $w0, killed $x1, 0
552 Bcc 1, %bb.2, implicit killed $nzcv
562 STRWui killed $w0, killed $x2, 0