1 ; RUN: opt < %s -S -instcombine | FileCheck %s
3 declare i32 @llvm.ctpop.i32(i32)
4 declare i8 @llvm.ctpop.i8(i8)
5 declare void @llvm.assume(i1)
7 define i1 @test1(i32 %arg) {
10 %and = and i32 %arg, 15
11 %cnt = call i32 @llvm.ctpop.i32(i32 %and)
12 %res = icmp eq i32 %cnt, 9
16 define i1 @test2(i32 %arg) {
19 %and = and i32 %arg, 1
20 %cnt = call i32 @llvm.ctpop.i32(i32 %and)
21 %res = icmp eq i32 %cnt, 2
25 define i1 @test3(i32 %arg) {
28 ;; Use an assume to make all the bits known without triggering constant
29 ;; folding. This is trying to hit a corner case where we have to avoid
30 ;; taking the log of 0.
31 %assume = icmp eq i32 %arg, 0
32 call void @llvm.assume(i1 %assume)
33 %cnt = call i32 @llvm.ctpop.i32(i32 %arg)
34 %res = icmp eq i32 %cnt, 2
38 ; Negative test for when we know nothing
39 define i1 @test4(i8 %arg) {
42 %cnt = call i8 @llvm.ctpop.i8(i8 %arg)
43 %res = icmp eq i8 %cnt, 2