1; RUN: opt -S -lowerbitsets < %s | FileCheck %s
2
3target datalayout = "e-p:32:32"
4
5; CHECK: [[G:@[^ ]*]] = private constant { i32, [0 x i8], i32 }
6@a = constant i32 1
7@b = constant i32 2
8
9!0 = !{!"bitset1", i32* @a, i32 0}
10!1 = !{!"bitset1", i32* @b, i32 0}
11!2 = !{!"bitset2", i32* @a, i32 0}
12!3 = !{!"bitset3", i32* @b, i32 0}
13
14!llvm.bitsets = !{ !0, !1, !2, !3 }
15
16declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone
17
18; CHECK: @foo(i8* [[A0:%[^ ]*]])
19define i1 @foo(i8* %p) {
20  ; CHECK: [[R0:%[^ ]*]] = ptrtoint i8* [[A0]] to i32
21  ; CHECK: [[R1:%[^ ]*]] = icmp eq i32 [[R0]], ptrtoint ({ i32, [0 x i8], i32 }* [[G]] to i32)
22  %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset2")
23  ; CHECK: ret i1 [[R1]]
24  ret i1 %x
25}
26
27; CHECK: @bar(i8* [[B0:%[^ ]*]])
28define i1 @bar(i8* %p) {
29  ; CHECK: [[S0:%[^ ]*]] = ptrtoint i8* [[B0]] to i32
30  ; CHECK: [[S1:%[^ ]*]] = icmp eq i32 [[S0]], add (i32 ptrtoint ({ i32, [0 x i8], i32 }* [[G]] to i32), i32 4)
31  %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset3")
32  ; CHECK: ret i1 [[S1]]
33  ret i1 %x
34}
35
36; CHECK: @x(
37define i1 @x(i8* %p) {
38  %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset1")
39  ret i1 %x
40}
41