1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=arm64-unknown-unknown -global-isel -run-pass=legalizer -global-isel-abort=1 %s -o - | FileCheck %s
6 tracksRegLiveness: true
11 ; CHECK-LABEL: name: test_v8s8
14 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<8 x s8>) = COPY $d0
15 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<8 x s8>) = G_CTLZ [[COPY]](<8 x s8>)
16 ; CHECK-NEXT: $d0 = COPY [[CTLZ]](<8 x s8>)
17 ; CHECK-NEXT: RET_ReallyLR implicit $d0
18 %0:_(<8 x s8>) = COPY $d0
19 %1:_(<8 x s8>) = G_CTLZ %0(<8 x s8>)
20 $d0 = COPY %1(<8 x s8>)
21 RET_ReallyLR implicit $d0
27 tracksRegLiveness: true
32 ; CHECK-LABEL: name: test_v4s16
35 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s16>) = COPY $d0
36 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<4 x s16>) = G_CTLZ [[COPY]](<4 x s16>)
37 ; CHECK-NEXT: $d0 = COPY [[CTLZ]](<4 x s16>)
38 ; CHECK-NEXT: RET_ReallyLR implicit $d0
39 %0:_(<4 x s16>) = COPY $d0
40 %1:_(<4 x s16>) = G_CTLZ %0(<4 x s16>)
41 $d0 = COPY %1(<4 x s16>)
42 RET_ReallyLR implicit $d0
48 tracksRegLiveness: true
53 ; CHECK-LABEL: name: test_v2s32
56 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
57 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<2 x s32>) = G_CTLZ [[COPY]](<2 x s32>)
58 ; CHECK-NEXT: $d0 = COPY [[CTLZ]](<2 x s32>)
59 ; CHECK-NEXT: RET_ReallyLR implicit $d0
60 %0:_(<2 x s32>) = COPY $d0
61 %1:_(<2 x s32>) = G_CTLZ %0(<2 x s32>)
62 $d0 = COPY %1(<2 x s32>)
63 RET_ReallyLR implicit $d0
69 tracksRegLiveness: true
74 ; CHECK-LABEL: name: test_s64
77 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $d0
78 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
79 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[COPY1]](s64)
80 ; CHECK-NEXT: $d0 = COPY [[CTLZ]](s64)
81 ; CHECK-NEXT: RET_ReallyLR implicit $d0
83 %2:_(s64) = COPY %0(s64)
84 %1:_(s64) = G_CTLZ %2(s64)
86 RET_ReallyLR implicit $d0
92 tracksRegLiveness: true
96 ; CHECK-LABEL: name: test_s32
99 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $s0
100 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
101 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[COPY1]](s32)
102 ; CHECK-NEXT: $s0 = COPY [[CTLZ]](s32)
103 ; CHECK-NEXT: RET_ReallyLR implicit $s0
105 %2:_(s32) = COPY %0(s32)
106 %1:_(s32) = G_CTLZ %2(s32)
108 RET_ReallyLR implicit $s0
114 tracksRegLiveness: true
119 ; CHECK-LABEL: name: test_v16s8
120 ; CHECK: liveins: $q0
122 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
123 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<16 x s8>) = G_CTLZ [[COPY]](<16 x s8>)
124 ; CHECK-NEXT: $q0 = COPY [[CTLZ]](<16 x s8>)
125 ; CHECK-NEXT: RET_ReallyLR implicit $q0
126 %0:_(<16 x s8>) = COPY $q0
127 %1:_(<16 x s8>) = G_CTLZ %0(<16 x s8>)
128 $q0 = COPY %1(<16 x s8>)
129 RET_ReallyLR implicit $q0
135 tracksRegLiveness: true
140 ; CHECK-LABEL: name: test_v8s16
141 ; CHECK: liveins: $q0
143 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<8 x s16>) = COPY $q0
144 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<8 x s16>) = G_CTLZ [[COPY]](<8 x s16>)
145 ; CHECK-NEXT: $q0 = COPY [[CTLZ]](<8 x s16>)
146 ; CHECK-NEXT: RET_ReallyLR implicit $q0
147 %0:_(<8 x s16>) = COPY $q0
148 %1:_(<8 x s16>) = G_CTLZ %0(<8 x s16>)
149 $q0 = COPY %1(<8 x s16>)
150 RET_ReallyLR implicit $q0
156 tracksRegLiveness: true
161 ; CHECK-LABEL: name: test_v4s32
162 ; CHECK: liveins: $q0
164 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
165 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(<4 x s32>) = G_CTLZ [[COPY]](<4 x s32>)
166 ; CHECK-NEXT: $q0 = COPY [[CTLZ]](<4 x s32>)
167 ; CHECK-NEXT: RET_ReallyLR implicit $q0
168 %0:_(<4 x s32>) = COPY $q0
169 %1:_(<4 x s32>) = G_CTLZ %0(<4 x s32>)
170 $q0 = COPY %1(<4 x s32>)
171 RET_ReallyLR implicit $q0
175 # The ZERO_UNDEF variants just lower into the vanilla ones.
177 name: test_s32_zeroundef
179 tracksRegLiveness: true
183 ; CHECK-LABEL: name: test_s32_zeroundef
184 ; CHECK: liveins: $s0
186 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $s0
187 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
188 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[COPY1]](s32)
189 ; CHECK-NEXT: $s0 = COPY [[CTLZ]](s32)
190 ; CHECK-NEXT: RET_ReallyLR implicit $s0
192 %2:_(s32) = COPY %0(s32)
193 %1:_(s32) = G_CTLZ_ZERO_UNDEF %2(s32)
195 RET_ReallyLR implicit $s0
199 name: test_s64_zeroundef
201 tracksRegLiveness: true
206 ; CHECK-LABEL: name: test_s64_zeroundef
207 ; CHECK: liveins: $d0
209 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $d0
210 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
211 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[COPY1]](s64)
212 ; CHECK-NEXT: $d0 = COPY [[CTLZ]](s64)
213 ; CHECK-NEXT: RET_ReallyLR implicit $d0
215 %2:_(s64) = COPY %0(s64)
216 %1:_(s64) = G_CTLZ_ZERO_UNDEF %2(s64)
218 RET_ReallyLR implicit $d0
224 tracksRegLiveness: true
229 ; CHECK-LABEL: name: test_s35
230 ; CHECK: liveins: $x0
232 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
233 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738367
234 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
235 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[AND]](s64)
236 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
237 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[CTLZ]], [[C1]]
238 ; CHECK-NEXT: $x0 = COPY [[SUB]](s64)
239 ; CHECK-NEXT: RET_ReallyLR implicit $x0
241 %0:_(s35) = G_TRUNC %1(s64)
242 %2:_(s35) = G_CTLZ %0(s35)
243 %3:_(s64) = G_ANYEXT %2(s35)
245 RET_ReallyLR implicit $x0
250 tracksRegLiveness: true
255 ; CHECK-LABEL: name: test_s8
256 ; CHECK: liveins: $w0
258 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
259 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
260 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
261 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s32) = G_CTLZ [[AND]](s32)
262 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
263 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[CTLZ]], [[C1]]
264 ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
265 ; CHECK-NEXT: RET_ReallyLR implicit $w0
267 %0:_(s8) = G_TRUNC %1(s32)
268 %2:_(s8) = G_CTLZ %0(s8)
269 %3:_(s32) = G_ANYEXT %2(s8)
271 RET_ReallyLR implicit $w0
276 tracksRegLiveness: true
281 ; CHECK-LABEL: name: test_s65
282 ; CHECK: liveins: $x0, $x1
284 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
285 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
286 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
287 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
288 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
289 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
290 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
291 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[AND1]](s64), [[C2]]
292 ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[AND]](s64)
293 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
294 ; CHECK-NEXT: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s32) = G_UADDO [[CTLZ]], [[C3]]
295 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
296 ; CHECK-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[UADDO1]], [[C4]]
297 ; CHECK-NEXT: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s32) = G_UADDE [[C2]], [[C2]], [[AND2]]
298 ; CHECK-NEXT: [[CTLZ1:%[0-9]+]]:_(s64) = G_CTLZ [[AND1]](s64)
299 ; CHECK-NEXT: [[AND3:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C4]]
300 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[AND3]](s32), [[UADDO]], [[CTLZ1]]
301 ; CHECK-NEXT: [[AND4:%[0-9]+]]:_(s32) = G_AND [[ICMP]], [[C4]]
302 ; CHECK-NEXT: [[SELECT1:%[0-9]+]]:_(s64) = G_SELECT [[AND4]](s32), [[UADDE]], [[C2]]
303 ; CHECK-NEXT: [[C5:%[0-9]+]]:_(s64) = G_CONSTANT i64 63
304 ; CHECK-NEXT: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s32) = G_USUBO [[SELECT]], [[C5]]
305 ; CHECK-NEXT: [[AND5:%[0-9]+]]:_(s32) = G_AND [[USUBO1]], [[C4]]
306 ; CHECK-NEXT: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s32) = G_USUBE [[SELECT1]], [[C2]], [[AND5]]
307 ; CHECK-NEXT: $x0 = COPY [[USUBO]](s64)
308 ; CHECK-NEXT: $x1 = COPY [[USUBE]](s64)
309 ; CHECK-NEXT: RET_ReallyLR implicit $x0, implicit $x1
312 %3:_(s128) = G_MERGE_VALUES %1(s64), %2(s64)
313 %0:_(s65) = G_TRUNC %3(s128)
314 %4:_(s65) = G_CTLZ %0(s65)
315 %7:_(s128) = G_ANYEXT %4(s65)
316 %5:_(s64), %6:_(s64) = G_UNMERGE_VALUES %7(s128)
319 RET_ReallyLR implicit $x0, implicit $x1