1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- -mattr=+lzcnt | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+lzcnt | FileCheck %s --check-prefixes=CHECK,X32
4 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+lzcnt | FileCheck %s --check-prefixes=CHECK,X64
6 declare i8 @llvm.ctlz.i8(i8, i1) nounwind readnone
7 declare i16 @llvm.ctlz.i16(i16, i1) nounwind readnone
8 declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
9 declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone
11 define i8 @t1(i8 %x) nounwind {
14 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
15 ; X86-NEXT: lzcntl %eax, %eax
16 ; X86-NEXT: addl $-24, %eax
17 ; X86-NEXT: # kill: def $al killed $al killed $eax
22 ; X32-NEXT: movzbl %dil, %eax
23 ; X32-NEXT: lzcntl %eax, %eax
24 ; X32-NEXT: addl $-24, %eax
25 ; X32-NEXT: # kill: def $al killed $al killed $eax
30 ; X64-NEXT: movzbl %dil, %eax
31 ; X64-NEXT: lzcntl %eax, %eax
32 ; X64-NEXT: addl $-24, %eax
33 ; X64-NEXT: # kill: def $al killed $al killed $eax
35 %tmp = tail call i8 @llvm.ctlz.i8( i8 %x, i1 false )
39 define i16 @t2(i16 %x) nounwind {
42 ; X86-NEXT: lzcntw {{[0-9]+}}(%esp), %ax
47 ; X32-NEXT: lzcntw %di, %ax
52 ; X64-NEXT: lzcntw %di, %ax
54 %tmp = tail call i16 @llvm.ctlz.i16( i16 %x, i1 false )
58 define i32 @t3(i32 %x) nounwind {
61 ; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax
66 ; X32-NEXT: lzcntl %edi, %eax
71 ; X64-NEXT: lzcntl %edi, %eax
73 %tmp = tail call i32 @llvm.ctlz.i32( i32 %x, i1 false )
77 define i64 @t4(i64 %x) nounwind {
80 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
81 ; X86-NEXT: testl %eax, %eax
82 ; X86-NEXT: jne .LBB3_1
84 ; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax
85 ; X86-NEXT: addl $32, %eax
86 ; X86-NEXT: xorl %edx, %edx
89 ; X86-NEXT: lzcntl %eax, %eax
90 ; X86-NEXT: xorl %edx, %edx
95 ; X32-NEXT: lzcntq %rdi, %rax
100 ; X64-NEXT: lzcntq %rdi, %rax
102 %tmp = tail call i64 @llvm.ctlz.i64( i64 %x, i1 false )
106 define i8 @t5(i8 %x) nounwind {
109 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
110 ; X86-NEXT: lzcntl %eax, %eax
111 ; X86-NEXT: addl $-24, %eax
112 ; X86-NEXT: # kill: def $al killed $al killed $eax
117 ; X32-NEXT: movzbl %dil, %eax
118 ; X32-NEXT: lzcntl %eax, %eax
119 ; X32-NEXT: addl $-24, %eax
120 ; X32-NEXT: # kill: def $al killed $al killed $eax
125 ; X64-NEXT: movzbl %dil, %eax
126 ; X64-NEXT: lzcntl %eax, %eax
127 ; X64-NEXT: addl $-24, %eax
128 ; X64-NEXT: # kill: def $al killed $al killed $eax
130 %tmp = tail call i8 @llvm.ctlz.i8( i8 %x, i1 true )
134 define i16 @t6(i16 %x) nounwind {
137 ; X86-NEXT: lzcntw {{[0-9]+}}(%esp), %ax
142 ; X32-NEXT: lzcntw %di, %ax
147 ; X64-NEXT: lzcntw %di, %ax
149 %tmp = tail call i16 @llvm.ctlz.i16( i16 %x, i1 true )
153 define i32 @t7(i32 %x) nounwind {
156 ; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax
161 ; X32-NEXT: lzcntl %edi, %eax
166 ; X64-NEXT: lzcntl %edi, %eax
168 %tmp = tail call i32 @llvm.ctlz.i32( i32 %x, i1 true )
172 define i64 @t8(i64 %x) nounwind {
175 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
176 ; X86-NEXT: testl %eax, %eax
177 ; X86-NEXT: jne .LBB7_1
179 ; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax
180 ; X86-NEXT: addl $32, %eax
181 ; X86-NEXT: xorl %edx, %edx
184 ; X86-NEXT: lzcntl %eax, %eax
185 ; X86-NEXT: xorl %edx, %edx
190 ; X32-NEXT: lzcntq %rdi, %rax
195 ; X64-NEXT: lzcntq %rdi, %rax
197 %tmp = tail call i64 @llvm.ctlz.i64( i64 %x, i1 true )