• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4declare i64 @llvm.ctpop.i64(i64) nounwind readnone
5
6define i32 @test1(i64 %x) nounwind readnone {
7; CHECK-LABEL: test1:
8; CHECK:       # BB#0:
9; CHECK-NEXT:    leaq -1(%rdi), %rcx
10; CHECK-NEXT:    xorl %eax, %eax
11; CHECK-NEXT:    testq %rcx, %rdi
12; CHECK-NEXT:    setne %al
13; CHECK-NEXT:    retq
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
18  ret i32 %conv
19}
20
21
22define i32 @test2(i64 %x) nounwind readnone {
23; CHECK-LABEL: test2:
24; CHECK:       # BB#0:
25; CHECK-NEXT:    leaq -1(%rdi), %rcx
26; CHECK-NEXT:    xorl %eax, %eax
27; CHECK-NEXT:    testq %rcx, %rdi
28; CHECK-NEXT:    sete %al
29; CHECK-NEXT:    retq
30  %count = tail call i64 @llvm.ctpop.i64(i64 %x)
31  %cmp = icmp ult i64 %count, 2
32  %conv = zext i1 %cmp to i32
33  ret i32 %conv
34}
35
36define i32 @test3(i64 %x) nounwind readnone {
37; CHECK-LABEL: test3:
38; CHECK:       # BB#0:
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
44; CHECK-NEXT:    retq
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
49  ret i32 %conv
50}
51