1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=corei7 | FileCheck %s
4 declare i8 @llvm.ctpop.i8(i8) nounwind readnone
5 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
7 define i32 @test1(i64 %x) nounwind readnone {
10 ; CHECK-NEXT: leaq -1(%rdi), %rcx
11 ; CHECK-NEXT: xorl %eax, %eax
12 ; CHECK-NEXT: testq %rcx, %rdi
13 ; CHECK-NEXT: setne %al
15 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
16 %cast = trunc i64 %count to i32
17 %cmp = icmp ugt i32 %cast, 1
18 %conv = zext i1 %cmp to i32
23 define i32 @test2(i64 %x) nounwind readnone {
26 ; CHECK-NEXT: leaq -1(%rdi), %rcx
27 ; CHECK-NEXT: xorl %eax, %eax
28 ; CHECK-NEXT: testq %rcx, %rdi
29 ; CHECK-NEXT: sete %al
31 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
32 %cmp = icmp ult i64 %count, 2
33 %conv = zext i1 %cmp to i32
37 define i32 @test3(i64 %x) nounwind readnone {
40 ; CHECK-NEXT: popcntq %rdi, %rcx
41 ; CHECK-NEXT: andb $63, %cl
42 ; CHECK-NEXT: xorl %eax, %eax
43 ; CHECK-NEXT: cmpb $2, %cl
44 ; CHECK-NEXT: setb %al
46 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
47 %cast = trunc i64 %count to i6 ; Too small for 0-64
48 %cmp = icmp ult i6 %cast, 2
49 %conv = zext i1 %cmp to i32
53 define i8 @test4(i8 %x) nounwind readnone {
56 ; CHECK-NEXT: andl $127, %edi
57 ; CHECK-NEXT: popcntl %edi, %eax
58 ; CHECK-NEXT: # kill: def $al killed $al killed $eax
61 %count = tail call i8 @llvm.ctpop.i8(i8 %x2)
62 %and = and i8 %count, 7