1 ; RUN: opt < %s -S -instcombine | FileCheck %s
3 declare i8 @llvm.bitreverse.i8(i8)
4 declare i32 @llvm.bitreverse.i32(i32)
8 define i1 @test1(i32 %arg) {
9 %a = or i32 %arg, 4294901760
10 %b = call i32 @llvm.bitreverse.i32(i32 %a)
11 %and = and i32 %b, 65535
12 %res = icmp eq i32 %and, 65535
18 define i1 @test2(i32 %arg) {
20 %b = call i32 @llvm.bitreverse.i32(i32 %a)
21 %c = and i32 %b, 2147483648
22 %d = call i32 @llvm.bitreverse.i32(i32 %c)
23 %res = icmp eq i32 %d, 1
29 define i1 @test3(i32 %arg) {
30 %a = or i32 %arg, 65536
31 %b = call i32 @llvm.bitreverse.i32(i32 %a)
32 %and = and i32 %b, 32768
33 %res = icmp eq i32 %and, 0
37 ; CHECK-LABEL: @add_bitreverse
38 ; Make sure we process range metadata on bitreverse
39 define i8 @add_bitreverse(i8 %a) {
41 ; known bits for the bitreverse will say the result is in the range [0, 64)
42 ; but the metadata says [0, 16). So make sure the range metadata wins.
43 ; add %reverse, 1111 0000
45 ; or %reverse, 1111 0000
46 %reverse = call i8 @llvm.bitreverse.i8(i8 %b), !range !1
47 %c = add i8 %reverse, -16
48 ; CHECK: or i8 %reverse, -16