1; RUN: llc < %s | FileCheck %s
2; RUN: llc -relocation-model=pic < %s | FileCheck %s
3
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7@bit_mask8 = external hidden global i8, !absolute_symbol !0
8@bit_mask32 = external hidden global i8, !absolute_symbol !1
9@bit_mask64 = external hidden global i8, !absolute_symbol !2
10
11declare void @f()
12
13define void @foo8(i8* %ptr) {
14  %load = load i8, i8* %ptr
15  ; CHECK: testb $bit_mask8, (%rdi)
16  %and = and i8 %load, ptrtoint (i8* @bit_mask8 to i8)
17  %icmp = icmp eq i8 %and, 0
18  br i1 %icmp, label %t, label %f
19
20t:
21  call void @f()
22  ret void
23
24f:
25  ret void
26}
27
28define void @foo32(i32* %ptr) {
29  %load = load i32, i32* %ptr
30  ; CHECK: testl $bit_mask32, (%rdi)
31  %and = and i32 %load, ptrtoint (i8* @bit_mask32 to i32)
32  %icmp = icmp eq i32 %and, 0
33  br i1 %icmp, label %t, label %f
34
35t:
36  call void @f()
37  ret void
38
39f:
40  ret void
41}
42
43define void @foo64(i64* %ptr) {
44  %load = load i64, i64* %ptr
45  ; CHECK: movabsq $bit_mask64, %rax
46  ; CHECK: testq %rax, (%rdi)
47  %and = and i64 %load, ptrtoint (i8* @bit_mask64 to i64)
48  %icmp = icmp eq i64 %and, 0
49  br i1 %icmp, label %t, label %f
50
51t:
52  call void @f()
53  ret void
54
55f:
56  ret void
57}
58
59!0 = !{i64 0, i64 256}
60!1 = !{i64 0, i64 4294967296}
61!2 = !{i64 -1, i64 -1}
62