1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple arm-eabi -mattr=+v6t2 | FileCheck %s
3 ; RUN: llc < %s -mtriple arm-eabi -mattr=+v6t2 -mattr=+neon | FileCheck %s
4 ; RUN: llc < %s -mtriple thumbv6m-none-eabi | FileCheck %s --check-prefix=CHECK-6M
5 ; RUN: llc < %s -mtriple thumbv8m.base-none-eabi | FileCheck %s --check-prefix=CHECK-8MBASE
7 ; This test checks the @llvm.cttz.* intrinsics for integers.
9 declare i8 @llvm.cttz.i8(i8, i1)
10 declare i16 @llvm.cttz.i16(i16, i1)
11 declare i32 @llvm.cttz.i32(i32, i1)
12 declare i64 @llvm.cttz.i64(i64, i1)
14 ;------------------------------------------------------------------------------
16 define i8 @test_i8(i8 %a) {
17 ; CHECK-LABEL: test_i8:
19 ; CHECK-NEXT: orr r0, r0, #256
20 ; CHECK-NEXT: rbit r0, r0
21 ; CHECK-NEXT: clz r0, r0
24 ; CHECK-6M-LABEL: test_i8:
26 ; CHECK-6M-NEXT: lsls r1, r0, #24
27 ; CHECK-6M-NEXT: beq .LBB0_3
28 ; CHECK-6M-NEXT: @ %bb.1: @ %cond.false
29 ; CHECK-6M-NEXT: cmp r0, #0
30 ; CHECK-6M-NEXT: beq .LBB0_4
31 ; CHECK-6M-NEXT: @ %bb.2: @ %cond.false
32 ; CHECK-6M-NEXT: rsbs r1, r0, #0
33 ; CHECK-6M-NEXT: ands r1, r0
34 ; CHECK-6M-NEXT: ldr r0, .LCPI0_0
35 ; CHECK-6M-NEXT: muls r0, r1, r0
36 ; CHECK-6M-NEXT: lsrs r0, r0, #27
37 ; CHECK-6M-NEXT: adr r1, .LCPI0_1
38 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
39 ; CHECK-6M-NEXT: bx lr
40 ; CHECK-6M-NEXT: .LBB0_3:
41 ; CHECK-6M-NEXT: movs r0, #8
42 ; CHECK-6M-NEXT: bx lr
43 ; CHECK-6M-NEXT: .LBB0_4:
44 ; CHECK-6M-NEXT: movs r0, #32
45 ; CHECK-6M-NEXT: bx lr
46 ; CHECK-6M-NEXT: .p2align 2
47 ; CHECK-6M-NEXT: @ %bb.5:
48 ; CHECK-6M-NEXT: .LCPI0_0:
49 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
50 ; CHECK-6M-NEXT: .LCPI0_1:
51 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
53 ; CHECK-8MBASE-LABEL: test_i8:
54 ; CHECK-8MBASE: @ %bb.0:
55 ; CHECK-8MBASE-NEXT: lsls r1, r0, #24
56 ; CHECK-8MBASE-NEXT: beq .LBB0_3
57 ; CHECK-8MBASE-NEXT: @ %bb.1: @ %cond.false
58 ; CHECK-8MBASE-NEXT: cbz r0, .LBB0_4
59 ; CHECK-8MBASE-NEXT: @ %bb.2: @ %cond.false
60 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
61 ; CHECK-8MBASE-NEXT: ands r1, r0
62 ; CHECK-8MBASE-NEXT: movw r0, #46385
63 ; CHECK-8MBASE-NEXT: movt r0, #1916
64 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
65 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
66 ; CHECK-8MBASE-NEXT: adr r1, .LCPI0_0
67 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
68 ; CHECK-8MBASE-NEXT: bx lr
69 ; CHECK-8MBASE-NEXT: .LBB0_3:
70 ; CHECK-8MBASE-NEXT: movs r0, #8
71 ; CHECK-8MBASE-NEXT: bx lr
72 ; CHECK-8MBASE-NEXT: .LBB0_4:
73 ; CHECK-8MBASE-NEXT: movs r0, #32
74 ; CHECK-8MBASE-NEXT: bx lr
75 ; CHECK-8MBASE-NEXT: .p2align 2
76 ; CHECK-8MBASE-NEXT: @ %bb.5:
77 ; CHECK-8MBASE-NEXT: .LCPI0_0:
78 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
79 %tmp = call i8 @llvm.cttz.i8(i8 %a, i1 false)
83 define i16 @test_i16(i16 %a) {
84 ; CHECK-LABEL: test_i16:
86 ; CHECK-NEXT: orr r0, r0, #65536
87 ; CHECK-NEXT: rbit r0, r0
88 ; CHECK-NEXT: clz r0, r0
91 ; CHECK-6M-LABEL: test_i16:
93 ; CHECK-6M-NEXT: lsls r1, r0, #16
94 ; CHECK-6M-NEXT: beq .LBB1_3
95 ; CHECK-6M-NEXT: @ %bb.1: @ %cond.false
96 ; CHECK-6M-NEXT: cmp r0, #0
97 ; CHECK-6M-NEXT: beq .LBB1_4
98 ; CHECK-6M-NEXT: @ %bb.2: @ %cond.false
99 ; CHECK-6M-NEXT: rsbs r1, r0, #0
100 ; CHECK-6M-NEXT: ands r1, r0
101 ; CHECK-6M-NEXT: ldr r0, .LCPI1_0
102 ; CHECK-6M-NEXT: muls r0, r1, r0
103 ; CHECK-6M-NEXT: lsrs r0, r0, #27
104 ; CHECK-6M-NEXT: adr r1, .LCPI1_1
105 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
106 ; CHECK-6M-NEXT: bx lr
107 ; CHECK-6M-NEXT: .LBB1_3:
108 ; CHECK-6M-NEXT: movs r0, #16
109 ; CHECK-6M-NEXT: bx lr
110 ; CHECK-6M-NEXT: .LBB1_4:
111 ; CHECK-6M-NEXT: movs r0, #32
112 ; CHECK-6M-NEXT: bx lr
113 ; CHECK-6M-NEXT: .p2align 2
114 ; CHECK-6M-NEXT: @ %bb.5:
115 ; CHECK-6M-NEXT: .LCPI1_0:
116 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
117 ; CHECK-6M-NEXT: .LCPI1_1:
118 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
120 ; CHECK-8MBASE-LABEL: test_i16:
121 ; CHECK-8MBASE: @ %bb.0:
122 ; CHECK-8MBASE-NEXT: lsls r1, r0, #16
123 ; CHECK-8MBASE-NEXT: beq .LBB1_3
124 ; CHECK-8MBASE-NEXT: @ %bb.1: @ %cond.false
125 ; CHECK-8MBASE-NEXT: cbz r0, .LBB1_4
126 ; CHECK-8MBASE-NEXT: @ %bb.2: @ %cond.false
127 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
128 ; CHECK-8MBASE-NEXT: ands r1, r0
129 ; CHECK-8MBASE-NEXT: movw r0, #46385
130 ; CHECK-8MBASE-NEXT: movt r0, #1916
131 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
132 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
133 ; CHECK-8MBASE-NEXT: adr r1, .LCPI1_0
134 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
135 ; CHECK-8MBASE-NEXT: bx lr
136 ; CHECK-8MBASE-NEXT: .LBB1_3:
137 ; CHECK-8MBASE-NEXT: movs r0, #16
138 ; CHECK-8MBASE-NEXT: bx lr
139 ; CHECK-8MBASE-NEXT: .LBB1_4:
140 ; CHECK-8MBASE-NEXT: movs r0, #32
141 ; CHECK-8MBASE-NEXT: bx lr
142 ; CHECK-8MBASE-NEXT: .p2align 2
143 ; CHECK-8MBASE-NEXT: @ %bb.5:
144 ; CHECK-8MBASE-NEXT: .LCPI1_0:
145 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
146 %tmp = call i16 @llvm.cttz.i16(i16 %a, i1 false)
150 define i32 @test_i32(i32 %a) {
151 ; CHECK-LABEL: test_i32:
153 ; CHECK-NEXT: rbit r0, r0
154 ; CHECK-NEXT: clz r0, r0
157 ; CHECK-6M-LABEL: test_i32:
159 ; CHECK-6M-NEXT: cmp r0, #0
160 ; CHECK-6M-NEXT: beq .LBB2_3
161 ; CHECK-6M-NEXT: @ %bb.1: @ %cond.false
162 ; CHECK-6M-NEXT: cmp r0, #0
163 ; CHECK-6M-NEXT: beq .LBB2_3
164 ; CHECK-6M-NEXT: @ %bb.2: @ %cond.false
165 ; CHECK-6M-NEXT: rsbs r1, r0, #0
166 ; CHECK-6M-NEXT: ands r1, r0
167 ; CHECK-6M-NEXT: ldr r0, .LCPI2_0
168 ; CHECK-6M-NEXT: muls r0, r1, r0
169 ; CHECK-6M-NEXT: lsrs r0, r0, #27
170 ; CHECK-6M-NEXT: adr r1, .LCPI2_1
171 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
172 ; CHECK-6M-NEXT: bx lr
173 ; CHECK-6M-NEXT: .LBB2_3:
174 ; CHECK-6M-NEXT: movs r0, #32
175 ; CHECK-6M-NEXT: bx lr
176 ; CHECK-6M-NEXT: .p2align 2
177 ; CHECK-6M-NEXT: @ %bb.4:
178 ; CHECK-6M-NEXT: .LCPI2_0:
179 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
180 ; CHECK-6M-NEXT: .LCPI2_1:
181 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
183 ; CHECK-8MBASE-LABEL: test_i32:
184 ; CHECK-8MBASE: @ %bb.0:
185 ; CHECK-8MBASE-NEXT: cbz r0, .LBB2_3
186 ; CHECK-8MBASE-NEXT: @ %bb.1: @ %cond.false
187 ; CHECK-8MBASE-NEXT: cbz r0, .LBB2_3
188 ; CHECK-8MBASE-NEXT: @ %bb.2: @ %cond.false
189 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
190 ; CHECK-8MBASE-NEXT: ands r1, r0
191 ; CHECK-8MBASE-NEXT: movw r0, #46385
192 ; CHECK-8MBASE-NEXT: movt r0, #1916
193 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
194 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
195 ; CHECK-8MBASE-NEXT: adr r1, .LCPI2_0
196 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
197 ; CHECK-8MBASE-NEXT: bx lr
198 ; CHECK-8MBASE-NEXT: .LBB2_3:
199 ; CHECK-8MBASE-NEXT: movs r0, #32
200 ; CHECK-8MBASE-NEXT: bx lr
201 ; CHECK-8MBASE-NEXT: .p2align 2
202 ; CHECK-8MBASE-NEXT: @ %bb.4:
203 ; CHECK-8MBASE-NEXT: .LCPI2_0:
204 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
205 %tmp = call i32 @llvm.cttz.i32(i32 %a, i1 false)
209 define i64 @test_i64(i64 %a) {
210 ; CHECK-LABEL: test_i64:
212 ; CHECK-NEXT: rbit r1, r1
213 ; CHECK-NEXT: rbit r2, r0
214 ; CHECK-NEXT: clz r1, r1
215 ; CHECK-NEXT: cmp r0, #0
216 ; CHECK-NEXT: add r1, r1, #32
217 ; CHECK-NEXT: clzne r1, r2
218 ; CHECK-NEXT: mov r0, r1
219 ; CHECK-NEXT: mov r1, #0
222 ; CHECK-6M-LABEL: test_i64:
224 ; CHECK-6M-NEXT: .save {r4, r5, r7, lr}
225 ; CHECK-6M-NEXT: push {r4, r5, r7, lr}
226 ; CHECK-6M-NEXT: ldr r5, .LCPI3_0
227 ; CHECK-6M-NEXT: adr r4, .LCPI3_1
228 ; CHECK-6M-NEXT: movs r3, #32
229 ; CHECK-6M-NEXT: cmp r0, #0
230 ; CHECK-6M-NEXT: mov r2, r3
231 ; CHECK-6M-NEXT: bne .LBB3_5
232 ; CHECK-6M-NEXT: @ %bb.1:
233 ; CHECK-6M-NEXT: cmp r1, #0
234 ; CHECK-6M-NEXT: bne .LBB3_6
235 ; CHECK-6M-NEXT: .LBB3_2:
236 ; CHECK-6M-NEXT: cmp r0, #0
237 ; CHECK-6M-NEXT: bne .LBB3_4
238 ; CHECK-6M-NEXT: .LBB3_3:
239 ; CHECK-6M-NEXT: adds r3, #32
240 ; CHECK-6M-NEXT: mov r2, r3
241 ; CHECK-6M-NEXT: .LBB3_4:
242 ; CHECK-6M-NEXT: movs r1, #0
243 ; CHECK-6M-NEXT: mov r0, r2
244 ; CHECK-6M-NEXT: pop {r4, r5, r7, pc}
245 ; CHECK-6M-NEXT: .LBB3_5:
246 ; CHECK-6M-NEXT: rsbs r2, r0, #0
247 ; CHECK-6M-NEXT: ands r2, r0
248 ; CHECK-6M-NEXT: muls r2, r5, r2
249 ; CHECK-6M-NEXT: lsrs r2, r2, #27
250 ; CHECK-6M-NEXT: ldrb r2, [r4, r2]
251 ; CHECK-6M-NEXT: cmp r1, #0
252 ; CHECK-6M-NEXT: beq .LBB3_2
253 ; CHECK-6M-NEXT: .LBB3_6:
254 ; CHECK-6M-NEXT: rsbs r3, r1, #0
255 ; CHECK-6M-NEXT: ands r3, r1
256 ; CHECK-6M-NEXT: muls r5, r3, r5
257 ; CHECK-6M-NEXT: lsrs r1, r5, #27
258 ; CHECK-6M-NEXT: ldrb r3, [r4, r1]
259 ; CHECK-6M-NEXT: cmp r0, #0
260 ; CHECK-6M-NEXT: beq .LBB3_3
261 ; CHECK-6M-NEXT: b .LBB3_4
262 ; CHECK-6M-NEXT: .p2align 2
263 ; CHECK-6M-NEXT: @ %bb.7:
264 ; CHECK-6M-NEXT: .LCPI3_0:
265 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
266 ; CHECK-6M-NEXT: .LCPI3_1:
267 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
269 ; CHECK-8MBASE-LABEL: test_i64:
270 ; CHECK-8MBASE: @ %bb.0:
271 ; CHECK-8MBASE-NEXT: .save {r4, r5, r7, lr}
272 ; CHECK-8MBASE-NEXT: push {r4, r5, r7, lr}
273 ; CHECK-8MBASE-NEXT: movw r5, #46385
274 ; CHECK-8MBASE-NEXT: movt r5, #1916
275 ; CHECK-8MBASE-NEXT: adr r4, .LCPI3_0
276 ; CHECK-8MBASE-NEXT: movs r3, #32
277 ; CHECK-8MBASE-NEXT: mov r2, r3
278 ; CHECK-8MBASE-NEXT: cbnz r0, .LBB3_5
279 ; CHECK-8MBASE-NEXT: @ %bb.1:
280 ; CHECK-8MBASE-NEXT: cbnz r1, .LBB3_6
281 ; CHECK-8MBASE-NEXT: .LBB3_2:
282 ; CHECK-8MBASE-NEXT: cbnz r0, .LBB3_4
283 ; CHECK-8MBASE-NEXT: .LBB3_3:
284 ; CHECK-8MBASE-NEXT: adds r3, #32
285 ; CHECK-8MBASE-NEXT: mov r2, r3
286 ; CHECK-8MBASE-NEXT: .LBB3_4:
287 ; CHECK-8MBASE-NEXT: movs r1, #0
288 ; CHECK-8MBASE-NEXT: mov r0, r2
289 ; CHECK-8MBASE-NEXT: pop {r4, r5, r7, pc}
290 ; CHECK-8MBASE-NEXT: .LBB3_5:
291 ; CHECK-8MBASE-NEXT: rsbs r2, r0, #0
292 ; CHECK-8MBASE-NEXT: ands r2, r0
293 ; CHECK-8MBASE-NEXT: muls r2, r5, r2
294 ; CHECK-8MBASE-NEXT: lsrs r2, r2, #27
295 ; CHECK-8MBASE-NEXT: ldrb r2, [r4, r2]
296 ; CHECK-8MBASE-NEXT: cmp r1, #0
297 ; CHECK-8MBASE-NEXT: beq .LBB3_2
298 ; CHECK-8MBASE-NEXT: .LBB3_6:
299 ; CHECK-8MBASE-NEXT: rsbs r3, r1, #0
300 ; CHECK-8MBASE-NEXT: ands r3, r1
301 ; CHECK-8MBASE-NEXT: muls r5, r3, r5
302 ; CHECK-8MBASE-NEXT: lsrs r1, r5, #27
303 ; CHECK-8MBASE-NEXT: ldrb r3, [r4, r1]
304 ; CHECK-8MBASE-NEXT: cmp r0, #0
305 ; CHECK-8MBASE-NEXT: beq .LBB3_3
306 ; CHECK-8MBASE-NEXT: b .LBB3_4
307 ; CHECK-8MBASE-NEXT: .p2align 2
308 ; CHECK-8MBASE-NEXT: @ %bb.7:
309 ; CHECK-8MBASE-NEXT: .LCPI3_0:
310 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
311 %tmp = call i64 @llvm.cttz.i64(i64 %a, i1 false)
315 ;------------------------------------------------------------------------------
317 define i8 @test_i8_zero_undef(i8 %a) {
318 ; CHECK-LABEL: test_i8_zero_undef:
320 ; CHECK-NEXT: rbit r0, r0
321 ; CHECK-NEXT: clz r0, r0
324 ; CHECK-6M-LABEL: test_i8_zero_undef:
326 ; CHECK-6M-NEXT: cmp r0, #0
327 ; CHECK-6M-NEXT: beq .LBB4_2
328 ; CHECK-6M-NEXT: @ %bb.1:
329 ; CHECK-6M-NEXT: rsbs r1, r0, #0
330 ; CHECK-6M-NEXT: ands r1, r0
331 ; CHECK-6M-NEXT: ldr r0, .LCPI4_0
332 ; CHECK-6M-NEXT: muls r0, r1, r0
333 ; CHECK-6M-NEXT: lsrs r0, r0, #27
334 ; CHECK-6M-NEXT: adr r1, .LCPI4_1
335 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
336 ; CHECK-6M-NEXT: bx lr
337 ; CHECK-6M-NEXT: .LBB4_2:
338 ; CHECK-6M-NEXT: movs r0, #32
339 ; CHECK-6M-NEXT: bx lr
340 ; CHECK-6M-NEXT: .p2align 2
341 ; CHECK-6M-NEXT: @ %bb.3:
342 ; CHECK-6M-NEXT: .LCPI4_0:
343 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
344 ; CHECK-6M-NEXT: .LCPI4_1:
345 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
347 ; CHECK-8MBASE-LABEL: test_i8_zero_undef:
348 ; CHECK-8MBASE: @ %bb.0:
349 ; CHECK-8MBASE-NEXT: cbz r0, .LBB4_2
350 ; CHECK-8MBASE-NEXT: @ %bb.1:
351 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
352 ; CHECK-8MBASE-NEXT: ands r1, r0
353 ; CHECK-8MBASE-NEXT: movw r0, #46385
354 ; CHECK-8MBASE-NEXT: movt r0, #1916
355 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
356 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
357 ; CHECK-8MBASE-NEXT: adr r1, .LCPI4_0
358 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
359 ; CHECK-8MBASE-NEXT: bx lr
360 ; CHECK-8MBASE-NEXT: .LBB4_2:
361 ; CHECK-8MBASE-NEXT: movs r0, #32
362 ; CHECK-8MBASE-NEXT: bx lr
363 ; CHECK-8MBASE-NEXT: .p2align 2
364 ; CHECK-8MBASE-NEXT: @ %bb.3:
365 ; CHECK-8MBASE-NEXT: .LCPI4_0:
366 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
367 %tmp = call i8 @llvm.cttz.i8(i8 %a, i1 true)
371 define i16 @test_i16_zero_undef(i16 %a) {
372 ; CHECK-LABEL: test_i16_zero_undef:
374 ; CHECK-NEXT: rbit r0, r0
375 ; CHECK-NEXT: clz r0, r0
378 ; CHECK-6M-LABEL: test_i16_zero_undef:
380 ; CHECK-6M-NEXT: cmp r0, #0
381 ; CHECK-6M-NEXT: beq .LBB5_2
382 ; CHECK-6M-NEXT: @ %bb.1:
383 ; CHECK-6M-NEXT: rsbs r1, r0, #0
384 ; CHECK-6M-NEXT: ands r1, r0
385 ; CHECK-6M-NEXT: ldr r0, .LCPI5_0
386 ; CHECK-6M-NEXT: muls r0, r1, r0
387 ; CHECK-6M-NEXT: lsrs r0, r0, #27
388 ; CHECK-6M-NEXT: adr r1, .LCPI5_1
389 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
390 ; CHECK-6M-NEXT: bx lr
391 ; CHECK-6M-NEXT: .LBB5_2:
392 ; CHECK-6M-NEXT: movs r0, #32
393 ; CHECK-6M-NEXT: bx lr
394 ; CHECK-6M-NEXT: .p2align 2
395 ; CHECK-6M-NEXT: @ %bb.3:
396 ; CHECK-6M-NEXT: .LCPI5_0:
397 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
398 ; CHECK-6M-NEXT: .LCPI5_1:
399 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
401 ; CHECK-8MBASE-LABEL: test_i16_zero_undef:
402 ; CHECK-8MBASE: @ %bb.0:
403 ; CHECK-8MBASE-NEXT: cbz r0, .LBB5_2
404 ; CHECK-8MBASE-NEXT: @ %bb.1:
405 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
406 ; CHECK-8MBASE-NEXT: ands r1, r0
407 ; CHECK-8MBASE-NEXT: movw r0, #46385
408 ; CHECK-8MBASE-NEXT: movt r0, #1916
409 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
410 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
411 ; CHECK-8MBASE-NEXT: adr r1, .LCPI5_0
412 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
413 ; CHECK-8MBASE-NEXT: bx lr
414 ; CHECK-8MBASE-NEXT: .LBB5_2:
415 ; CHECK-8MBASE-NEXT: movs r0, #32
416 ; CHECK-8MBASE-NEXT: bx lr
417 ; CHECK-8MBASE-NEXT: .p2align 2
418 ; CHECK-8MBASE-NEXT: @ %bb.3:
419 ; CHECK-8MBASE-NEXT: .LCPI5_0:
420 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
421 %tmp = call i16 @llvm.cttz.i16(i16 %a, i1 true)
426 define i32 @test_i32_zero_undef(i32 %a) {
427 ; CHECK-LABEL: test_i32_zero_undef:
429 ; CHECK-NEXT: rbit r0, r0
430 ; CHECK-NEXT: clz r0, r0
433 ; CHECK-6M-LABEL: test_i32_zero_undef:
435 ; CHECK-6M-NEXT: cmp r0, #0
436 ; CHECK-6M-NEXT: beq .LBB6_2
437 ; CHECK-6M-NEXT: @ %bb.1:
438 ; CHECK-6M-NEXT: rsbs r1, r0, #0
439 ; CHECK-6M-NEXT: ands r1, r0
440 ; CHECK-6M-NEXT: ldr r0, .LCPI6_0
441 ; CHECK-6M-NEXT: muls r0, r1, r0
442 ; CHECK-6M-NEXT: lsrs r0, r0, #27
443 ; CHECK-6M-NEXT: adr r1, .LCPI6_1
444 ; CHECK-6M-NEXT: ldrb r0, [r1, r0]
445 ; CHECK-6M-NEXT: bx lr
446 ; CHECK-6M-NEXT: .LBB6_2:
447 ; CHECK-6M-NEXT: movs r0, #32
448 ; CHECK-6M-NEXT: bx lr
449 ; CHECK-6M-NEXT: .p2align 2
450 ; CHECK-6M-NEXT: @ %bb.3:
451 ; CHECK-6M-NEXT: .LCPI6_0:
452 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
453 ; CHECK-6M-NEXT: .LCPI6_1:
454 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
456 ; CHECK-8MBASE-LABEL: test_i32_zero_undef:
457 ; CHECK-8MBASE: @ %bb.0:
458 ; CHECK-8MBASE-NEXT: cbz r0, .LBB6_2
459 ; CHECK-8MBASE-NEXT: @ %bb.1:
460 ; CHECK-8MBASE-NEXT: rsbs r1, r0, #0
461 ; CHECK-8MBASE-NEXT: ands r1, r0
462 ; CHECK-8MBASE-NEXT: movw r0, #46385
463 ; CHECK-8MBASE-NEXT: movt r0, #1916
464 ; CHECK-8MBASE-NEXT: muls r0, r1, r0
465 ; CHECK-8MBASE-NEXT: lsrs r0, r0, #27
466 ; CHECK-8MBASE-NEXT: adr r1, .LCPI6_0
467 ; CHECK-8MBASE-NEXT: ldrb r0, [r1, r0]
468 ; CHECK-8MBASE-NEXT: bx lr
469 ; CHECK-8MBASE-NEXT: .LBB6_2:
470 ; CHECK-8MBASE-NEXT: movs r0, #32
471 ; CHECK-8MBASE-NEXT: bx lr
472 ; CHECK-8MBASE-NEXT: .p2align 2
473 ; CHECK-8MBASE-NEXT: @ %bb.3:
474 ; CHECK-8MBASE-NEXT: .LCPI6_0:
475 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
476 %tmp = call i32 @llvm.cttz.i32(i32 %a, i1 true)
480 define i64 @test_i64_zero_undef(i64 %a) {
481 ; CHECK-LABEL: test_i64_zero_undef:
483 ; CHECK-NEXT: rbit r1, r1
484 ; CHECK-NEXT: rbit r2, r0
485 ; CHECK-NEXT: clz r1, r1
486 ; CHECK-NEXT: cmp r0, #0
487 ; CHECK-NEXT: add r1, r1, #32
488 ; CHECK-NEXT: clzne r1, r2
489 ; CHECK-NEXT: mov r0, r1
490 ; CHECK-NEXT: mov r1, #0
493 ; CHECK-6M-LABEL: test_i64_zero_undef:
495 ; CHECK-6M-NEXT: .save {r4, r5, r7, lr}
496 ; CHECK-6M-NEXT: push {r4, r5, r7, lr}
497 ; CHECK-6M-NEXT: ldr r5, .LCPI7_0
498 ; CHECK-6M-NEXT: adr r4, .LCPI7_1
499 ; CHECK-6M-NEXT: movs r3, #32
500 ; CHECK-6M-NEXT: cmp r0, #0
501 ; CHECK-6M-NEXT: mov r2, r3
502 ; CHECK-6M-NEXT: bne .LBB7_5
503 ; CHECK-6M-NEXT: @ %bb.1:
504 ; CHECK-6M-NEXT: cmp r1, #0
505 ; CHECK-6M-NEXT: bne .LBB7_6
506 ; CHECK-6M-NEXT: .LBB7_2:
507 ; CHECK-6M-NEXT: cmp r0, #0
508 ; CHECK-6M-NEXT: bne .LBB7_4
509 ; CHECK-6M-NEXT: .LBB7_3:
510 ; CHECK-6M-NEXT: adds r3, #32
511 ; CHECK-6M-NEXT: mov r2, r3
512 ; CHECK-6M-NEXT: .LBB7_4:
513 ; CHECK-6M-NEXT: movs r1, #0
514 ; CHECK-6M-NEXT: mov r0, r2
515 ; CHECK-6M-NEXT: pop {r4, r5, r7, pc}
516 ; CHECK-6M-NEXT: .LBB7_5:
517 ; CHECK-6M-NEXT: rsbs r2, r0, #0
518 ; CHECK-6M-NEXT: ands r2, r0
519 ; CHECK-6M-NEXT: muls r2, r5, r2
520 ; CHECK-6M-NEXT: lsrs r2, r2, #27
521 ; CHECK-6M-NEXT: ldrb r2, [r4, r2]
522 ; CHECK-6M-NEXT: cmp r1, #0
523 ; CHECK-6M-NEXT: beq .LBB7_2
524 ; CHECK-6M-NEXT: .LBB7_6:
525 ; CHECK-6M-NEXT: rsbs r3, r1, #0
526 ; CHECK-6M-NEXT: ands r3, r1
527 ; CHECK-6M-NEXT: muls r5, r3, r5
528 ; CHECK-6M-NEXT: lsrs r1, r5, #27
529 ; CHECK-6M-NEXT: ldrb r3, [r4, r1]
530 ; CHECK-6M-NEXT: cmp r0, #0
531 ; CHECK-6M-NEXT: beq .LBB7_3
532 ; CHECK-6M-NEXT: b .LBB7_4
533 ; CHECK-6M-NEXT: .p2align 2
534 ; CHECK-6M-NEXT: @ %bb.7:
535 ; CHECK-6M-NEXT: .LCPI7_0:
536 ; CHECK-6M-NEXT: .long 125613361 @ 0x77cb531
537 ; CHECK-6M-NEXT: .LCPI7_1:
538 ; CHECK-6M-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
540 ; CHECK-8MBASE-LABEL: test_i64_zero_undef:
541 ; CHECK-8MBASE: @ %bb.0:
542 ; CHECK-8MBASE-NEXT: .save {r4, r5, r7, lr}
543 ; CHECK-8MBASE-NEXT: push {r4, r5, r7, lr}
544 ; CHECK-8MBASE-NEXT: movw r5, #46385
545 ; CHECK-8MBASE-NEXT: movt r5, #1916
546 ; CHECK-8MBASE-NEXT: adr r4, .LCPI7_0
547 ; CHECK-8MBASE-NEXT: movs r3, #32
548 ; CHECK-8MBASE-NEXT: mov r2, r3
549 ; CHECK-8MBASE-NEXT: cbnz r0, .LBB7_5
550 ; CHECK-8MBASE-NEXT: @ %bb.1:
551 ; CHECK-8MBASE-NEXT: cbnz r1, .LBB7_6
552 ; CHECK-8MBASE-NEXT: .LBB7_2:
553 ; CHECK-8MBASE-NEXT: cbnz r0, .LBB7_4
554 ; CHECK-8MBASE-NEXT: .LBB7_3:
555 ; CHECK-8MBASE-NEXT: adds r3, #32
556 ; CHECK-8MBASE-NEXT: mov r2, r3
557 ; CHECK-8MBASE-NEXT: .LBB7_4:
558 ; CHECK-8MBASE-NEXT: movs r1, #0
559 ; CHECK-8MBASE-NEXT: mov r0, r2
560 ; CHECK-8MBASE-NEXT: pop {r4, r5, r7, pc}
561 ; CHECK-8MBASE-NEXT: .LBB7_5:
562 ; CHECK-8MBASE-NEXT: rsbs r2, r0, #0
563 ; CHECK-8MBASE-NEXT: ands r2, r0
564 ; CHECK-8MBASE-NEXT: muls r2, r5, r2
565 ; CHECK-8MBASE-NEXT: lsrs r2, r2, #27
566 ; CHECK-8MBASE-NEXT: ldrb r2, [r4, r2]
567 ; CHECK-8MBASE-NEXT: cmp r1, #0
568 ; CHECK-8MBASE-NEXT: beq .LBB7_2
569 ; CHECK-8MBASE-NEXT: .LBB7_6:
570 ; CHECK-8MBASE-NEXT: rsbs r3, r1, #0
571 ; CHECK-8MBASE-NEXT: ands r3, r1
572 ; CHECK-8MBASE-NEXT: muls r5, r3, r5
573 ; CHECK-8MBASE-NEXT: lsrs r1, r5, #27
574 ; CHECK-8MBASE-NEXT: ldrb r3, [r4, r1]
575 ; CHECK-8MBASE-NEXT: cmp r0, #0
576 ; CHECK-8MBASE-NEXT: beq .LBB7_3
577 ; CHECK-8MBASE-NEXT: b .LBB7_4
578 ; CHECK-8MBASE-NEXT: .p2align 2
579 ; CHECK-8MBASE-NEXT: @ %bb.7:
580 ; CHECK-8MBASE-NEXT: .LCPI7_0:
581 ; CHECK-8MBASE-NEXT: .ascii "\000\001\034\002\035\016\030\003\036\026\024\017\031\021\004\b\037\033\r\027\025\023\020\007\032\f\022\006\013\005\n\t"
582 %tmp = call i64 @llvm.cttz.i64(i64 %a, i1 true)