1 ; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
5 ; FUNC-LABEL: {{^}}sdiv24_i8:
15 define amdgpu_kernel void @sdiv24_i8(i8 addrspace(1)* %out, i8 addrspace(1)* %in) {
16 %den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
17 %num = load i8, i8 addrspace(1) * %in
18 %den = load i8, i8 addrspace(1) * %den_ptr
19 %result = sdiv i8 %num, %den
20 store i8 %result, i8 addrspace(1)* %out
24 ; FUNC-LABEL: {{^}}sdiv24_i16:
34 define amdgpu_kernel void @sdiv24_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %in) {
35 %den_ptr = getelementptr i16, i16 addrspace(1)* %in, i16 1
36 %num = load i16, i16 addrspace(1) * %in, align 2
37 %den = load i16, i16 addrspace(1) * %den_ptr, align 2
38 %result = sdiv i16 %num, %den
39 store i16 %result, i16 addrspace(1)* %out, align 2
43 ; FUNC-LABEL: {{^}}sdiv24_i32:
53 define amdgpu_kernel void @sdiv24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
54 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
55 %num = load i32, i32 addrspace(1) * %in, align 4
56 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
57 %num.i24.0 = shl i32 %num, 8
58 %den.i24.0 = shl i32 %den, 8
59 %num.i24 = ashr i32 %num.i24.0, 8
60 %den.i24 = ashr i32 %den.i24.0, 8
61 %result = sdiv i32 %num.i24, %den.i24
62 store i32 %result, i32 addrspace(1)* %out, align 4
66 ; FUNC-LABEL: {{^}}sdiv25_i32:
67 ; SI-NOT: v_cvt_f32_i32
72 define amdgpu_kernel void @sdiv25_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
73 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
74 %num = load i32, i32 addrspace(1) * %in, align 4
75 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
76 %num.i24.0 = shl i32 %num, 7
77 %den.i24.0 = shl i32 %den, 7
78 %num.i24 = ashr i32 %num.i24.0, 7
79 %den.i24 = ashr i32 %den.i24.0, 7
80 %result = sdiv i32 %num.i24, %den.i24
81 store i32 %result, i32 addrspace(1)* %out, align 4
85 ; FUNC-LABEL: {{^}}test_no_sdiv24_i32_1:
86 ; SI-NOT: v_cvt_f32_i32
91 define amdgpu_kernel void @test_no_sdiv24_i32_1(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
92 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
93 %num = load i32, i32 addrspace(1) * %in, align 4
94 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
95 %num.i24.0 = shl i32 %num, 8
96 %den.i24.0 = shl i32 %den, 7
97 %num.i24 = ashr i32 %num.i24.0, 8
98 %den.i24 = ashr i32 %den.i24.0, 7
99 %result = sdiv i32 %num.i24, %den.i24
100 store i32 %result, i32 addrspace(1)* %out, align 4
104 ; FUNC-LABEL: {{^}}test_no_sdiv24_i32_2:
105 ; SI-NOT: v_cvt_f32_i32
110 define amdgpu_kernel void @test_no_sdiv24_i32_2(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
111 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
112 %num = load i32, i32 addrspace(1) * %in, align 4
113 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
114 %num.i24.0 = shl i32 %num, 7
115 %den.i24.0 = shl i32 %den, 8
116 %num.i24 = ashr i32 %num.i24.0, 7
117 %den.i24 = ashr i32 %den.i24.0, 8
118 %result = sdiv i32 %num.i24, %den.i24
119 store i32 %result, i32 addrspace(1)* %out, align 4
123 ; FUNC-LABEL: {{^}}srem24_i8:
126 ; SI: v_rcp_iflag_f32
133 define amdgpu_kernel void @srem24_i8(i8 addrspace(1)* %out, i8 addrspace(1)* %in) {
134 %den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
135 %num = load i8, i8 addrspace(1) * %in
136 %den = load i8, i8 addrspace(1) * %den_ptr
137 %result = srem i8 %num, %den
138 store i8 %result, i8 addrspace(1)* %out
142 ; FUNC-LABEL: {{^}}srem24_i16:
145 ; SI: v_rcp_iflag_f32
152 define amdgpu_kernel void @srem24_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %in) {
153 %den_ptr = getelementptr i16, i16 addrspace(1)* %in, i16 1
154 %num = load i16, i16 addrspace(1) * %in, align 2
155 %den = load i16, i16 addrspace(1) * %den_ptr, align 2
156 %result = srem i16 %num, %den
157 store i16 %result, i16 addrspace(1)* %out, align 2
161 ; FUNC-LABEL: {{^}}srem24_i32:
164 ; SI: v_rcp_iflag_f32
171 define amdgpu_kernel void @srem24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
172 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
173 %num = load i32, i32 addrspace(1) * %in, align 4
174 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
175 %num.i24.0 = shl i32 %num, 8
176 %den.i24.0 = shl i32 %den, 8
177 %num.i24 = ashr i32 %num.i24.0, 8
178 %den.i24 = ashr i32 %den.i24.0, 8
179 %result = srem i32 %num.i24, %den.i24
180 store i32 %result, i32 addrspace(1)* %out, align 4
184 ; FUNC-LABEL: {{^}}no_srem25_i32:
185 ; SI-NOT: v_cvt_f32_i32
190 define amdgpu_kernel void @no_srem25_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
191 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
192 %num = load i32, i32 addrspace(1) * %in, align 4
193 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
194 %num.i24.0 = shl i32 %num, 7
195 %den.i24.0 = shl i32 %den, 7
196 %num.i24 = ashr i32 %num.i24.0, 7
197 %den.i24 = ashr i32 %den.i24.0, 7
198 %result = srem i32 %num.i24, %den.i24
199 store i32 %result, i32 addrspace(1)* %out, align 4
203 ; FUNC-LABEL: {{^}}no_sdiv25_i24_i25_i32:
204 ; SI-NOT: v_cvt_f32_i32
209 define amdgpu_kernel void @no_sdiv25_i24_i25_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
210 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
211 %num = load i32, i32 addrspace(1) * %in, align 4
212 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
213 %num.i24.0 = shl i32 %num, 8
214 %den.i25.0 = shl i32 %den, 7
215 %num.i24 = ashr i32 %num.i24.0, 8
216 %den.i25 = ashr i32 %den.i25.0, 7
217 %result = sdiv i32 %num.i24, %den.i25
218 store i32 %result, i32 addrspace(1)* %out, align 4
222 ; FUNC-LABEL: {{^}}no_sdiv25_i25_i24_i32:
223 ; SI-NOT: v_cvt_f32_i32
228 define amdgpu_kernel void @no_sdiv25_i25_i24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
229 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
230 %num = load i32, i32 addrspace(1) * %in, align 4
231 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
232 %num.i25.0 = shl i32 %num, 7
233 %den.i24.0 = shl i32 %den, 8
234 %num.i25 = ashr i32 %num.i25.0, 7
235 %den.i24 = ashr i32 %den.i24.0, 8
236 %result = sdiv i32 %num.i25, %den.i24
237 store i32 %result, i32 addrspace(1)* %out, align 4
241 ; FUNC-LABEL: {{^}}no_srem25_i24_i25_i32:
242 ; SI-NOT: v_cvt_f32_i32
247 define amdgpu_kernel void @no_srem25_i24_i25_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
248 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
249 %num = load i32, i32 addrspace(1) * %in, align 4
250 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
251 %num.i24.0 = shl i32 %num, 8
252 %den.i25.0 = shl i32 %den, 7
253 %num.i24 = ashr i32 %num.i24.0, 8
254 %den.i25 = ashr i32 %den.i25.0, 7
255 %result = srem i32 %num.i24, %den.i25
256 store i32 %result, i32 addrspace(1)* %out, align 4
260 ; FUNC-LABEL: {{^}}no_srem25_i25_i24_i32:
261 ; SI-NOT: v_cvt_f32_i32
266 define amdgpu_kernel void @no_srem25_i25_i24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
267 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
268 %num = load i32, i32 addrspace(1) * %in, align 4
269 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
270 %num.i25.0 = shl i32 %num, 7
271 %den.i24.0 = shl i32 %den, 8
272 %num.i25 = ashr i32 %num.i25.0, 7
273 %den.i24 = ashr i32 %den.i24.0, 8
274 %result = srem i32 %num.i25, %den.i24
275 store i32 %result, i32 addrspace(1)* %out, align 4
279 ; FUNC-LABEL: {{^}}srem25_i24_i11_i32:
281 ; SI: v_rcp_iflag_f32
282 ; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 24
286 define amdgpu_kernel void @srem25_i24_i11_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
287 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
288 %num = load i32, i32 addrspace(1) * %in, align 4
289 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
290 %num.i24.0 = shl i32 %num, 8
291 %den.i11.0 = shl i32 %den, 21
292 %num.i24 = ashr i32 %num.i24.0, 8
293 %den.i11 = ashr i32 %den.i11.0, 21
294 %result = srem i32 %num.i24, %den.i11
295 store i32 %result, i32 addrspace(1)* %out, align 4
299 ; FUNC-LABEL: {{^}}srem25_i11_i24_i32:
301 ; SI: v_rcp_iflag_f32
302 ; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 24
306 define amdgpu_kernel void @srem25_i11_i24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
307 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
308 %num = load i32, i32 addrspace(1) * %in, align 4
309 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
310 %num.i11.0 = shl i32 %num, 21
311 %den.i24.0 = shl i32 %den, 8
312 %num.i11 = ashr i32 %num.i11.0, 21
313 %den.i24 = ashr i32 %den.i24.0, 8
314 %result = srem i32 %num.i11, %den.i24
315 store i32 %result, i32 addrspace(1)* %out, align 4
319 ; FUNC-LABEL: {{^}}srem25_i17_i12_i32:
321 ; SI: v_rcp_iflag_f32
322 ; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 17
326 define amdgpu_kernel void @srem25_i17_i12_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
327 %den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
328 %num = load i32, i32 addrspace(1) * %in, align 4
329 %den = load i32, i32 addrspace(1) * %den_ptr, align 4
330 %num.i17.0 = shl i32 %num, 15
331 %den.i12.0 = shl i32 %den, 20
332 %num.i17 = ashr i32 %num.i17.0, 15
333 %den.i12 = ashr i32 %den.i12.0, 20
334 %result = sdiv i32 %num.i17, %den.i12
335 store i32 %result, i32 addrspace(1)* %out, align 4