1 ; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
5 declare i32 @llvm.r600.read.tidig.x() #0
7 ; FUNC-LABEL: {{^}}test2:
8 ; EG: AND_INT {{\*? *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
9 ; EG: AND_INT {{\*? *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
11 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
12 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
14 define amdgpu_kernel void @test2(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
15 %b_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1
16 %a = load <2 x i32>, <2 x i32> addrspace(1) * %in
17 %b = load <2 x i32>, <2 x i32> addrspace(1) * %b_ptr
18 %result = and <2 x i32> %a, %b
19 store <2 x i32> %result, <2 x i32> addrspace(1)* %out
23 ; FUNC-LABEL: {{^}}test4:
24 ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
25 ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
26 ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
27 ; EG: AND_INT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
30 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
31 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
32 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
33 ; SI: s_and_b32 s{{[0-9]+, s[0-9]+, s[0-9]+}}
35 define amdgpu_kernel void @test4(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
36 %b_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1
37 %a = load <4 x i32>, <4 x i32> addrspace(1) * %in
38 %b = load <4 x i32>, <4 x i32> addrspace(1) * %b_ptr
39 %result = and <4 x i32> %a, %b
40 store <4 x i32> %result, <4 x i32> addrspace(1)* %out
44 ; FUNC-LABEL: {{^}}s_and_i32:
46 define amdgpu_kernel void @s_and_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) {
48 store i32 %and, i32 addrspace(1)* %out, align 4
52 ; FUNC-LABEL: {{^}}s_and_constant_i32:
53 ; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x12d687
54 define amdgpu_kernel void @s_and_constant_i32(i32 addrspace(1)* %out, i32 %a) {
55 %and = and i32 %a, 1234567
56 store i32 %and, i32 addrspace(1)* %out, align 4
60 ; FIXME: We should really duplicate the constant so that the SALU use
61 ; can fold into the s_and_b32 and the VALU one is materialized
62 ; directly without copying from the SGPR.
64 ; Second use is a VGPR use of the constant.
65 ; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_0:
66 ; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687
67 ; SI-DAG: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]]
68 ; SI-DAG: v_mov_b32_e32 [[VK:v[0-9]+]], [[K]]
69 ; SI: buffer_store_dword [[VK]]
70 define amdgpu_kernel void @s_and_multi_use_constant_i32_0(i32 addrspace(1)* %out, i32 %a, i32 %b) {
71 %and = and i32 %a, 1234567
73 ; Just to stop future replacement of copy to vgpr + store with VALU op.
74 %foo = add i32 %and, %b
75 store volatile i32 %foo, i32 addrspace(1)* %out
76 store volatile i32 1234567, i32 addrspace(1)* %out
80 ; Second use is another SGPR use of the constant.
81 ; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_1:
82 ; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687
83 ; SI: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]]
85 ; SI: s_add_i32 [[ADD:s[0-9]+]], s{{[0-9]+}}, [[K]]
86 ; SI: v_mov_b32_e32 [[VADD:v[0-9]+]], [[ADD]]
87 ; SI: buffer_store_dword [[VADD]]
88 define amdgpu_kernel void @s_and_multi_use_constant_i32_1(i32 addrspace(1)* %out, i32 %a, i32 %b) {
89 %and = and i32 %a, 1234567
90 %foo = add i32 %and, 1234567
91 %bar = add i32 %foo, %b
92 store volatile i32 %bar, i32 addrspace(1)* %out
96 ; FUNC-LABEL: {{^}}v_and_i32_vgpr_vgpr:
97 ; SI: v_and_b32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
98 define amdgpu_kernel void @v_and_i32_vgpr_vgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) {
99 %tid = call i32 @llvm.r600.read.tidig.x() #0
100 %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
101 %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
102 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
103 %a = load i32, i32 addrspace(1)* %gep.a
104 %b = load i32, i32 addrspace(1)* %gep.b
105 %and = and i32 %a, %b
106 store i32 %and, i32 addrspace(1)* %gep.out
110 ; FUNC-LABEL: {{^}}v_and_i32_sgpr_vgpr:
111 ; SI-DAG: s_load_dword [[SA:s[0-9]+]]
112 ; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]]
113 ; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]]
114 define amdgpu_kernel void @v_and_i32_sgpr_vgpr(i32 addrspace(1)* %out, i32 %a, i32 addrspace(1)* %bptr) {
115 %tid = call i32 @llvm.r600.read.tidig.x() #0
116 %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
117 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
118 %b = load i32, i32 addrspace(1)* %gep.b
119 %and = and i32 %a, %b
120 store i32 %and, i32 addrspace(1)* %gep.out
124 ; FUNC-LABEL: {{^}}v_and_i32_vgpr_sgpr:
125 ; SI-DAG: s_load_dword [[SA:s[0-9]+]]
126 ; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]]
127 ; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]]
128 define amdgpu_kernel void @v_and_i32_vgpr_sgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 %b) {
129 %tid = call i32 @llvm.r600.read.tidig.x() #0
130 %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
131 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
132 %a = load i32, i32 addrspace(1)* %gep.a
133 %and = and i32 %a, %b
134 store i32 %and, i32 addrspace(1)* %gep.out
138 ; FUNC-LABEL: {{^}}v_and_constant_i32
139 ; SI: v_and_b32_e32 v{{[0-9]+}}, 0x12d687, v{{[0-9]+}}
140 define amdgpu_kernel void @v_and_constant_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
141 %tid = call i32 @llvm.r600.read.tidig.x() #0
142 %gep = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
143 %a = load i32, i32 addrspace(1)* %gep, align 4
144 %and = and i32 %a, 1234567
145 store i32 %and, i32 addrspace(1)* %out, align 4
149 ; FUNC-LABEL: {{^}}v_and_inline_imm_64_i32
150 ; SI: v_and_b32_e32 v{{[0-9]+}}, 64, v{{[0-9]+}}
151 define amdgpu_kernel void @v_and_inline_imm_64_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
152 %tid = call i32 @llvm.r600.read.tidig.x() #0
153 %gep = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
154 %a = load i32, i32 addrspace(1)* %gep, align 4
155 %and = and i32 %a, 64
156 store i32 %and, i32 addrspace(1)* %out, align 4
160 ; FUNC-LABEL: {{^}}v_and_inline_imm_neg_16_i32
161 ; SI: v_and_b32_e32 v{{[0-9]+}}, -16, v{{[0-9]+}}
162 define amdgpu_kernel void @v_and_inline_imm_neg_16_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
163 %tid = call i32 @llvm.r600.read.tidig.x() #0
164 %gep = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
165 %a = load i32, i32 addrspace(1)* %gep, align 4
166 %and = and i32 %a, -16
167 store i32 %and, i32 addrspace(1)* %out, align 4
171 ; FUNC-LABEL: {{^}}s_and_i64
173 define amdgpu_kernel void @s_and_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
174 %and = and i64 %a, %b
175 store i64 %and, i64 addrspace(1)* %out, align 8
179 ; FIXME: Should use SGPRs
180 ; FUNC-LABEL: {{^}}s_and_i1:
182 define amdgpu_kernel void @s_and_i1(i1 addrspace(1)* %out, i1 %a, i1 %b) {
184 store i1 %and, i1 addrspace(1)* %out
188 ; FUNC-LABEL: {{^}}s_and_constant_i64:
189 ; SI-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000{{$}}
190 ; SI-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80{{$}}
191 ; SI: buffer_store_dwordx2
192 define amdgpu_kernel void @s_and_constant_i64(i64 addrspace(1)* %out, i64 %a) {
193 %and = and i64 %a, 549756338176
194 store i64 %and, i64 addrspace(1)* %out, align 8
198 ; FUNC-LABEL: {{^}}s_and_multi_use_constant_i64:
199 ; XSI-DAG: s_mov_b32 s[[KLO:[0-9]+]], 0x80000{{$}}
200 ; XSI-DAG: s_mov_b32 s[[KHI:[0-9]+]], 0x80{{$}}
201 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[KLO]]:[[KHI]]{{\]}}
202 define amdgpu_kernel void @s_and_multi_use_constant_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
203 %and0 = and i64 %a, 549756338176
204 %and1 = and i64 %b, 549756338176
205 store volatile i64 %and0, i64 addrspace(1)* %out
206 store volatile i64 %and1, i64 addrspace(1)* %out
210 ; FUNC-LABEL: {{^}}s_and_32_bit_constant_i64:
213 ; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x12d687{{$}}
215 ; SI: buffer_store_dwordx2
216 define amdgpu_kernel void @s_and_32_bit_constant_i64(i64 addrspace(1)* %out, i64 %a) {
217 %and = and i64 %a, 1234567
218 store i64 %and, i64 addrspace(1)* %out, align 8
222 ; FUNC-LABEL: {{^}}s_and_multi_use_inline_imm_i64:
224 ; SI: s_load_dword [[A:s[0-9]+]]
225 ; SI: s_load_dword [[B:s[0-9]+]]
228 ; SI: s_lshl_b32 [[A]], [[A]], 1
229 ; SI: s_lshl_b32 [[B]], [[B]], 1
230 ; SI: s_and_b32 s{{[0-9]+}}, [[A]], 62
231 ; SI: s_and_b32 s{{[0-9]+}}, [[B]], 62
233 ; SI: buffer_store_dwordx2
234 define amdgpu_kernel void @s_and_multi_use_inline_imm_i64(i64 addrspace(1)* %out, i64 %a, i64 %b, i64 %c) {
235 %shl.a = shl i64 %a, 1
236 %shl.b = shl i64 %b, 1
237 %and0 = and i64 %shl.a, 62
238 %and1 = and i64 %shl.b, 62
239 %add0 = add i64 %and0, %c
240 %add1 = add i64 %and1, %c
241 store volatile i64 %add0, i64 addrspace(1)* %out
242 store volatile i64 %add1, i64 addrspace(1)* %out
246 ; FUNC-LABEL: {{^}}v_and_i64:
249 define amdgpu_kernel void @v_and_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) {
250 %tid = call i32 @llvm.r600.read.tidig.x() #0
251 %gep.a = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid
252 %a = load i64, i64 addrspace(1)* %gep.a, align 8
253 %gep.b = getelementptr i64, i64 addrspace(1)* %bptr, i32 %tid
254 %b = load i64, i64 addrspace(1)* %gep.b, align 8
255 %and = and i64 %a, %b
256 store i64 %and, i64 addrspace(1)* %out, align 8
260 ; FUNC-LABEL: {{^}}v_and_constant_i64:
261 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, 0xab19b207, {{v[0-9]+}}
262 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, 0x11e, {{v[0-9]+}}
263 ; SI: buffer_store_dwordx2
264 define amdgpu_kernel void @v_and_constant_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
265 %tid = call i32 @llvm.r600.read.tidig.x() #0
266 %gep.a = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid
267 %a = load i64, i64 addrspace(1)* %gep.a, align 8
268 %and = and i64 %a, 1231231234567
269 store i64 %and, i64 addrspace(1)* %out, align 8
273 ; FUNC-LABEL: {{^}}v_and_multi_use_constant_i64:
274 ; SI-DAG: buffer_load_dwordx2 v{{\[}}[[LO0:[0-9]+]]:[[HI0:[0-9]+]]{{\]}}
275 ; SI-DAG: buffer_load_dwordx2 v{{\[}}[[LO1:[0-9]+]]:[[HI1:[0-9]+]]{{\]}}
276 ; SI-DAG: s_movk_i32 [[KHI:s[0-9]+]], 0x11e{{$}}
277 ; SI-DAG: s_mov_b32 [[KLO:s[0-9]+]], 0xab19b207{{$}}
278 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KLO]], v[[LO0]]
279 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KHI]], v[[HI0]]
280 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KLO]], v[[LO1]]
281 ; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KHI]], v[[HI1]]
282 ; SI: buffer_store_dwordx2
283 ; SI: buffer_store_dwordx2
284 define amdgpu_kernel void @v_and_multi_use_constant_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
285 %a = load volatile i64, i64 addrspace(1)* %aptr
286 %b = load volatile i64, i64 addrspace(1)* %aptr
287 %and0 = and i64 %a, 1231231234567
288 %and1 = and i64 %b, 1231231234567
289 store volatile i64 %and0, i64 addrspace(1)* %out
290 store volatile i64 %and1, i64 addrspace(1)* %out
294 ; FUNC-LABEL: {{^}}v_and_multi_use_inline_imm_i64:
295 ; SI: buffer_load_dwordx2 v{{\[}}[[LO0:[0-9]+]]:[[HI0:[0-9]+]]{{\]}}
297 ; SI: buffer_load_dwordx2 v{{\[}}[[LO1:[0-9]+]]:[[HI1:[0-9]+]]{{\]}}
299 ; SI: v_and_b32_e32 v[[RESLO0:[0-9]+]], 63, v[[LO0]]
300 ; SI: v_and_b32_e32 v[[RESLO1:[0-9]+]], 63, v[[LO1]]
302 ; SI: buffer_store_dwordx2 v{{\[}}[[RESLO0]]
303 ; SI: buffer_store_dwordx2 v{{\[}}[[RESLO1]]
304 define amdgpu_kernel void @v_and_multi_use_inline_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
305 %a = load volatile i64, i64 addrspace(1)* %aptr
306 %b = load volatile i64, i64 addrspace(1)* %aptr
307 %and0 = and i64 %a, 63
308 %and1 = and i64 %b, 63
309 store volatile i64 %and0, i64 addrspace(1)* %out
310 store volatile i64 %and1, i64 addrspace(1)* %out
314 ; FUNC-LABEL: {{^}}v_and_i64_32_bit_constant:
315 ; SI: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
317 ; SI: v_and_b32_e32 {{v[0-9]+}}, 0x12d687, [[VAL]]
319 ; SI: buffer_store_dwordx2
320 define amdgpu_kernel void @v_and_i64_32_bit_constant(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
321 %tid = call i32 @llvm.r600.read.tidig.x() #0
322 %gep.a = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid
323 %a = load i64, i64 addrspace(1)* %gep.a, align 8
324 %and = and i64 %a, 1234567
325 store i64 %and, i64 addrspace(1)* %out, align 8
329 ; FUNC-LABEL: {{^}}v_and_inline_imm_i64:
330 ; SI: {{buffer|flat}}_load_dword v{{[0-9]+}}
332 ; SI: v_and_b32_e32 {{v[0-9]+}}, 64, {{v[0-9]+}}
334 ; SI: buffer_store_dwordx2
335 define amdgpu_kernel void @v_and_inline_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
336 %tid = call i32 @llvm.r600.read.tidig.x() #0
337 %gep.a = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid
338 %a = load i64, i64 addrspace(1)* %gep.a, align 8
339 %and = and i64 %a, 64
340 store i64 %and, i64 addrspace(1)* %out, align 8
344 ; FIXME: Should be able to reduce load width
345 ; FUNC-LABEL: {{^}}v_and_inline_neg_imm_i64:
346 ; SI: {{buffer|flat}}_load_dwordx2 v{{\[}}[[VAL_LO:[0-9]+]]:[[VAL_HI:[0-9]+]]{{\]}}
348 ; SI: v_and_b32_e32 v[[VAL_LO]], -8, v[[VAL_LO]]
350 ; SI: buffer_store_dwordx2 v{{\[}}[[VAL_LO]]:[[VAL_HI]]{{\]}}
351 define amdgpu_kernel void @v_and_inline_neg_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
352 %tid = call i32 @llvm.r600.read.tidig.x() #0
353 %gep.a = getelementptr i64, i64 addrspace(1)* %aptr, i32 %tid
354 %a = load i64, i64 addrspace(1)* %gep.a, align 8
355 %and = and i64 %a, -8
356 store i64 %and, i64 addrspace(1)* %out, align 8
360 ; FUNC-LABEL: {{^}}s_and_inline_imm_64_i64
363 ; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 64
365 ; SI: buffer_store_dword
366 define amdgpu_kernel void @s_and_inline_imm_64_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
367 %and = and i64 %a, 64
368 store i64 %and, i64 addrspace(1)* %out, align 8
372 ; FUNC-LABEL: {{^}}s_and_inline_imm_64_i64_noshrink:
373 ; SI: s_load_dword [[A:s[0-9]+]]
374 ; SI: s_lshl_b32 [[A]], [[A]], 1{{$}}
376 ; SI: s_and_b32 s{{[0-9]+}}, [[A]], 64
379 ; SI-NEXT: s_addc_u32
380 define amdgpu_kernel void @s_and_inline_imm_64_i64_noshrink(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a, i64 %b) {
382 %and = and i64 %shl, 64
383 %add = add i64 %and, %b
384 store i64 %add, i64 addrspace(1)* %out, align 8
388 ; FUNC-LABEL: {{^}}s_and_inline_imm_1_i64
391 ; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 1
393 ; SI: buffer_store_dwordx2
394 define amdgpu_kernel void @s_and_inline_imm_1_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
396 store i64 %and, i64 addrspace(1)* %out, align 8
400 ; FUNC-LABEL: {{^}}s_and_inline_imm_1.0_i64
401 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 1.0
406 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x3ff00000
408 ; SI: buffer_store_dwordx2
409 define amdgpu_kernel void @s_and_inline_imm_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
410 %and = and i64 %a, 4607182418800017408
411 store i64 %and, i64 addrspace(1)* %out, align 8
415 ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_1.0_i64
416 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -1.0
421 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xbff00000
423 ; SI: buffer_store_dwordx2
424 define amdgpu_kernel void @s_and_inline_imm_neg_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
425 %and = and i64 %a, 13830554455654793216
426 store i64 %and, i64 addrspace(1)* %out, align 8
430 ; FUNC-LABEL: {{^}}s_and_inline_imm_0.5_i64
431 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0.5
436 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x3fe00000
438 ; SI: buffer_store_dwordx2
439 define amdgpu_kernel void @s_and_inline_imm_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
440 %and = and i64 %a, 4602678819172646912
441 store i64 %and, i64 addrspace(1)* %out, align 8
445 ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_0.5_i64:
446 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -0.5
451 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xbfe00000
453 ; SI: buffer_store_dwordx2
454 define amdgpu_kernel void @s_and_inline_imm_neg_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
455 %and = and i64 %a, 13826050856027422720
456 store i64 %and, i64 addrspace(1)* %out, align 8
460 ; FUNC-LABEL: {{^}}s_and_inline_imm_2.0_i64:
464 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 2.0
466 ; SI: buffer_store_dwordx2
467 define amdgpu_kernel void @s_and_inline_imm_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
468 %and = and i64 %a, 4611686018427387904
469 store i64 %and, i64 addrspace(1)* %out, align 8
473 ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_2.0_i64:
477 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, -2.0
479 ; SI: buffer_store_dwordx2
480 define amdgpu_kernel void @s_and_inline_imm_neg_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
481 %and = and i64 %a, 13835058055282163712
482 store i64 %and, i64 addrspace(1)* %out, align 8
486 ; FUNC-LABEL: {{^}}s_and_inline_imm_4.0_i64:
487 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 4.0
492 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x40100000
494 ; SI: buffer_store_dwordx2
495 define amdgpu_kernel void @s_and_inline_imm_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
496 %and = and i64 %a, 4616189618054758400
497 store i64 %and, i64 addrspace(1)* %out, align 8
501 ; FUNC-LABEL: {{^}}s_and_inline_imm_neg_4.0_i64:
502 ; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -4.0
507 ; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xc0100000
509 ; SI: buffer_store_dwordx2
510 define amdgpu_kernel void @s_and_inline_imm_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
511 %and = and i64 %a, 13839561654909534208
512 store i64 %and, i64 addrspace(1)* %out, align 8
517 ; Test with the 64-bit integer bitpattern for a 32-bit float in the
518 ; low 32-bits, which is not a valid 64-bit inline immmediate.
520 ; FUNC-LABEL: {{^}}s_and_inline_imm_f32_4.0_i64:
524 ; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, 4.0
526 ; SI: buffer_store_dwordx2
527 define amdgpu_kernel void @s_and_inline_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
528 %and = and i64 %a, 1082130432
529 store i64 %and, i64 addrspace(1)* %out, align 8
533 ; FUNC-LABEL: {{^}}s_and_inline_imm_f32_neg_4.0_i64:
537 ; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, -4.0
539 ; SI: buffer_store_dwordx2
540 define amdgpu_kernel void @s_and_inline_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
541 %and = and i64 %a, -1065353216
542 store i64 %and, i64 addrspace(1)* %out, align 8
546 ; Shift into upper 32-bits
550 ; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, 4.0
552 ; SI: buffer_store_dwordx2
553 define amdgpu_kernel void @s_and_inline_high_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
554 %and = and i64 %a, 4647714815446351872
555 store i64 %and, i64 addrspace(1)* %out, align 8
559 ; FUNC-LABEL: {{^}}s_and_inline_high_imm_f32_neg_4.0_i64:
563 ; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, -4.0
565 ; SI: buffer_store_dwordx2
566 define amdgpu_kernel void @s_and_inline_high_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
567 %and = and i64 %a, 13871086852301127680
568 store i64 %and, i64 addrspace(1)* %out, align 8
571 attributes #0 = { nounwind readnone }