198 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 42; RUN: llc < %s -mtriple=i686-- -mattr=+lzcnt | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+lzcnt | FileCheck %s --check-prefix=X324; RUN: llc < %s -mtriple=x86_64-- -mattr=+lzcnt | FileCheck %s --check-prefix=X645 6declare i8 @llvm.ctlz.i8(i8, i1) nounwind readnone7declare i16 @llvm.ctlz.i16(i16, i1) nounwind readnone8declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone9declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone10 11define i8 @t1(i8 %x) nounwind {12; X86-LABEL: t1:13; X86: # %bb.0:14; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax15; X86-NEXT: lzcntl %eax, %eax16; X86-NEXT: addl $-24, %eax17; X86-NEXT: # kill: def $al killed $al killed $eax18; X86-NEXT: retl19;20; X32-LABEL: t1:21; X32: # %bb.0:22; X32-NEXT: movzbl %dil, %eax23; X32-NEXT: lzcntl %eax, %eax24; X32-NEXT: addl $-24, %eax25; X32-NEXT: # kill: def $al killed $al killed $eax26; X32-NEXT: retq27;28; X64-LABEL: t1:29; X64: # %bb.0:30; X64-NEXT: movzbl %dil, %eax31; X64-NEXT: lzcntl %eax, %eax32; X64-NEXT: addl $-24, %eax33; X64-NEXT: # kill: def $al killed $al killed $eax34; X64-NEXT: retq35 %tmp = tail call i8 @llvm.ctlz.i8( i8 %x, i1 false )36 ret i8 %tmp37}38 39define i16 @t2(i16 %x) nounwind {40; X86-LABEL: t2:41; X86: # %bb.0:42; X86-NEXT: lzcntw {{[0-9]+}}(%esp), %ax43; X86-NEXT: retl44;45; X32-LABEL: t2:46; X32: # %bb.0:47; X32-NEXT: lzcntw %di, %ax48; X32-NEXT: retq49;50; X64-LABEL: t2:51; X64: # %bb.0:52; X64-NEXT: lzcntw %di, %ax53; X64-NEXT: retq54 %tmp = tail call i16 @llvm.ctlz.i16( i16 %x, i1 false )55 ret i16 %tmp56}57 58define i32 @t3(i32 %x) nounwind {59; X86-LABEL: t3:60; X86: # %bb.0:61; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax62; X86-NEXT: retl63;64; X32-LABEL: t3:65; X32: # %bb.0:66; X32-NEXT: lzcntl %edi, %eax67; X32-NEXT: retq68;69; X64-LABEL: t3:70; X64: # %bb.0:71; X64-NEXT: lzcntl %edi, %eax72; X64-NEXT: retq73 %tmp = tail call i32 @llvm.ctlz.i32( i32 %x, i1 false )74 ret i32 %tmp75}76 77define i64 @t4(i64 %x) nounwind {78; X86-LABEL: t4:79; X86: # %bb.0:80; X86-NEXT: movl {{[0-9]+}}(%esp), %eax81; X86-NEXT: testl %eax, %eax82; X86-NEXT: jne .LBB3_183; X86-NEXT: # %bb.2:84; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax85; X86-NEXT: addl $32, %eax86; X86-NEXT: xorl %edx, %edx87; X86-NEXT: retl88; X86-NEXT: .LBB3_1:89; X86-NEXT: lzcntl %eax, %eax90; X86-NEXT: xorl %edx, %edx91; X86-NEXT: retl92;93; X32-LABEL: t4:94; X32: # %bb.0:95; X32-NEXT: lzcntq %rdi, %rax96; X32-NEXT: retq97;98; X64-LABEL: t4:99; X64: # %bb.0:100; X64-NEXT: lzcntq %rdi, %rax101; X64-NEXT: retq102 %tmp = tail call i64 @llvm.ctlz.i64( i64 %x, i1 false )103 ret i64 %tmp104}105 106define i8 @t5(i8 %x) nounwind {107; X86-LABEL: t5:108; X86: # %bb.0:109; X86-NEXT: movl {{[0-9]+}}(%esp), %eax110; X86-NEXT: shll $24, %eax111; X86-NEXT: lzcntl %eax, %eax112; X86-NEXT: # kill: def $al killed $al killed $eax113; X86-NEXT: retl114;115; X32-LABEL: t5:116; X32: # %bb.0:117; X32-NEXT: shll $24, %edi118; X32-NEXT: lzcntl %edi, %eax119; X32-NEXT: # kill: def $al killed $al killed $eax120; X32-NEXT: retq121;122; X64-LABEL: t5:123; X64: # %bb.0:124; X64-NEXT: shll $24, %edi125; X64-NEXT: lzcntl %edi, %eax126; X64-NEXT: # kill: def $al killed $al killed $eax127; X64-NEXT: retq128 %tmp = tail call i8 @llvm.ctlz.i8( i8 %x, i1 true )129 ret i8 %tmp130}131 132define i16 @t6(i16 %x) nounwind {133; X86-LABEL: t6:134; X86: # %bb.0:135; X86-NEXT: lzcntw {{[0-9]+}}(%esp), %ax136; X86-NEXT: retl137;138; X32-LABEL: t6:139; X32: # %bb.0:140; X32-NEXT: lzcntw %di, %ax141; X32-NEXT: retq142;143; X64-LABEL: t6:144; X64: # %bb.0:145; X64-NEXT: lzcntw %di, %ax146; X64-NEXT: retq147 %tmp = tail call i16 @llvm.ctlz.i16( i16 %x, i1 true )148 ret i16 %tmp149}150 151define i32 @t7(i32 %x) nounwind {152; X86-LABEL: t7:153; X86: # %bb.0:154; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax155; X86-NEXT: retl156;157; X32-LABEL: t7:158; X32: # %bb.0:159; X32-NEXT: lzcntl %edi, %eax160; X32-NEXT: retq161;162; X64-LABEL: t7:163; X64: # %bb.0:164; X64-NEXT: lzcntl %edi, %eax165; X64-NEXT: retq166 %tmp = tail call i32 @llvm.ctlz.i32( i32 %x, i1 true )167 ret i32 %tmp168}169 170define i64 @t8(i64 %x) nounwind {171; X86-LABEL: t8:172; X86: # %bb.0:173; X86-NEXT: movl {{[0-9]+}}(%esp), %eax174; X86-NEXT: testl %eax, %eax175; X86-NEXT: jne .LBB7_1176; X86-NEXT: # %bb.2:177; X86-NEXT: lzcntl {{[0-9]+}}(%esp), %eax178; X86-NEXT: addl $32, %eax179; X86-NEXT: xorl %edx, %edx180; X86-NEXT: retl181; X86-NEXT: .LBB7_1:182; X86-NEXT: lzcntl %eax, %eax183; X86-NEXT: xorl %edx, %edx184; X86-NEXT: retl185;186; X32-LABEL: t8:187; X32: # %bb.0:188; X32-NEXT: lzcntq %rdi, %rax189; X32-NEXT: retq190;191; X64-LABEL: t8:192; X64: # %bb.0:193; X64-NEXT: lzcntq %rdi, %rax194; X64-NEXT: retq195 %tmp = tail call i64 @llvm.ctlz.i64( i64 %x, i1 true )196 ret i64 %tmp197}198