1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,SI %s
2 ; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
4 declare i64 @llvm.amdgcn.icmp.i32(i32, i32, i32) #0
5 declare i64 @llvm.amdgcn.icmp.i64(i64, i64, i32) #0
6 declare i64 @llvm.amdgcn.icmp.i16(i16, i16, i32) #0
7 declare i64 @llvm.amdgcn.icmp.i1(i1, i1, i32) #0
9 ; GCN-LABEL: {{^}}v_icmp_i32_eq:
10 ; GCN: v_cmp_eq_u32_e64
11 define amdgpu_kernel void @v_icmp_i32_eq(i64 addrspace(1)* %out, i32 %src) {
12 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 32)
13 store i64 %result, i64 addrspace(1)* %out
17 ; GCN-LABEL: {{^}}v_icmp_i32:
18 ; GCN-NOT: v_cmp_eq_u32_e64
19 define amdgpu_kernel void @v_icmp_i32(i64 addrspace(1)* %out, i32 %src) {
20 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 30)
21 store i64 %result, i64 addrspace(1)* %out
25 ; GCN-LABEL: {{^}}v_icmp_i32_ne:
26 ; GCN: v_cmp_ne_u32_e64
27 define amdgpu_kernel void @v_icmp_i32_ne(i64 addrspace(1)* %out, i32 %src) {
28 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 33)
29 store i64 %result, i64 addrspace(1)* %out
33 ; GCN-LABEL: {{^}}v_icmp_i32_ugt:
34 ; GCN: v_cmp_gt_u32_e64
35 define amdgpu_kernel void @v_icmp_i32_ugt(i64 addrspace(1)* %out, i32 %src) {
36 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 34)
37 store i64 %result, i64 addrspace(1)* %out
41 ; GCN-LABEL: {{^}}v_icmp_i32_uge:
42 ; GCN: v_cmp_ge_u32_e64
43 define amdgpu_kernel void @v_icmp_i32_uge(i64 addrspace(1)* %out, i32 %src) {
44 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 35)
45 store i64 %result, i64 addrspace(1)* %out
49 ; GCN-LABEL: {{^}}v_icmp_i32_ult:
50 ; GCN: v_cmp_lt_u32_e64
51 define amdgpu_kernel void @v_icmp_i32_ult(i64 addrspace(1)* %out, i32 %src) {
52 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 36)
53 store i64 %result, i64 addrspace(1)* %out
57 ; GCN-LABEL: {{^}}v_icmp_i32_ule:
58 ; GCN: v_cmp_le_u32_e64
59 define amdgpu_kernel void @v_icmp_i32_ule(i64 addrspace(1)* %out, i32 %src) {
60 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 37)
61 store i64 %result, i64 addrspace(1)* %out
65 ; GCN-LABEL: {{^}}v_icmp_i32_sgt:
66 ; GCN: v_cmp_gt_i32_e64
67 define amdgpu_kernel void @v_icmp_i32_sgt(i64 addrspace(1)* %out, i32 %src) #1 {
68 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 38)
69 store i64 %result, i64 addrspace(1)* %out
73 ; GCN-LABEL: {{^}}v_icmp_i32_sge:
74 ; GCN: v_cmp_ge_i32_e64
75 define amdgpu_kernel void @v_icmp_i32_sge(i64 addrspace(1)* %out, i32 %src) {
76 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 39)
77 store i64 %result, i64 addrspace(1)* %out
81 ; GCN-LABEL: {{^}}v_icmp_i32_slt:
82 ; GCN: v_cmp_lt_i32_e64
83 define amdgpu_kernel void @v_icmp_i32_slt(i64 addrspace(1)* %out, i32 %src) {
84 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 40)
85 store i64 %result, i64 addrspace(1)* %out
88 ; GCN-LABEL: {{^}}v_icmp_i32_sle:
89 ; GCN: v_cmp_le_i32_e64
90 define amdgpu_kernel void @v_icmp_i32_sle(i64 addrspace(1)* %out, i32 %src) {
91 %result = call i64 @llvm.amdgcn.icmp.i32(i32 %src, i32 100, i32 41)
92 store i64 %result, i64 addrspace(1)* %out
96 ; GCN-LABEL: {{^}}v_icmp_i64_eq:
97 ; GCN: v_cmp_eq_u64_e64
98 define amdgpu_kernel void @v_icmp_i64_eq(i64 addrspace(1)* %out, i64 %src) {
99 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 32)
100 store i64 %result, i64 addrspace(1)* %out
104 ; GCN-LABEL: {{^}}v_icmp_i64_ne:
105 ; GCN: v_cmp_ne_u64_e64
106 define amdgpu_kernel void @v_icmp_i64_ne(i64 addrspace(1)* %out, i64 %src) {
107 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 33)
108 store i64 %result, i64 addrspace(1)* %out
112 ; GCN-LABEL: {{^}}v_icmp_u64_ugt:
113 ; GCN: v_cmp_gt_u64_e64
114 define amdgpu_kernel void @v_icmp_u64_ugt(i64 addrspace(1)* %out, i64 %src) {
115 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 34)
116 store i64 %result, i64 addrspace(1)* %out
120 ; GCN-LABEL: {{^}}v_icmp_u64_uge:
121 ; GCN: v_cmp_ge_u64_e64
122 define amdgpu_kernel void @v_icmp_u64_uge(i64 addrspace(1)* %out, i64 %src) {
123 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 35)
124 store i64 %result, i64 addrspace(1)* %out
128 ; GCN-LABEL: {{^}}v_icmp_u64_ult:
129 ; GCN: v_cmp_lt_u64_e64
130 define amdgpu_kernel void @v_icmp_u64_ult(i64 addrspace(1)* %out, i64 %src) {
131 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 36)
132 store i64 %result, i64 addrspace(1)* %out
136 ; GCN-LABEL: {{^}}v_icmp_u64_ule:
137 ; GCN: v_cmp_le_u64_e64
138 define amdgpu_kernel void @v_icmp_u64_ule(i64 addrspace(1)* %out, i64 %src) {
139 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 37)
140 store i64 %result, i64 addrspace(1)* %out
144 ; GCN-LABEL: {{^}}v_icmp_i64_sgt:
145 ; GCN: v_cmp_gt_i64_e64
146 define amdgpu_kernel void @v_icmp_i64_sgt(i64 addrspace(1)* %out, i64 %src) {
147 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 38)
148 store i64 %result, i64 addrspace(1)* %out
152 ; GCN-LABEL: {{^}}v_icmp_i64_sge:
153 ; GCN: v_cmp_ge_i64_e64
154 define amdgpu_kernel void @v_icmp_i64_sge(i64 addrspace(1)* %out, i64 %src) {
155 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 39)
156 store i64 %result, i64 addrspace(1)* %out
160 ; GCN-LABEL: {{^}}v_icmp_i64_slt:
161 ; GCN: v_cmp_lt_i64_e64
162 define amdgpu_kernel void @v_icmp_i64_slt(i64 addrspace(1)* %out, i64 %src) {
163 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 40)
164 store i64 %result, i64 addrspace(1)* %out
167 ; GCN-LABEL: {{^}}v_icmp_i64_sle:
168 ; GCN: v_cmp_le_i64_e64
169 define amdgpu_kernel void @v_icmp_i64_sle(i64 addrspace(1)* %out, i64 %src) {
170 %result = call i64 @llvm.amdgcn.icmp.i64(i64 %src, i64 100, i32 41)
171 store i64 %result, i64 addrspace(1)* %out
175 ; VI: v_cmp_eq_u16_e64
177 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
178 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
179 ; SI: v_cmp_eq_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
180 define amdgpu_kernel void @v_icmp_i16_eq(i64 addrspace(1)* %out, i16 %src) {
181 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 32)
182 store i64 %result, i64 addrspace(1)* %out
186 ; GCN-LABEL: {{^}}v_icmp_i16:
188 define amdgpu_kernel void @v_icmp_i16(i64 addrspace(1)* %out, i16 %src) {
189 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 30)
190 store i64 %result, i64 addrspace(1)* %out
193 ; GCN-LABEL: {{^}}v_icmp_i16_ne:
194 ; VI: v_cmp_ne_u16_e64
196 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
197 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
198 ; SI: v_cmp_ne_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
199 define amdgpu_kernel void @v_icmp_i16_ne(i64 addrspace(1)* %out, i16 %src) {
200 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 33)
201 store i64 %result, i64 addrspace(1)* %out
205 ; GCN-LABEL: {{^}}v_icmp_i16_ugt:
206 ; VI: v_cmp_gt_u16_e64
208 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
209 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
210 ; SI: v_cmp_gt_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
211 define amdgpu_kernel void @v_icmp_i16_ugt(i64 addrspace(1)* %out, i16 %src) {
212 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 34)
213 store i64 %result, i64 addrspace(1)* %out
217 ; GCN-LABEL: {{^}}v_icmp_i16_uge:
218 ; VI: v_cmp_ge_u16_e64
220 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
221 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
222 ; SI: v_cmp_ge_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
223 define amdgpu_kernel void @v_icmp_i16_uge(i64 addrspace(1)* %out, i16 %src) {
224 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 35)
225 store i64 %result, i64 addrspace(1)* %out
229 ; GCN-LABEL: {{^}}v_icmp_i16_ult:
230 ; VI: v_cmp_lt_u16_e64
232 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
233 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
234 ; SI: v_cmp_lt_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
235 define amdgpu_kernel void @v_icmp_i16_ult(i64 addrspace(1)* %out, i16 %src) {
236 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 36)
237 store i64 %result, i64 addrspace(1)* %out
241 ; GCN-LABEL: {{^}}v_icmp_i16_ule:
242 ; VI: v_cmp_le_u16_e64
244 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
245 ; SI-DAG: s_and_b32 [[CVT:s[0-9]+]], s{{[0-9]+}}, 0xffff{{$}}
246 ; SI: v_cmp_le_u32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
247 define amdgpu_kernel void @v_icmp_i16_ule(i64 addrspace(1)* %out, i16 %src) {
248 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 37)
249 store i64 %result, i64 addrspace(1)* %out
253 ; GCN-LABEL: {{^}}v_icmp_i16_sgt:
254 ; VI: v_cmp_gt_i16_e64
256 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
257 ; SI-DAG: s_sext_i32_i16 [[CVT:s[0-9]+]], s{{[0-9]+}}
258 ; SI: v_cmp_gt_i32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
259 define amdgpu_kernel void @v_icmp_i16_sgt(i64 addrspace(1)* %out, i16 %src) #1 {
260 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 38)
261 store i64 %result, i64 addrspace(1)* %out
265 ; GCN-LABEL: {{^}}v_icmp_i16_sge:
266 ; VI: v_cmp_ge_i16_e64
268 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
269 ; SI-DAG: s_sext_i32_i16 [[CVT:s[0-9]+]], s{{[0-9]+}}
270 ; SI: v_cmp_ge_i32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
271 define amdgpu_kernel void @v_icmp_i16_sge(i64 addrspace(1)* %out, i16 %src) {
272 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 39)
273 store i64 %result, i64 addrspace(1)* %out
277 ; GCN-LABEL: {{^}}v_icmp_i16_slt:
278 ; VI: v_cmp_lt_i16_e64
280 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
281 ; SI-DAG: s_sext_i32_i16 [[CVT:s[0-9]+]], s{{[0-9]+}}
282 ; SI: v_cmp_lt_i32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
283 define amdgpu_kernel void @v_icmp_i16_slt(i64 addrspace(1)* %out, i16 %src) {
284 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 40)
285 store i64 %result, i64 addrspace(1)* %out
288 ; GCN-LABEL: {{^}}v_icmp_i16_sle:
289 ; VI: v_cmp_le_i16_e64
291 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x64
292 ; SI-DAG: s_sext_i32_i16 [[CVT:s[0-9]+]], s{{[0-9]+}}
293 ; SI: v_cmp_le_i32_e64 s{{\[[0-9]+:[0-9]+\]}}, [[CVT]], [[K]]
294 define amdgpu_kernel void @v_icmp_i16_sle(i64 addrspace(1)* %out, i16 %src) {
295 %result = call i64 @llvm.amdgcn.icmp.i16(i16 %src, i16 100, i32 41)
296 store i64 %result, i64 addrspace(1)* %out
300 ; GCN-LABEL: {{^}}v_icmp_i1_ne0:
301 ; GCN: v_cmp_gt_u32_e64 s[[C0:\[[0-9]+:[0-9]+\]]],
302 ; GCN: v_cmp_gt_u32_e64 s[[C1:\[[0-9]+:[0-9]+\]]],
303 ; GCN: s_and_b64 s[[SRC:\[[0-9]+:[0-9]+\]]], s[[C0]], s[[C1]]
304 ; SI-NEXT: s_mov_b32 s{{[0-9]+}}, -1
305 ; GCN-NEXT: v_mov_b32_e32
306 ; GCN-NEXT: v_mov_b32_e32
307 ; GCN-NEXT: {{global|flat|buffer}}_store_dwordx2
308 define amdgpu_kernel void @v_icmp_i1_ne0(i64 addrspace(1)* %out, i32 %a, i32 %b) {
309 %c0 = icmp ugt i32 %a, 1
310 %c1 = icmp ugt i32 %b, 2
311 %src = and i1 %c0, %c1
312 %result = call i64 @llvm.amdgcn.icmp.i1(i1 %src, i1 false, i32 33)
313 store i64 %result, i64 addrspace(1)* %out
317 attributes #0 = { nounwind readnone convergent }