1; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2
3; SI-LABEL: {{^}}s_clear_msb:
4; SI: s_bitset0_b32 s{{[0-9]+}}, 31
5define amdgpu_kernel void @s_clear_msb(i32 addrspace(1)* %out, i32 %in) {
6  %x = and i32 %in, 2147483647
7  store i32 %x, i32 addrspace(1)* %out
8  ret void
9}
10
11; SI-LABEL: {{^}}s_set_msb:
12; SI: s_bitset1_b32 s{{[0-9]+}}, 31
13define amdgpu_kernel void @s_set_msb(i32 addrspace(1)* %out, i32 %in) {
14  %x = or i32 %in, 2147483648
15  store i32 %x, i32 addrspace(1)* %out
16  ret void
17}
18
19; SI-LABEL: {{^}}s_clear_lsb:
20; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, -2
21define amdgpu_kernel void @s_clear_lsb(i32 addrspace(1)* %out, i32 %in) {
22  %x = and i32 %in, 4294967294
23  store i32 %x, i32 addrspace(1)* %out
24  ret void
25}
26
27; SI-LABEL: {{^}}s_set_lsb:
28; SI: s_or_b32 s{{[0-9]+}}, s{{[0-9]+}}, 1
29define amdgpu_kernel void @s_set_lsb(i32 addrspace(1)* %out, i32 %in) {
30  %x = or i32 %in, 1
31  store i32 %x, i32 addrspace(1)* %out
32  ret void
33}
34
35; SI-LABEL: {{^}}s_clear_midbit:
36; SI: s_bitset0_b32 s{{[0-9]+}}, 8
37define amdgpu_kernel void @s_clear_midbit(i32 addrspace(1)* %out, i32 %in) {
38  %x = and i32 %in, 4294967039
39  store i32 %x, i32 addrspace(1)* %out
40  ret void
41}
42
43; SI-LABEL: {{^}}s_set_midbit:
44; SI: s_bitset1_b32 s{{[0-9]+}}, 8
45define amdgpu_kernel void @s_set_midbit(i32 addrspace(1)* %out, i32 %in) {
46  %x = or i32 %in, 256
47  store i32 %x, i32 addrspace(1)* %out
48  ret void
49}
50
51; Make sure there's no verifier error with an undef source.
52; SI-LABEL: {{^}}bitset_verifier_error:
53; SI: s_bitset0_b32 s{{[0-9]+}}, 31
54define void @bitset_verifier_error() local_unnamed_addr #0 {
55bb:
56  %i = call float @llvm.fabs.f32(float undef) #0
57  %i1 = bitcast float %i to i32
58  br label %bb2
59
60bb2:
61  %i3 = call float @llvm.fabs.f32(float undef) #0
62  %i4 = fcmp fast ult float %i3, 0x3FEFF7CEE0000000
63  br i1 %i4, label %bb5, label %bb6
64
65bb5:
66  unreachable
67
68bb6:
69  unreachable
70}
71
72declare float @llvm.fabs.f32(float) #0
73
74attributes #0 = { nounwind readnone speculatable willreturn }
75