1 # RUN: llc -mtriple=aarch64--linux-gnu -run-pass=aarch64-copyelim %s -verify-machineinstrs -o - | FileCheck %s
3 # Check that bb.0 COPY is seen through to allow the bb.1 COPY of XZR to be removed.
4 # CHECK-LABEL: name: test1
7 tracksRegLiveness: true
27 RET_ReallyLR implicit $x0
30 # Similar to test1, but with reversed COPY.
31 # CHECK-LABEL: name: test2
32 # CHECK-NOT: COPY $xzr
34 tracksRegLiveness: true
54 RET_ReallyLR implicit $x0
57 # Similar to test1, but with a clobber that prevents removal of the XZR COPY.
58 # CHECK-LABEL: name: test3
61 tracksRegLiveness: true
64 liveins: $x0, $x1, $x2
82 RET_ReallyLR implicit $x0
85 # Similar to test2, but with a clobber that prevents removal of the XZR COPY.
86 # CHECK-LABEL: name: test4
89 tracksRegLiveness: true
92 liveins: $x0, $x1, $x2
110 RET_ReallyLR implicit $x0
113 # Similar to test2, but with a clobber that prevents removal of the XZR COPY.
114 # CHECK-LABEL: name: test5
117 tracksRegLiveness: true
120 liveins: $x0, $x1, $x2
138 RET_ReallyLR implicit $x0
141 # Similar to test1, but with two levels of COPYs.
142 # CHECK-LABEL: name: test6
143 # CHECK-NOT: COPY $xzr
145 tracksRegLiveness: true
148 liveins: $x0, $x1, $x2
166 RET_ReallyLR implicit $x0
169 # Similar to test1, but with two levels of COPYs and a clobber preventing COPY of XZR removal.
170 # CHECK-LABEL: name: test7
173 tracksRegLiveness: true
176 liveins: $x0, $x1, $x2
195 RET_ReallyLR implicit $x0
198 # Check that the TargetRegs vector clobber update loop in
199 # AArch64RedundantCopyElimination::optimizeCopy works correctly.
200 # CHECK-LABEL: name: test8
201 # CHECK: x0 = COPY $xzr
202 # CHECK: x1 = COPY $xzr
204 tracksRegLiveness: true
215 $x0, $x1 = LDPXi $x2, 0
228 RET_ReallyLR implicit $x0
231 # Check that copy isn't removed from a block with multiple predecessors.
232 # CHECK-LABEL: name: test9
233 # CHECK: x0 = COPY $xzr
234 # CHECK-NEXT: B %bb.3
236 tracksRegLiveness: true
259 RET_ReallyLR implicit $x0
262 # Eliminate redundant MOVi32imm 7 in bb.1
263 # Note: 32-bit compare/32-bit move imm
264 # Kill marker should be removed from compare.
265 # CHECK-LABEL: name: test10
266 # CHECK: SUBSWri $w0, 7, 0, implicit-def $nzcv
268 # CHECK-NOT: MOVi32imm
270 tracksRegLiveness: true
275 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
276 Bcc 1, %bb.2, implicit killed $nzcv
283 STRWui killed $w0, killed $x1, 0
288 # Eliminate redundant MOVi32imm 7 in bb.1
289 # Note: 64-bit compare/32-bit move imm w/implicit def
290 # Kill marker should be removed from compare.
291 # CHECK-LABEL: name: test11
292 # CHECK: SUBSXri $x0, 7, 0, implicit-def $nzcv
294 # CHECK-NOT: MOVi32imm
296 tracksRegLiveness: true
301 dead $xzr = SUBSXri killed $x0, 7, 0, implicit-def $nzcv
302 Bcc 1, %bb.2, implicit killed $nzcv
308 $w0 = MOVi32imm 7, implicit-def $x0
309 STRXui killed $x0, killed $x1, 0
314 # Eliminate redundant MOVi32imm 7 in bb.1
315 # Note: 64-bit compare/32-bit move imm
316 # Kill marker should be removed from compare.
317 # CHECK-LABEL: name: test12
318 # CHECK: SUBSXri $x0, 7, 0, implicit-def $nzcv
320 # CHECK-NOT: MOVi32imm
322 tracksRegLiveness: true
327 dead $xzr = SUBSXri killed $x0, 7, 0, implicit-def $nzcv
328 Bcc 1, %bb.2, implicit killed $nzcv
335 STRWui killed $w0, killed $x1, 0
340 # Don't eliminate MOVi32imm 7 in bb.1 as we don't necessarily know the upper 32-bits.
341 # Note: 32-bit compare/32-bit move imm w/implicit def
342 # Kill marker should remain on compare.
343 # CHECK-LABEL: name: test13
344 # CHECK: SUBSWri killed $w0, 7, 0, implicit-def $nzcv
348 tracksRegLiveness: true
353 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
354 Bcc 1, %bb.2, implicit killed $nzcv
360 $w0 = MOVi32imm 7, implicit-def $x0
361 STRXui killed $x0, killed $x1, 0
366 # We can't eliminate the MOVi32imm because of the clobbering LDRWui.
367 # CHECK-LABEL: name: test14
371 tracksRegLiveness: true
374 liveins: $w0, $x1, $x2
376 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
378 STRWui killed $w0, killed $x2, 0
379 Bcc 1, %bb.2, implicit killed $nzcv
386 STRWui killed $w0, killed $x1, 0
391 # We can't eliminate the MOVi32imm because of the clobbering LDRWui.
392 # CHECK-LABEL: name: test15
396 tracksRegLiveness: true
399 liveins: $w0, $x1, $x2
401 dead $wzr = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
402 Bcc 1, %bb.2, implicit killed $nzcv
409 STRWui killed $w0, killed $x2, 0
411 STRWui killed $w0, killed $x1, 0
416 # Check that bb.0 COPY is seen through to allow the bb.1 MOVi32imm to be removed.
417 # CHECK-LABEL: name: test16
419 # CHECK-NOT: MOVi32imm
421 tracksRegLiveness: true
426 dead $wzr = SUBSWri $w0, 7, 0, implicit-def $nzcv
428 Bcc 1, %bb.2, implicit killed $nzcv
435 STRWui killed $w2, killed $x1, 0
440 # Check that bb.1 MOVi32imm is not removed due to self clobbering compare.
441 # CHECK-LABEL: name: test17
445 tracksRegLiveness: true
450 dead $w0 = SUBSWri killed $w0, 7, 0, implicit-def $nzcv
451 Bcc 1, %bb.2, implicit killed $nzcv
458 STRWui killed $w0, killed $x1, 0
463 # Make sure the MOVi64imm is not removed. In one version of this patch the
464 # MOVi64imm immediate was truncated to 32 bits and incorrectly matched because
465 # the low 32 bits of 4252017623040 are all zero.
466 # CHECK-LABEL: name: test18
470 tracksRegLiveness: true
475 CBNZX killed $x0, %bb.2
481 $x0 = MOVi64imm 4252017623040
482 STRXui killed $x0, killed $x1, 0
487 # Eliminate redundant MOVi32imm -1 in bb.1
488 # Note: 32-bit compare/32-bit move imm
489 # Kill marker should be removed from compare.
490 # CHECK-LABEL: name: test19
491 # CHECK: ADDSWri $w0, 1, 0, implicit-def $nzcv
493 # CHECK-NOT: MOVi32imm
495 tracksRegLiveness: true
500 dead $wzr = ADDSWri killed $w0, 1, 0, implicit-def $nzcv
501 Bcc 1, %bb.2, implicit killed $nzcv
508 STRWui killed $w0, killed $x1, 0
513 # Eliminate redundant MOVi64imm -1 in bb.1
514 # Note: 64-bit compare/64-bit move imm
515 # Kill marker should be removed from compare.
516 # CHECK-LABEL: name: test20
517 # CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
519 # CHECK-NOT: MOVi64imm
521 tracksRegLiveness: true
526 dead $xzr = ADDSXri killed $x0, 1, 0, implicit-def $nzcv
527 Bcc 1, %bb.2, implicit killed $nzcv
534 STRXui killed $x0, killed $x1, 0
539 # Eliminate redundant MOVi32imm -1 in bb.1
540 # Note: 64-bit compare/32-bit move imm
541 # Kill marker should be removed from compare.
542 # CHECK-LABEL: name: test21
543 # CHECK: ADDSXri $x0, 1, 0, implicit-def $nzcv
545 # CHECK-NOT: MOVi32imm
547 tracksRegLiveness: true
552 dead $xzr = ADDSXri killed $x0, 1, 0, implicit-def $nzcv
553 Bcc 1, %bb.2, implicit killed $nzcv
560 STRWui killed $w0, killed $x1, 0
565 # Don't eliminate MOVi64imm -1 in bb.1 as we don't necessarily know the upper 32-bits.
566 # Note: 32-bit compare/64-bit move imm
567 # CHECK-LABEL: name: test22
571 tracksRegLiveness: true
576 dead $wzr = ADDSWri killed $w0, 1, 0, implicit-def $nzcv
577 Bcc 1, %bb.2, implicit killed $nzcv
584 STRXui killed $x0, killed $x1, 0
589 # Eliminate redundant MOVi32imm 4096 in bb.1 when the compare has a shifted immediate.
590 # CHECK-LABEL: name: test23
592 # CHECK-NOT: MOVi32imm
594 tracksRegLiveness: true
599 dead $wzr = SUBSWri killed $w0, 1, 12, implicit-def $nzcv
600 Bcc 1, %bb.2, implicit killed $nzcv
607 STRWui killed $w0, killed $x1, 0