blob: 830aa0a900443bfd270b82e25ef90f496686be20 [file] [log] [blame]
Matt Arsenault284ae082014-06-09 08:36:53 +00001; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
Tom Stellard49f8bfd2015-01-06 18:00:21 +00002; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Marek Olsak75170772015-01-27 17:27:15 +00003; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Tom Stellard75aadc22012-12-11 21:25:42 +00004
Matt Arsenault28bd7d42015-09-25 18:21:47 +00005declare i32 @llvm.r600.read.tidig.x() #0
6
Tom Stellard79243d92014-10-01 17:15:17 +00007; FUNC-LABEL: {{^}}test2:
Matt Arsenault284ae082014-06-09 08:36:53 +00008; 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]}}
Tom Stellard75aadc22012-12-11 21:25:42 +000010
Tom Stellard326d6ec2014-11-05 14:50:53 +000011; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
12; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
Aaron Watry00aeb112013-06-25 13:55:23 +000013
14define void @test2(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
David Blaikie79e6c742015-02-27 19:29:02 +000015 %b_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000016 %a = load <2 x i32>, <2 x i32> addrspace(1) * %in
17 %b = load <2 x i32>, <2 x i32> addrspace(1) * %b_ptr
Aaron Watry00aeb112013-06-25 13:55:23 +000018 %result = and <2 x i32> %a, %b
19 store <2 x i32> %result, <2 x i32> addrspace(1)* %out
20 ret void
21}
22
Tom Stellard79243d92014-10-01 17:15:17 +000023; FUNC-LABEL: {{^}}test4:
Matt Arsenault284ae082014-06-09 08:36:53 +000024; 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]}}
Aaron Watry00aeb112013-06-25 13:55:23 +000028
Tom Stellard326d6ec2014-11-05 14:50:53 +000029; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
30; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
31; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
32; SI: v_and_b32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
Aaron Watry00aeb112013-06-25 13:55:23 +000033
34define void @test4(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
David Blaikie79e6c742015-02-27 19:29:02 +000035 %b_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000036 %a = load <4 x i32>, <4 x i32> addrspace(1) * %in
37 %b = load <4 x i32>, <4 x i32> addrspace(1) * %b_ptr
Tom Stellard75aadc22012-12-11 21:25:42 +000038 %result = and <4 x i32> %a, %b
39 store <4 x i32> %result, <4 x i32> addrspace(1)* %out
40 ret void
41}
Matt Arsenault284ae082014-06-09 08:36:53 +000042
Tom Stellard79243d92014-10-01 17:15:17 +000043; FUNC-LABEL: {{^}}s_and_i32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000044; SI: s_and_b32
Matt Arsenault284ae082014-06-09 08:36:53 +000045define void @s_and_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) {
46 %and = and i32 %a, %b
47 store i32 %and, i32 addrspace(1)* %out, align 4
48 ret void
49}
50
Tom Stellard79243d92014-10-01 17:15:17 +000051; FUNC-LABEL: {{^}}s_and_constant_i32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000052; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x12d687
Matt Arsenault284ae082014-06-09 08:36:53 +000053define void @s_and_constant_i32(i32 addrspace(1)* %out, i32 %a) {
54 %and = and i32 %a, 1234567
55 store i32 %and, i32 addrspace(1)* %out, align 4
56 ret void
57}
58
Matt Arsenault28bd7d42015-09-25 18:21:47 +000059; FIXME: We should really duplicate the constant so that the SALU use
60; can fold into the s_and_b32 and the VALU one is materialized
61; directly without copying from the SGPR.
62
63; Second use is a VGPR use of the constant.
64; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_0:
65; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687
66; SI-DAG: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]]
67; SI-DAG: v_mov_b32_e32 [[VK:v[0-9]+]], [[K]]
68; SI: buffer_store_dword [[VK]]
69define void @s_and_multi_use_constant_i32_0(i32 addrspace(1)* %out, i32 %a, i32 %b) {
70 %and = and i32 %a, 1234567
71
72 ; Just to stop future replacement of copy to vgpr + store with VALU op.
73 %foo = add i32 %and, %b
74 store volatile i32 %foo, i32 addrspace(1)* %out
75 store volatile i32 1234567, i32 addrspace(1)* %out
76 ret void
77}
78
79; Second use is another SGPR use of the constant.
80; FUNC-LABEL: {{^}}s_and_multi_use_constant_i32_1:
81; SI: s_mov_b32 [[K:s[0-9]+]], 0x12d687
82; SI: s_and_b32 [[AND:s[0-9]+]], s{{[0-9]+}}, [[K]]
83; SI: s_add_i32
84; SI: s_add_i32 [[ADD:s[0-9]+]], s{{[0-9]+}}, [[K]]
85; SI: buffer_store_dword [[VK]]
86define void @s_and_multi_use_constant_i32_1(i32 addrspace(1)* %out, i32 %a, i32 %b) {
87 %and = and i32 %a, 1234567
88 %foo = add i32 %and, 1234567
89 %bar = add i32 %foo, %b
90 store volatile i32 %bar, i32 addrspace(1)* %out
91 ret void
92}
93
94; FUNC-LABEL: {{^}}v_and_i32_vgpr_vgpr:
95; SI: v_and_b32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
96define void @v_and_i32_vgpr_vgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) {
97 %tid = call i32 @llvm.r600.read.tidig.x() #0
98 %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
99 %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
100 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
101 %a = load i32, i32 addrspace(1)* %gep.a
102 %b = load i32, i32 addrspace(1)* %gep.b
Matt Arsenault284ae082014-06-09 08:36:53 +0000103 %and = and i32 %a, %b
Matt Arsenault28bd7d42015-09-25 18:21:47 +0000104 store i32 %and, i32 addrspace(1)* %gep.out
105 ret void
106}
107
108; FUNC-LABEL: {{^}}v_and_i32_sgpr_vgpr:
109; SI-DAG: s_load_dword [[SA:s[0-9]+]]
110; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]]
111; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]]
112define void @v_and_i32_sgpr_vgpr(i32 addrspace(1)* %out, i32 %a, i32 addrspace(1)* %bptr) {
113 %tid = call i32 @llvm.r600.read.tidig.x() #0
114 %gep.b = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
115 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
116 %b = load i32, i32 addrspace(1)* %gep.b
117 %and = and i32 %a, %b
118 store i32 %and, i32 addrspace(1)* %gep.out
119 ret void
120}
121
122; FUNC-LABEL: {{^}}v_and_i32_vgpr_sgpr:
123; SI-DAG: s_load_dword [[SA:s[0-9]+]]
124; SI-DAG: {{buffer|flat}}_load_dword [[VB:v[0-9]+]]
125; SI: v_and_b32_e32 v{{[0-9]+}}, [[SA]], [[VB]]
126define void @v_and_i32_vgpr_sgpr(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 %b) {
127 %tid = call i32 @llvm.r600.read.tidig.x() #0
128 %gep.a = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
129 %gep.out = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
130 %a = load i32, i32 addrspace(1)* %gep.a
131 %and = and i32 %a, %b
132 store i32 %and, i32 addrspace(1)* %gep.out
Matt Arsenault284ae082014-06-09 08:36:53 +0000133 ret void
134}
135
Matt Arsenault11a4d672015-02-13 19:05:03 +0000136; FUNC-LABEL: {{^}}v_and_constant_i32
137; SI: v_and_b32_e32 v{{[0-9]+}}, 0x12d687, v{{[0-9]+}}
Matt Arsenault284ae082014-06-09 08:36:53 +0000138define void @v_and_constant_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000139 %a = load i32, i32 addrspace(1)* %aptr, align 4
Matt Arsenault284ae082014-06-09 08:36:53 +0000140 %and = and i32 %a, 1234567
141 store i32 %and, i32 addrspace(1)* %out, align 4
142 ret void
143}
144
Matt Arsenault11a4d672015-02-13 19:05:03 +0000145; FUNC-LABEL: {{^}}v_and_inline_imm_64_i32
146; SI: v_and_b32_e32 v{{[0-9]+}}, 64, v{{[0-9]+}}
147define void @v_and_inline_imm_64_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000148 %a = load i32, i32 addrspace(1)* %aptr, align 4
Matt Arsenault11a4d672015-02-13 19:05:03 +0000149 %and = and i32 %a, 64
150 store i32 %and, i32 addrspace(1)* %out, align 4
151 ret void
152}
153
154; FUNC-LABEL: {{^}}v_and_inline_imm_neg_16_i32
155; SI: v_and_b32_e32 v{{[0-9]+}}, -16, v{{[0-9]+}}
156define void @v_and_inline_imm_neg_16_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000157 %a = load i32, i32 addrspace(1)* %aptr, align 4
Matt Arsenault11a4d672015-02-13 19:05:03 +0000158 %and = and i32 %a, -16
159 store i32 %and, i32 addrspace(1)* %out, align 4
160 ret void
161}
162
163; FUNC-LABEL: {{^}}s_and_i64
Tom Stellard326d6ec2014-11-05 14:50:53 +0000164; SI: s_and_b64
Matt Arsenault284ae082014-06-09 08:36:53 +0000165define void @s_and_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
166 %and = and i64 %a, %b
167 store i64 %and, i64 addrspace(1)* %out, align 8
168 ret void
169}
170
Matt Arsenault0d89e842014-07-15 21:44:37 +0000171; FIXME: Should use SGPRs
Tom Stellard79243d92014-10-01 17:15:17 +0000172; FUNC-LABEL: {{^}}s_and_i1:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000173; SI: v_and_b32
Matt Arsenault0d89e842014-07-15 21:44:37 +0000174define void @s_and_i1(i1 addrspace(1)* %out, i1 %a, i1 %b) {
175 %and = and i1 %a, %b
176 store i1 %and, i1 addrspace(1)* %out
177 ret void
178}
179
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000180; FUNC-LABEL: {{^}}s_and_constant_i64:
181; SI-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000{{$}}
182; SI-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80{{$}}
183; SI: buffer_store_dwordx2
Matt Arsenault284ae082014-06-09 08:36:53 +0000184define void @s_and_constant_i64(i64 addrspace(1)* %out, i64 %a) {
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000185 %and = and i64 %a, 549756338176
Matt Arsenault284ae082014-06-09 08:36:53 +0000186 store i64 %and, i64 addrspace(1)* %out, align 8
187 ret void
188}
189
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000190; FUNC-LABEL: {{^}}s_and_multi_use_constant_i64:
191; XSI-DAG: s_mov_b32 s[[KLO:[0-9]+]], 0x80000{{$}}
192; XSI-DAG: s_mov_b32 s[[KHI:[0-9]+]], 0x80{{$}}
193; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, s{{\[}}[[KLO]]:[[KHI]]{{\]}}
194define void @s_and_multi_use_constant_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
195 %and0 = and i64 %a, 549756338176
196 %and1 = and i64 %b, 549756338176
197 store volatile i64 %and0, i64 addrspace(1)* %out
198 store volatile i64 %and1, i64 addrspace(1)* %out
199 ret void
200}
201
202; FUNC-LABEL: {{^}}s_and_32_bit_constant_i64:
203; SI: s_load_dwordx2
204; SI-NOT: and
205; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x12d687{{$}}
206; SI-NOT: and
207; SI: buffer_store_dwordx2
208define void @s_and_32_bit_constant_i64(i64 addrspace(1)* %out, i64 %a) {
209 %and = and i64 %a, 1234567
210 store i64 %and, i64 addrspace(1)* %out, align 8
211 ret void
212}
213
214; FUNC-LABEL: {{^}}s_and_multi_use_inline_imm_i64:
215; SI: s_load_dwordx2
216; SI: s_load_dwordx2
217; SI: s_load_dwordx2
218; SI: s_load_dwordx2
219; SI-NOT: and
220; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 62
221; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 62
222; SI-NOT: and
223; SI: buffer_store_dwordx2
224define void @s_and_multi_use_inline_imm_i64(i64 addrspace(1)* %out, i64 %a, i64 %b, i64 %c) {
225 %shl.a = shl i64 %a, 1
226 %shl.b = shl i64 %b, 1
227 %and0 = and i64 %shl.a, 62
228 %and1 = and i64 %shl.b, 62
229 %add0 = add i64 %and0, %c
230 %add1 = add i64 %and1, %c
231 store volatile i64 %add0, i64 addrspace(1)* %out
232 store volatile i64 %add1, i64 addrspace(1)* %out
233 ret void
234}
235
Tom Stellard79243d92014-10-01 17:15:17 +0000236; FUNC-LABEL: {{^}}v_and_i64:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000237; SI: v_and_b32
238; SI: v_and_b32
Matt Arsenault284ae082014-06-09 08:36:53 +0000239define void @v_and_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000240 %a = load i64, i64 addrspace(1)* %aptr, align 8
241 %b = load i64, i64 addrspace(1)* %bptr, align 8
Matt Arsenault284ae082014-06-09 08:36:53 +0000242 %and = and i64 %a, %b
243 store i64 %and, i64 addrspace(1)* %out, align 8
244 ret void
245}
246
Tom Stellard79243d92014-10-01 17:15:17 +0000247; FUNC-LABEL: {{^}}v_and_i64_br:
Tom Stellard326d6ec2014-11-05 14:50:53 +0000248; SI: v_and_b32
249; SI: v_and_b32
Tom Stellard102c6872014-09-03 15:22:41 +0000250define void @v_and_i64_br(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr, i32 %cond) {
251entry:
252 %tmp0 = icmp eq i32 %cond, 0
253 br i1 %tmp0, label %if, label %endif
254
255if:
David Blaikiea79ac142015-02-27 21:17:42 +0000256 %a = load i64, i64 addrspace(1)* %aptr, align 8
257 %b = load i64, i64 addrspace(1)* %bptr, align 8
Tom Stellard102c6872014-09-03 15:22:41 +0000258 %and = and i64 %a, %b
259 br label %endif
260
261endif:
262 %tmp1 = phi i64 [%and, %if], [0, %entry]
263 store i64 %tmp1, i64 addrspace(1)* %out, align 8
264 ret void
265}
266
Tom Stellard79243d92014-10-01 17:15:17 +0000267; FUNC-LABEL: {{^}}v_and_constant_i64:
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000268; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, 0xab19b207, {{v[0-9]+}}
269; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, 0x11e, {{v[0-9]+}}
Matt Arsenault68d93862015-09-24 08:36:14 +0000270; SI: buffer_store_dwordx2
271define void @v_and_constant_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
272 %a = load i64, i64 addrspace(1)* %aptr, align 8
273 %and = and i64 %a, 1231231234567
274 store i64 %and, i64 addrspace(1)* %out, align 8
275 ret void
276}
277
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000278; FUNC-LABEL: {{^}}v_and_multi_use_constant_i64:
279; SI: buffer_load_dwordx2 v{{\[}}[[LO0:[0-9]+]]:[[HI0:[0-9]+]]{{\]}}
280; SI: buffer_load_dwordx2 v{{\[}}[[LO1:[0-9]+]]:[[HI1:[0-9]+]]{{\]}}
281; SI-DAG: s_mov_b32 [[KLO:s[0-9]+]], 0xab19b207{{$}}
282; SI-DAG: s_movk_i32 [[KHI:s[0-9]+]], 0x11e{{$}}
283; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KLO]], v[[LO0]]
284; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KHI]], v[[HI0]]
285; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KLO]], v[[LO1]]
286; SI-DAG: v_and_b32_e32 {{v[0-9]+}}, [[KHI]], v[[HI1]]
287; SI: buffer_store_dwordx2
288; SI: buffer_store_dwordx2
289define void @v_and_multi_use_constant_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
290 %a = load volatile i64, i64 addrspace(1)* %aptr
291 %b = load volatile i64, i64 addrspace(1)* %aptr
292 %and0 = and i64 %a, 1231231234567
293 %and1 = and i64 %b, 1231231234567
294 store volatile i64 %and0, i64 addrspace(1)* %out
295 store volatile i64 %and1, i64 addrspace(1)* %out
296 ret void
297}
298
299; FUNC-LABEL: {{^}}v_and_multi_use_inline_imm_i64:
300; SI: buffer_load_dwordx2 v{{\[}}[[LO0:[0-9]+]]:[[HI0:[0-9]+]]{{\]}}
301; SI-NOT: and
302; SI: buffer_load_dwordx2 v{{\[}}[[LO1:[0-9]+]]:[[HI1:[0-9]+]]{{\]}}
303; SI-NOT: and
304; SI: v_and_b32_e32 v[[RESLO0:[0-9]+]], 63, v[[LO0]]
305; SI: v_and_b32_e32 v[[RESLO1:[0-9]+]], 63, v[[LO1]]
306; SI-NOT: and
307; SI: buffer_store_dwordx2
308; SI-NOT: and
309; SI: buffer_store_dwordx2
310define void @v_and_multi_use_inline_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
311 %a = load volatile i64, i64 addrspace(1)* %aptr
312 %b = load volatile i64, i64 addrspace(1)* %aptr
313 %and0 = and i64 %a, 63
314 %and1 = and i64 %b, 63
315 store volatile i64 %and0, i64 addrspace(1)* %out
316 store volatile i64 %and1, i64 addrspace(1)* %out
317 ret void
318}
319
Matt Arsenault68d93862015-09-24 08:36:14 +0000320; FUNC-LABEL: {{^}}v_and_i64_32_bit_constant:
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000321; SI: buffer_load_dword [[VAL:v[0-9]+]]
322; SI-NOT: and
323; SI: v_and_b32_e32 {{v[0-9]+}}, 0x12d687, [[VAL]]
324; SI-NOT: and
325; SI: buffer_store_dwordx2
Matt Arsenault68d93862015-09-24 08:36:14 +0000326define void @v_and_i64_32_bit_constant(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000327 %a = load i64, i64 addrspace(1)* %aptr, align 8
Matt Arsenault284ae082014-06-09 08:36:53 +0000328 %and = and i64 %a, 1234567
329 store i64 %and, i64 addrspace(1)* %out, align 8
330 ret void
331}
Matt Arsenault49dd4282014-09-15 17:15:02 +0000332
Tom Stellard79243d92014-10-01 17:15:17 +0000333; FUNC-LABEL: {{^}}v_and_inline_imm_i64:
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000334; SI: buffer_load_dword v{{[0-9]+}}
335; SI-NOT: and
Tom Stellard326d6ec2014-11-05 14:50:53 +0000336; SI: v_and_b32_e32 {{v[0-9]+}}, 64, {{v[0-9]+}}
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000337; SI-NOT: and
338; SI: buffer_store_dwordx2
Matt Arsenault49dd4282014-09-15 17:15:02 +0000339define void @v_and_inline_imm_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr) {
David Blaikiea79ac142015-02-27 21:17:42 +0000340 %a = load i64, i64 addrspace(1)* %aptr, align 8
Matt Arsenault49dd4282014-09-15 17:15:02 +0000341 %and = and i64 %a, 64
342 store i64 %and, i64 addrspace(1)* %out, align 8
343 ret void
344}
345
Matt Arsenault11a4d672015-02-13 19:05:03 +0000346; FUNC-LABEL: {{^}}s_and_inline_imm_64_i64
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000347; SI: s_load_dword
348; SI-NOT: and
349; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 64
350; SI-NOT: and
351; SI: buffer_store_dword
Matt Arsenault11a4d672015-02-13 19:05:03 +0000352define void @s_and_inline_imm_64_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
Matt Arsenault49dd4282014-09-15 17:15:02 +0000353 %and = and i64 %a, 64
354 store i64 %and, i64 addrspace(1)* %out, align 8
355 ret void
356}
Matt Arsenault11a4d672015-02-13 19:05:03 +0000357
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000358; FUNC-LABEL: {{^}}s_and_inline_imm_64_i64_noshrink:
359; SI: s_lshl_b64 s{{\[}}[[VALLO:[0-9]+]]:{{[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 1
360; SI-NOT: and
361; SI: s_and_b32 s{{[0-9]+}}, s[[VALLO]], 64
362; SI-NOT: and
363; SI: s_add_u32
364; SI-NEXT: s_addc_u32
365define void @s_and_inline_imm_64_i64_noshrink(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a, i64 %b) {
366 %shl = shl i64 %a, 1
367 %and = and i64 %shl, 64
368 %add = add i64 %and, %b
369 store i64 %add, i64 addrspace(1)* %out, align 8
370 ret void
371}
372
Matt Arsenault11a4d672015-02-13 19:05:03 +0000373; FUNC-LABEL: {{^}}s_and_inline_imm_1_i64
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000374; SI: s_load_dwordx2
375; SI-NOT: and
376; SI: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 1
377; SI-NOT: and
378; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000379define void @s_and_inline_imm_1_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
380 %and = and i64 %a, 1
381 store i64 %and, i64 addrspace(1)* %out, align 8
382 ret void
383}
384
385; FUNC-LABEL: {{^}}s_and_inline_imm_1.0_i64
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000386; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 1.0
387
388; SI: s_load_dwordx2
389; SI: s_load_dwordx2
390; SI-NOT: and
391; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x3ff00000
392; SI-NOT: and
393; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000394define void @s_and_inline_imm_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
395 %and = and i64 %a, 4607182418800017408
396 store i64 %and, i64 addrspace(1)* %out, align 8
397 ret void
398}
399
400; FUNC-LABEL: {{^}}s_and_inline_imm_neg_1.0_i64
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000401; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -1.0
402
403; SI: s_load_dwordx2
404; SI: s_load_dwordx2
405; SI-NOT: and
406; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xbff00000
407; SI-NOT: and
408; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000409define void @s_and_inline_imm_neg_1.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
410 %and = and i64 %a, 13830554455654793216
411 store i64 %and, i64 addrspace(1)* %out, align 8
412 ret void
413}
414
415; FUNC-LABEL: {{^}}s_and_inline_imm_0.5_i64
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000416; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0.5
417
418; SI: s_load_dwordx2
419; SI: s_load_dwordx2
420; SI-NOT: and
421; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x3fe00000
422; SI-NOT: and
423; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000424define void @s_and_inline_imm_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
425 %and = and i64 %a, 4602678819172646912
426 store i64 %and, i64 addrspace(1)* %out, align 8
427 ret void
428}
429
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000430; FUNC-LABEL: {{^}}s_and_inline_imm_neg_0.5_i64:
431; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -0.5
432
433; SI: s_load_dwordx2
434; SI: s_load_dwordx2
435; SI-NOT: and
436; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xbfe00000
437; SI-NOT: and
438; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000439define void @s_and_inline_imm_neg_0.5_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
440 %and = and i64 %a, 13826050856027422720
441 store i64 %and, i64 addrspace(1)* %out, align 8
442 ret void
443}
444
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000445; FUNC-LABEL: {{^}}s_and_inline_imm_2.0_i64:
446; SI: s_load_dwordx2
447; SI: s_load_dwordx2
448; SI-NOT: and
449; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 2.0
450; SI-NOT: and
451; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000452define void @s_and_inline_imm_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
453 %and = and i64 %a, 4611686018427387904
454 store i64 %and, i64 addrspace(1)* %out, align 8
455 ret void
456}
457
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000458; FUNC-LABEL: {{^}}s_and_inline_imm_neg_2.0_i64:
459; SI: s_load_dwordx2
460; SI: s_load_dwordx2
461; SI-NOT: and
462; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, -2.0
463; SI-NOT: and
464; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000465define void @s_and_inline_imm_neg_2.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
466 %and = and i64 %a, 13835058055282163712
467 store i64 %and, i64 addrspace(1)* %out, align 8
468 ret void
469}
470
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000471; FUNC-LABEL: {{^}}s_and_inline_imm_4.0_i64:
472; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 4.0
473
474; SI: s_load_dwordx2
475; SI: s_load_dwordx2
476; SI-NOT: and
477; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x40100000
478; SI-NOT: and
479; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000480define void @s_and_inline_imm_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
481 %and = and i64 %a, 4616189618054758400
482 store i64 %and, i64 addrspace(1)* %out, align 8
483 ret void
484}
485
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000486; FUNC-LABEL: {{^}}s_and_inline_imm_neg_4.0_i64:
487; XSI: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, -4.0
488
489; SI: s_load_dwordx2
490; SI: s_load_dwordx2
491; SI-NOT: and
492; SI: s_and_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0xc0100000
493; SI-NOT: and
494; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000495define void @s_and_inline_imm_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
496 %and = and i64 %a, 13839561654909534208
497 store i64 %and, i64 addrspace(1)* %out, align 8
498 ret void
499}
500
501
502; Test with the 64-bit integer bitpattern for a 32-bit float in the
503; low 32-bits, which is not a valid 64-bit inline immmediate.
504
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000505; FUNC-LABEL: {{^}}s_and_inline_imm_f32_4.0_i64:
506; SI: s_load_dwordx2
507; SI: s_load_dword s
508; SI-NOT: and
509; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, 4.0
510; SI-NOT: and
511; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000512define void @s_and_inline_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
513 %and = and i64 %a, 1082130432
514 store i64 %and, i64 addrspace(1)* %out, align 8
515 ret void
516}
517
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000518; FUNC-LABEL: {{^}}s_and_inline_imm_f32_neg_4.0_i64:
519; SI: s_load_dwordx2
520; SI: s_load_dwordx2
521; SI-NOT: and
522; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, -4.0
523; SI-NOT: and
524; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000525define void @s_and_inline_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
526 %and = and i64 %a, -1065353216
527 store i64 %and, i64 addrspace(1)* %out, align 8
528 ret void
529}
530
531; Shift into upper 32-bits
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000532; SI: s_load_dwordx2
533; SI: s_load_dwordx2
534; SI-NOT: and
535; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, 4.0
536; SI-NOT: and
537; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000538define void @s_and_inline_high_imm_f32_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
539 %and = and i64 %a, 4647714815446351872
540 store i64 %and, i64 addrspace(1)* %out, align 8
541 ret void
542}
543
Matt Arsenault6e3a4512016-01-18 22:01:13 +0000544; FUNC-LABEL: {{^}}s_and_inline_high_imm_f32_neg_4.0_i64:
545; SI: s_load_dwordx2
546; SI: s_load_dwordx2
547; SI-NOT: and
548; SI: s_and_b32 s[[K_HI:[0-9]+]], s{{[0-9]+}}, -4.0
549; SI-NOT: and
550; SI: buffer_store_dwordx2
Matt Arsenault11a4d672015-02-13 19:05:03 +0000551define void @s_and_inline_high_imm_f32_neg_4.0_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %aptr, i64 %a) {
552 %and = and i64 %a, 13871086852301127680
553 store i64 %and, i64 addrspace(1)* %out, align 8
554 ret void
555}
Matt Arsenault28bd7d42015-09-25 18:21:47 +0000556
557attributes #0 = { nounwind readnone }