1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple aarch64 -run-pass=aarch64-post-select-optimize -verify-machineinstrs %s -o - | FileCheck %s 3--- | 4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" 5 6 @x = external hidden local_unnamed_addr global ptr, align 8 7 define void @copy_from_larger_rc_def() { ret void } 8 define void @copy_from_larger_rc_def_multi_use() { ret void } 9 define void @copy_from_smaller_rc_def() { ret void } 10 11... 12--- 13name: copy_from_larger_rc_def 14alignment: 4 15legalized: true 16regBankSelected: true 17selected: true 18tracksRegLiveness: true 19liveins: 20 - { reg: '$x0' } 21 - { reg: '$w1' } 22 - { reg: '$x2' } 23body: | 24 bb.1: 25 liveins: $w1, $x0, $x2 26 27 ; Show that if we're doing a copy from a large rc to a single user with a smaller rc 28 ; then we just constrain the def instead. 29 ; CHECK-LABEL: name: copy_from_larger_rc_def 30 ; CHECK: liveins: $w1, $x0, $x2 31 ; CHECK-NEXT: {{ $}} 32 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 33 ; CHECK-NEXT: %large_rc_def:gpr64common = UBFMXri [[COPY]], 61, 60 34 ; CHECK-NEXT: %add:gpr64sp = ADDXri %large_rc_def, 3, 0 35 ; CHECK-NEXT: $x0 = COPY %add 36 ; CHECK-NEXT: RET_ReallyLR 37 %0:gpr64 = COPY $x0 38 %large_rc_def:gpr64 = UBFMXri %0, 61, 60 39 %constrain_copy:gpr64common = COPY %large_rc_def 40 ; Even though ADDXri may not actually need to use gpr64common, just use it as an example. 41 %add:gpr64sp = ADDXri %constrain_copy, 3, 0 42 $x0 = COPY %add 43 RET_ReallyLR 44 45... 46--- 47name: copy_from_larger_rc_def_multi_use 48alignment: 4 49legalized: true 50regBankSelected: true 51selected: true 52tracksRegLiveness: true 53liveins: 54 - { reg: '$x0' } 55 - { reg: '$w1' } 56 - { reg: '$x2' } 57body: | 58 bb.1: 59 liveins: $w1, $x0, $x2 60 61 ; Don't constrain def if the original def has multiple users. 62 ; CHECK-LABEL: name: copy_from_larger_rc_def_multi_use 63 ; CHECK: liveins: $w1, $x0, $x2 64 ; CHECK-NEXT: {{ $}} 65 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0 66 ; CHECK-NEXT: %large_rc_def:gpr64 = UBFMXri [[COPY]], 61, 60 67 ; CHECK-NEXT: %constrain_copy:gpr64common = COPY %large_rc_def 68 ; CHECK-NEXT: %add:gpr64sp = ADDXri %constrain_copy, 3, 0 69 ; CHECK-NEXT: %add2:gpr64sp = ADDXri %constrain_copy, 3, 0 70 ; CHECK-NEXT: $x0 = COPY %add 71 ; CHECK-NEXT: $x1 = COPY %large_rc_def 72 ; CHECK-NEXT: RET_ReallyLR 73 %0:gpr64 = COPY $x0 74 %large_rc_def:gpr64 = UBFMXri %0, 61, 60 75 %constrain_copy:gpr64common = COPY %large_rc_def 76 %add:gpr64sp = ADDXri %constrain_copy, 3, 0 77 %add2:gpr64sp = ADDXri %constrain_copy, 3, 0 78 $x0 = COPY %add 79 $x1 = COPY %large_rc_def 80 RET_ReallyLR 81 82... 83--- 84name: copy_from_smaller_rc_def 85alignment: 4 86legalized: true 87regBankSelected: true 88selected: true 89tracksRegLiveness: true 90liveins: 91 - { reg: '$x0' } 92 - { reg: '$w1' } 93 - { reg: '$x2' } 94body: | 95 bb.1: 96 liveins: $w1, $x0, $x2 97 98 ; Show that if we're doing a copy from a small rc to a single user with a larger rc 99 ; then we just use the smaller def instead of doing a copy. 100 ; CHECK-LABEL: name: copy_from_smaller_rc_def 101 ; CHECK: liveins: $w1, $x0, $x2 102 ; CHECK-NEXT: {{ $}} 103 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64common = COPY $x0 104 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64common = COPY $x1 105 ; CHECK-NEXT: %add:gpr64common = ADDXri [[COPY1]], 3, 0 106 ; CHECK-NEXT: STRXui [[COPY1]], %add, target-flags(aarch64-pageoff, aarch64-nc) @x :: (store (p0)) 107 ; CHECK-NEXT: RET_ReallyLR 108 %0:gpr64common = COPY $x0 109 %1:gpr64common = COPY $x1 110 111 %add:gpr64common = ADDXri %1, 3, 0 112 %copy:gpr64sp = COPY %add 113 STRXui %1, %copy, target-flags(aarch64-pageoff, aarch64-nc) @x :: (store (p0)) 114 RET_ReallyLR 115 116... 117