1; RUN: llc < %s -march=avr | FileCheck %s
2
3define i8 @count_leading_zeros(i8) unnamed_addr {
4entry-block:
5  %1 = tail call i8 @llvm.ctlz.i8(i8 %0)
6  ret i8 %1
7}
8
9declare i8 @llvm.ctlz.i8(i8)
10
11; CHECK-LABEL: count_leading_zeros:
12; CHECK: cpi    [[RESULT:r[0-9]+]], 0
13; CHECK: brne   .LBB0_1
14; CHECK: rjmp   .LBB0_2
15; CHECK: mov    [[SCRATCH:r[0-9]+]], {{.*}}[[RESULT]]
16; CHECK: lsr    {{.*}}[[SCRATCH]]
17; CHECK: or     {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
18; CHECK: mov    {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
19; CHECK: lsr    {{.*}}[[RESULT]]
20; CHECK: lsr    {{.*}}[[RESULT]]
21; CHECK: or     {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
22; CHECK: mov    {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
23; CHECK: lsr    {{.*}}[[SCRATCH]]
24; CHECK: lsr    {{.*}}[[SCRATCH]]
25; CHECK: lsr    {{.*}}[[SCRATCH]]
26; CHECK: lsr    {{.*}}[[SCRATCH]]
27; CHECK: or     {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
28; CHECK: com    {{.*}}[[SCRATCH]]
29; CHECK: mov    {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
30; CHECK: lsr    {{.*}}[[RESULT]]
31; CHECK: andi   {{.*}}[[RESULT]], 85
32; CHECK: sub    {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
33; CHECK: mov    {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
34; CHECK: andi   {{.*}}[[RESULT]], 51
35; CHECK: lsr    {{.*}}[[SCRATCH]]
36; CHECK: lsr    {{.*}}[[SCRATCH]]
37; CHECK: andi   {{.*}}[[SCRATCH]], 51
38; CHECK: add    {{.*}}[[SCRATCH]], {{.*}}[[RESULT]]
39; CHECK: mov    {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
40; CHECK: lsr    {{.*}}[[RESULT]]
41; CHECK: lsr    {{.*}}[[RESULT]]
42; CHECK: lsr    {{.*}}[[RESULT]]
43; CHECK: lsr    {{.*}}[[RESULT]]
44; CHECK: add    {{.*}}[[RESULT]], {{.*}}[[SCRATCH]]
45; CHECK: andi   {{.*}}[[RESULT]], 15
46; CHECK: ret
47; CHECK: LBB0_2:
48; CHECK: ldi    {{.*}}[[RESULT]], 8
49; CHECK: ret
50