blob: b87637f9424fc6de6950d0d65e5ca29b7d7231e4 [file] [log] [blame]
Benjamin Kramerd8228922011-01-17 12:04:57 +00001; RUN: llc -march=x86-64 < %s | FileCheck %s
2
3declare i64 @llvm.ctpop.i64(i64) nounwind readnone
4
5define i32 @test1(i64 %x) nounwind readnone {
6 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
7 %cast = trunc i64 %count to i32
8 %cmp = icmp ugt i32 %cast, 1
9 %conv = zext i1 %cmp to i32
10 ret i32 %conv
11; CHECK: test1:
12; CHECK: leaq -1(%rdi)
13; CHECK-NEXT: testq
14; CHECK-NEXT: setne
15; CHECK: ret
16}
17
18
19define i32 @test2(i64 %x) nounwind readnone {
20 %count = tail call i64 @llvm.ctpop.i64(i64 %x)
21 %cast = trunc i64 %count to i32
22 %cmp = icmp ult i32 %cast, 2
23 %conv = zext i1 %cmp to i32
24 ret i32 %conv
25; CHECK: test2:
26; CHECK: leaq -1(%rdi)
27; CHECK-NEXT: testq
28; CHECK-NEXT: sete
29; CHECK: ret
30}
31