1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
9 tracksRegLiveness: true
14 ; This should not have an UBFMXri, since ADDWrr implicitly gives us the
17 ; CHECK-LABEL: name: fold
18 ; CHECK: liveins: $w0, $w1
20 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
21 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
22 ; CHECK-NEXT: [[ADDWrr:%[0-9]+]]:gpr32 = ADDWrr [[COPY1]], [[COPY]]
23 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, [[ADDWrr]], 0
24 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
25 ; CHECK-NEXT: $x0 = COPY [[SUBREG_TO_REG]]
26 ; CHECK-NEXT: RET_ReallyLR implicit $x0
27 %0:gpr(s32) = COPY $w0
28 %1:gpr(s32) = COPY $w1
29 %2:gpr(s32) = G_ADD %1, %0
30 %3:gpr(s64) = G_ZEXT %2(s32)
32 RET_ReallyLR implicit $x0
39 tracksRegLiveness: true
44 ; We should have a UBFMXri here, because we only do this for zero extends
45 ; from 32 bits to 64 bits.
47 ; CHECK-LABEL: name: dont_fold_s16
48 ; CHECK: liveins: $w0, $w1
50 ; CHECK-NEXT: [[DEF:%[0-9]+]]:gpr32 = IMPLICIT_DEF
51 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[DEF]], %subreg.sub_32
52 ; CHECK-NEXT: [[UBFMXri:%[0-9]+]]:gpr64 = UBFMXri [[SUBREG_TO_REG]], 0, 15
53 ; CHECK-NEXT: $x0 = COPY [[UBFMXri]]
54 ; CHECK-NEXT: RET_ReallyLR implicit $x0
55 %0:gpr(s16) = G_IMPLICIT_DEF
56 %3:gpr(s64) = G_ZEXT %0(s16)
58 RET_ReallyLR implicit $x0
65 tracksRegLiveness: true
70 ; We should have a ORRWrs here, because isDef32 disallows copies.
72 ; CHECK-LABEL: name: dont_fold_copy
75 ; CHECK-NEXT: %copy:gpr32 = COPY $w0
76 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, %copy, 0
77 ; CHECK-NEXT: %zext:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
78 ; CHECK-NEXT: $x0 = COPY %zext
79 ; CHECK-NEXT: RET_ReallyLR implicit $x0
80 %copy:gpr(s32) = COPY $w0
81 %zext:gpr(s64) = G_ZEXT %copy(s32)
83 RET_ReallyLR implicit $x0
87 name: dont_fold_bitcast
90 tracksRegLiveness: true
95 ; We should have a ORRWrs here, because isDef32 disallows bitcasts.
97 ; CHECK-LABEL: name: dont_fold_bitcast
100 ; CHECK-NEXT: %copy:gpr32all = COPY $w0
101 ; CHECK-NEXT: %bitcast1:gpr32 = COPY %copy
102 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, %bitcast1, 0
103 ; CHECK-NEXT: %zext:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
104 ; CHECK-NEXT: $x0 = COPY %zext
105 ; CHECK-NEXT: RET_ReallyLR implicit $x0
106 %copy:gpr(s32) = COPY $w0
107 %bitcast0:gpr(<4 x s8>) = G_BITCAST %copy(s32)
108 %bitcast1:gpr(s32) = G_BITCAST %bitcast0
109 %zext:gpr(s64) = G_ZEXT %bitcast1(s32)
110 $x0 = COPY %zext(s64)
111 RET_ReallyLR implicit $x0
115 name: dont_fold_trunc
117 regBankSelected: true
118 tracksRegLiveness: true
123 ; We should have a ORRWrs here, because isDef32 disallows truncs.
125 ; CHECK-LABEL: name: dont_fold_trunc
126 ; CHECK: liveins: $x0
128 ; CHECK-NEXT: %copy:gpr64sp = COPY $x0
129 ; CHECK-NEXT: %trunc:gpr32common = COPY %copy.sub_32
130 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, %trunc, 0
131 ; CHECK-NEXT: %zext:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
132 ; CHECK-NEXT: $x0 = COPY %zext
133 ; CHECK-NEXT: RET_ReallyLR implicit $x0
134 %copy:gpr(s64) = COPY $x0
135 %trunc:gpr(s32) = G_TRUNC %copy(s64)
136 %zext:gpr(s64) = G_ZEXT %trunc(s32)
137 $x0 = COPY %zext(s64)
138 RET_ReallyLR implicit $x0
144 regBankSelected: true
145 tracksRegLiveness: true
147 ; CHECK-LABEL: name: dont_fold_phi
149 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
150 ; CHECK-NEXT: liveins: $w0, $w1, $w2
152 ; CHECK-NEXT: %copy1:gpr32all = COPY $w0
153 ; CHECK-NEXT: %copy2:gpr32all = COPY $w1
154 ; CHECK-NEXT: %cond_wide:gpr32 = COPY $w2
155 ; CHECK-NEXT: TBNZW %cond_wide, 0, %bb.1
156 ; CHECK-NEXT: B %bb.2
159 ; CHECK-NEXT: successors: %bb.2(0x80000000)
163 ; CHECK-NEXT: %phi:gpr32 = PHI %copy1, %bb.0, %copy2, %bb.1
164 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, %phi, 0
165 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
166 ; CHECK-NEXT: $x0 = COPY [[SUBREG_TO_REG]]
167 ; CHECK-NEXT: RET_ReallyLR implicit $x0
168 ; We should have a ORRWrs here, because isDef32 disallows phis.
171 liveins: $w0, $w1, $w2
173 %copy1:gpr(s32) = COPY $w0
174 %copy2:gpr(s32) = COPY $w1
175 %cond_wide:gpr(s32) = COPY $w2
176 G_BRCOND %cond_wide, %bb.1
182 %phi:gpr(s32) = G_PHI %copy1(s32), %bb.0, %copy2(s32), %bb.1
183 %5:gpr(s64) = G_ZEXT %phi(s32)
185 RET_ReallyLR implicit $x0
189 name: dont_look_through_copy
191 regBankSelected: true
192 tracksRegLiveness: true
197 ; Make sure we don't walk past the copy.
199 ; CHECK-LABEL: name: dont_look_through_copy
200 ; CHECK: liveins: $w0, $w1
202 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
203 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
204 ; CHECK-NEXT: [[ADDWrr:%[0-9]+]]:gpr32 = ADDWrr [[COPY1]], [[COPY]]
205 ; CHECK-NEXT: [[ORRWrs:%[0-9]+]]:gpr32 = ORRWrs $wzr, [[ADDWrr]], 0
206 ; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, [[ORRWrs]], %subreg.sub_32
207 ; CHECK-NEXT: $x0 = COPY [[SUBREG_TO_REG]]
208 ; CHECK-NEXT: RET_ReallyLR implicit $x0
209 %0:gpr(s32) = COPY $w0
210 %1:gpr(s32) = COPY $w1
211 %2:gpr(s32) = G_ADD %1, %0
212 %3:gpr(s32) = COPY %2(s32)
213 %4:gpr(s64) = G_ZEXT %3(s32)
215 RET_ReallyLR implicit $x0