1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
4 ; Extract the high bit of the 1st quarter
5 define amdgpu_kernel void @v_uextract_bit_31_i128(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
6 ; GCN-LABEL: v_uextract_bit_31_i128:
8 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
9 ; GCN-NEXT: s_ashr_i32 s3, s2, 31
10 ; GCN-NEXT: s_lshl_b64 s[0:1], s[2:3], 4
11 ; GCN-NEXT: v_mov_b32_e32 v5, s1
12 ; GCN-NEXT: s_mov_b32 s11, 0xf000
13 ; GCN-NEXT: s_mov_b32 s10, 0
14 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
15 ; GCN-NEXT: s_mov_b64 s[8:9], s[6:7]
16 ; GCN-NEXT: v_mov_b32_e32 v4, s0
17 ; GCN-NEXT: buffer_load_dword v0, v[4:5], s[8:11], 0 addr64
18 ; GCN-NEXT: v_mov_b32_e32 v1, 0
19 ; GCN-NEXT: v_mov_b32_e32 v2, v1
20 ; GCN-NEXT: s_mov_b64 s[6:7], s[10:11]
21 ; GCN-NEXT: v_mov_b32_e32 v3, v1
22 ; GCN-NEXT: s_waitcnt vmcnt(0)
23 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 31, v0
24 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[4:7], 0 addr64
26 %id.x = tail call i32 @llvm.amdgcn.workgroup.id.x()
27 %in.gep = getelementptr i128, ptr addrspace(1) %in, i32 %id.x
28 %out.gep = getelementptr i128, ptr addrspace(1) %out, i32 %id.x
29 %ld.64 = load i128, ptr addrspace(1) %in.gep
30 %srl = lshr i128 %ld.64, 31
31 %bit = and i128 %srl, 1
32 store i128 %bit, ptr addrspace(1) %out.gep
36 ; Extract the high bit of the 2nd quarter
37 define amdgpu_kernel void @v_uextract_bit_63_i128(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
38 ; GCN-LABEL: v_uextract_bit_63_i128:
40 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
41 ; GCN-NEXT: s_mov_b32 s7, 0xf000
42 ; GCN-NEXT: s_mov_b32 s6, 0
43 ; GCN-NEXT: v_lshlrev_b32_e32 v4, 4, v0
44 ; GCN-NEXT: v_mov_b32_e32 v5, 0
45 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
46 ; GCN-NEXT: s_mov_b64 s[8:9], s[2:3]
47 ; GCN-NEXT: s_mov_b64 s[10:11], s[6:7]
48 ; GCN-NEXT: buffer_load_dword v0, v[4:5], s[8:11], 0 addr64 offset:4
49 ; GCN-NEXT: v_mov_b32_e32 v1, v5
50 ; GCN-NEXT: v_mov_b32_e32 v2, v5
51 ; GCN-NEXT: s_mov_b64 s[4:5], s[0:1]
52 ; GCN-NEXT: v_mov_b32_e32 v3, v5
53 ; GCN-NEXT: s_waitcnt vmcnt(0)
54 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 31, v0
55 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[4:7], 0 addr64
57 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
58 %in.gep = getelementptr i128, ptr addrspace(1) %in, i32 %id.x
59 %out.gep = getelementptr i128, ptr addrspace(1) %out, i32 %id.x
60 %ld.64 = load i128, ptr addrspace(1) %in.gep
61 %srl = lshr i128 %ld.64, 63
62 %bit = and i128 %srl, 1
63 store i128 %bit, ptr addrspace(1) %out.gep
67 ; Extract the high bit of the 3rd quarter
68 define amdgpu_kernel void @v_uextract_bit_95_i128(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
69 ; GCN-LABEL: v_uextract_bit_95_i128:
71 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
72 ; GCN-NEXT: s_ashr_i32 s3, s2, 31
73 ; GCN-NEXT: s_lshl_b64 s[0:1], s[2:3], 4
74 ; GCN-NEXT: s_mov_b32 s3, 0xf000
75 ; GCN-NEXT: s_mov_b32 s2, 0
76 ; GCN-NEXT: v_mov_b32_e32 v5, s1
77 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
78 ; GCN-NEXT: s_mov_b64 s[8:9], s[6:7]
79 ; GCN-NEXT: s_mov_b64 s[10:11], s[2:3]
80 ; GCN-NEXT: v_mov_b32_e32 v4, s0
81 ; GCN-NEXT: buffer_load_dword v0, v[4:5], s[8:11], 0 addr64 offset:8
82 ; GCN-NEXT: v_mov_b32_e32 v1, 0
83 ; GCN-NEXT: v_mov_b32_e32 v2, v1
84 ; GCN-NEXT: s_mov_b64 s[0:1], s[4:5]
85 ; GCN-NEXT: v_mov_b32_e32 v3, v1
86 ; GCN-NEXT: s_waitcnt vmcnt(0)
87 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 31, v0
88 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[0:3], 0 addr64
90 %id.x = tail call i32 @llvm.amdgcn.workgroup.id.x()
91 %in.gep = getelementptr i128, ptr addrspace(1) %in, i32 %id.x
92 %out.gep = getelementptr i128, ptr addrspace(1) %out, i32 %id.x
93 %ld.64 = load i128, ptr addrspace(1) %in.gep
94 %srl = lshr i128 %ld.64, 95
95 %bit = and i128 %srl, 1
96 store i128 %bit, ptr addrspace(1) %out.gep
100 ; Extract the high bit of the 4th quarter
101 define amdgpu_kernel void @v_uextract_bit_127_i128(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
102 ; GCN-LABEL: v_uextract_bit_127_i128:
104 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
105 ; GCN-NEXT: s_mov_b32 s7, 0xf000
106 ; GCN-NEXT: s_mov_b32 s6, 0
107 ; GCN-NEXT: v_lshlrev_b32_e32 v4, 4, v0
108 ; GCN-NEXT: v_mov_b32_e32 v5, 0
109 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
110 ; GCN-NEXT: s_mov_b64 s[8:9], s[2:3]
111 ; GCN-NEXT: s_mov_b64 s[10:11], s[6:7]
112 ; GCN-NEXT: buffer_load_dword v0, v[4:5], s[8:11], 0 addr64 offset:12
113 ; GCN-NEXT: v_mov_b32_e32 v1, v5
114 ; GCN-NEXT: v_mov_b32_e32 v2, v5
115 ; GCN-NEXT: s_mov_b64 s[4:5], s[0:1]
116 ; GCN-NEXT: v_mov_b32_e32 v3, v5
117 ; GCN-NEXT: s_waitcnt vmcnt(0)
118 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 31, v0
119 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[4:7], 0 addr64
121 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
122 %in.gep = getelementptr i128, ptr addrspace(1) %in, i32 %id.x
123 %out.gep = getelementptr i128, ptr addrspace(1) %out, i32 %id.x
124 %ld.64 = load i128, ptr addrspace(1) %in.gep
125 %srl = lshr i128 %ld.64, 127
126 %bit = and i128 %srl, 1
127 store i128 %bit, ptr addrspace(1) %out.gep
131 ; Spans more than 2 dword boundaries
132 define amdgpu_kernel void @v_uextract_bit_34_100_i128(ptr addrspace(1) %out, ptr addrspace(1) %in) #1 {
133 ; GCN-LABEL: v_uextract_bit_34_100_i128:
135 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
136 ; GCN-NEXT: s_mov_b32 s7, 0xf000
137 ; GCN-NEXT: s_mov_b32 s6, 0
138 ; GCN-NEXT: v_lshlrev_b32_e32 v8, 4, v0
139 ; GCN-NEXT: v_mov_b32_e32 v9, 0
140 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
141 ; GCN-NEXT: s_mov_b64 s[4:5], s[2:3]
142 ; GCN-NEXT: buffer_load_dwordx4 v[0:3], v[8:9], s[4:7], 0 addr64
143 ; GCN-NEXT: s_mov_b64 s[2:3], s[6:7]
144 ; GCN-NEXT: v_mov_b32_e32 v7, v9
145 ; GCN-NEXT: s_waitcnt vmcnt(0)
146 ; GCN-NEXT: v_lshl_b64 v[4:5], v[2:3], 30
147 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 2, v1
148 ; GCN-NEXT: v_bfe_u32 v6, v3, 2, 2
149 ; GCN-NEXT: v_or_b32_e32 v4, v0, v4
150 ; GCN-NEXT: buffer_store_dwordx4 v[4:7], v[8:9], s[0:3], 0 addr64
152 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
153 %in.gep = getelementptr i128, ptr addrspace(1) %in, i32 %id.x
154 %out.gep = getelementptr i128, ptr addrspace(1) %out, i32 %id.x
155 %ld.64 = load i128, ptr addrspace(1) %in.gep
156 %srl = lshr i128 %ld.64, 34
157 %bit = and i128 %srl, 73786976294838206463
158 store i128 %bit, ptr addrspace(1) %out.gep
162 declare i32 @llvm.amdgcn.workitem.id.x() #0
164 declare i32 @llvm.amdgcn.workgroup.id.x() #0
166 attributes #0 = { nounwind readnone }
167 attributes #1 = { nounwind }