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 i64 @llvm.ctpop.i64(i64) nounwind readnone
6 define i32 @test1(i64 %x) nounwind readnone {
9 ; CHECK-NEXT: leaq -1(%rdi), %rcx
10 ; CHECK-NEXT: xorl %eax, %eax
11 ; CHECK-NEXT: testq %rcx, %rdi
12 ; CHECK-NEXT: setne %al
14 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
15 %cast = trunc i64 %count to i32
16 %cmp = icmp ugt i32 %cast, 1
17 %conv = zext i1 %cmp to i32
22 define i32 @test2(i64 %x) nounwind readnone {
25 ; CHECK-NEXT: leaq -1(%rdi), %rcx
26 ; CHECK-NEXT: xorl %eax, %eax
27 ; CHECK-NEXT: testq %rcx, %rdi
28 ; CHECK-NEXT: sete %al
30 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
31 %cmp = icmp ult i64 %count, 2
32 %conv = zext i1 %cmp to i32
36 define i32 @test3(i64 %x) nounwind readnone {
39 ; CHECK-NEXT: popcntq %rdi, %rax
40 ; CHECK-NEXT: andb $63, %al
41 ; CHECK-NEXT: cmpb $2, %al
42 ; CHECK-NEXT: sbbl %eax, %eax
43 ; CHECK-NEXT: andl $1, %eax
45 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
46 %cast = trunc i64 %count to i6 ; Too small for 0-64
47 %cmp = icmp ult i6 %cast, 2
48 %conv = zext i1 %cmp to i32