OSDN Git Service

Add a DAGCombine to turn (ctpop x) u< 2 into (x & x-1) == 0.
[android-x86/external-llvm.git] / test / CodeGen / X86 / ctpop-combine.ll
1 ; RUN: llc -march=x86-64 < %s | FileCheck %s
2
3 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
4
5 define 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
19 define 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