blob: 8ebf289eb7d7bea0caa19bdd0277d7e4e79f1d4d [file] [log] [blame]
Reid Spencera3bc8502007-04-02 01:45:31 +00001; Tests to make sure bit counts of constants are folded
Reid Spencer91948d42007-04-14 20:13:02 +00002; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 19}
3; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
4; RUN: grep -v declare | not grep llvm.ct
Reid Spencera3bc8502007-04-02 01:45:31 +00005
Chandler Carruth7132e002007-08-04 01:51:18 +00006declare i31 @llvm.ctpop.i31(i31 %val)
Reid Spencera3bc8502007-04-02 01:45:31 +00007declare i32 @llvm.cttz.i32(i32 %val)
Chandler Carruth7132e002007-08-04 01:51:18 +00008declare i33 @llvm.ctlz.i33(i33 %val)
Reid Spencera3bc8502007-04-02 01:45:31 +00009
Reid Spencere51961b2007-04-02 03:24:47 +000010define i32 @test(i32 %A) {
Chandler Carruth7132e002007-08-04 01:51:18 +000011 %c1 = call i31 @llvm.ctpop.i31(i31 12415124)
Reid Spencere51961b2007-04-02 03:24:47 +000012 %c2 = call i32 @llvm.cttz.i32(i32 87359874)
Chandler Carruth7132e002007-08-04 01:51:18 +000013 %c3 = call i33 @llvm.ctlz.i33(i33 87359874)
14 %t1 = zext i31 %c1 to i32
15 %t3 = trunc i33 %c3 to i32
16 %r1 = add i32 %t1, %c2
17 %r2 = add i32 %r1, %t3
Reid Spencera3bc8502007-04-02 01:45:31 +000018 ret i32 %r2
19}