1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-- -mcpu=tahiti -amdgpu-codegenprepare -amdgpu-bypass-slow-div=0 %s | FileCheck %s
3 ; RUN: llc -mtriple=amdgcn-- -mcpu=tahiti -amdgpu-bypass-slow-div=0 < %s | FileCheck -check-prefix=GFX6 %s
4 ; RUN: llc -mtriple=amdgcn-- -mcpu=gfx900 -amdgpu-bypass-slow-div=0 < %s | FileCheck -check-prefix=GFX9 %s
6 define amdgpu_kernel void @udiv_i32(ptr addrspace(1) %out, i32 %x, i32 %y) {
7 ; CHECK-LABEL: @udiv_i32(
8 ; CHECK-NEXT: [[TMP1:%.*]] = uitofp i32 [[Y:%.*]] to float
9 ; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP1]])
10 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast float [[TMP2]], 0x41EFFFFFC0000000
11 ; CHECK-NEXT: [[TMP4:%.*]] = fptoui float [[TMP3]] to i32
12 ; CHECK-NEXT: [[TMP5:%.*]] = sub i32 0, [[Y]]
13 ; CHECK-NEXT: [[TMP6:%.*]] = mul i32 [[TMP5]], [[TMP4]]
14 ; CHECK-NEXT: [[TMP7:%.*]] = zext i32 [[TMP4]] to i64
15 ; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP6]] to i64
16 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP7]], [[TMP8]]
17 ; CHECK-NEXT: [[TMP10:%.*]] = trunc i64 [[TMP9]] to i32
18 ; CHECK-NEXT: [[TMP11:%.*]] = lshr i64 [[TMP9]], 32
19 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
20 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP4]], [[TMP12]]
21 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[X:%.*]] to i64
22 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP13]] to i64
23 ; CHECK-NEXT: [[TMP16:%.*]] = mul i64 [[TMP14]], [[TMP15]]
24 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i32
25 ; CHECK-NEXT: [[TMP18:%.*]] = lshr i64 [[TMP16]], 32
26 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
27 ; CHECK-NEXT: [[TMP20:%.*]] = mul i32 [[TMP19]], [[Y]]
28 ; CHECK-NEXT: [[TMP21:%.*]] = sub i32 [[X]], [[TMP20]]
29 ; CHECK-NEXT: [[TMP22:%.*]] = icmp uge i32 [[TMP21]], [[Y]]
30 ; CHECK-NEXT: [[TMP23:%.*]] = add i32 [[TMP19]], 1
31 ; CHECK-NEXT: [[TMP24:%.*]] = select i1 [[TMP22]], i32 [[TMP23]], i32 [[TMP19]]
32 ; CHECK-NEXT: [[TMP25:%.*]] = sub i32 [[TMP21]], [[Y]]
33 ; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP22]], i32 [[TMP25]], i32 [[TMP21]]
34 ; CHECK-NEXT: [[TMP27:%.*]] = icmp uge i32 [[TMP26]], [[Y]]
35 ; CHECK-NEXT: [[TMP28:%.*]] = add i32 [[TMP24]], 1
36 ; CHECK-NEXT: [[TMP29:%.*]] = select i1 [[TMP27]], i32 [[TMP28]], i32 [[TMP24]]
37 ; CHECK-NEXT: store i32 [[TMP29]], ptr addrspace(1) [[OUT:%.*]], align 4
38 ; CHECK-NEXT: ret void
40 ; GFX6-LABEL: udiv_i32:
42 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
43 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
44 ; GFX6-NEXT: s_mov_b32 s6, -1
45 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
46 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s3
47 ; GFX6-NEXT: s_sub_i32 s4, 0, s3
48 ; GFX6-NEXT: s_mov_b32 s5, s1
49 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
50 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
51 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
52 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v0
53 ; GFX6-NEXT: s_mov_b32 s4, s0
54 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
55 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
56 ; GFX6-NEXT: v_mul_hi_u32 v0, s2, v0
57 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
58 ; GFX6-NEXT: s_mul_i32 s0, s0, s3
59 ; GFX6-NEXT: s_sub_i32 s0, s2, s0
60 ; GFX6-NEXT: s_sub_i32 s1, s0, s3
61 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
62 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
63 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
64 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
65 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
66 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
67 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
68 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
69 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
70 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
73 ; GFX9-LABEL: udiv_i32:
75 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
76 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
77 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
78 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s7
79 ; GFX9-NEXT: s_sub_i32 s0, 0, s7
80 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
81 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
82 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
83 ; GFX9-NEXT: v_readfirstlane_b32 s1, v0
84 ; GFX9-NEXT: s_mul_i32 s0, s0, s1
85 ; GFX9-NEXT: s_mul_hi_u32 s0, s1, s0
86 ; GFX9-NEXT: s_add_i32 s1, s1, s0
87 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s1
88 ; GFX9-NEXT: s_mul_i32 s1, s0, s7
89 ; GFX9-NEXT: s_sub_i32 s1, s6, s1
90 ; GFX9-NEXT: s_add_i32 s2, s0, 1
91 ; GFX9-NEXT: s_sub_i32 s3, s1, s7
92 ; GFX9-NEXT: s_cmp_ge_u32 s1, s7
93 ; GFX9-NEXT: s_cselect_b32 s0, s2, s0
94 ; GFX9-NEXT: s_cselect_b32 s1, s3, s1
95 ; GFX9-NEXT: s_add_i32 s2, s0, 1
96 ; GFX9-NEXT: s_cmp_ge_u32 s1, s7
97 ; GFX9-NEXT: s_cselect_b32 s0, s2, s0
98 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
99 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
100 ; GFX9-NEXT: s_endpgm
102 store i32 %r, ptr addrspace(1) %out
106 define amdgpu_kernel void @urem_i32(ptr addrspace(1) %out, i32 %x, i32 %y) {
107 ; CHECK-LABEL: @urem_i32(
108 ; CHECK-NEXT: [[TMP1:%.*]] = uitofp i32 [[Y:%.*]] to float
109 ; CHECK-NEXT: [[TMP2:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP1]])
110 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast float [[TMP2]], 0x41EFFFFFC0000000
111 ; CHECK-NEXT: [[TMP4:%.*]] = fptoui float [[TMP3]] to i32
112 ; CHECK-NEXT: [[TMP5:%.*]] = sub i32 0, [[Y]]
113 ; CHECK-NEXT: [[TMP6:%.*]] = mul i32 [[TMP5]], [[TMP4]]
114 ; CHECK-NEXT: [[TMP7:%.*]] = zext i32 [[TMP4]] to i64
115 ; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP6]] to i64
116 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP7]], [[TMP8]]
117 ; CHECK-NEXT: [[TMP10:%.*]] = trunc i64 [[TMP9]] to i32
118 ; CHECK-NEXT: [[TMP11:%.*]] = lshr i64 [[TMP9]], 32
119 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
120 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP4]], [[TMP12]]
121 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[X:%.*]] to i64
122 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP13]] to i64
123 ; CHECK-NEXT: [[TMP16:%.*]] = mul i64 [[TMP14]], [[TMP15]]
124 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i32
125 ; CHECK-NEXT: [[TMP18:%.*]] = lshr i64 [[TMP16]], 32
126 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
127 ; CHECK-NEXT: [[TMP20:%.*]] = mul i32 [[TMP19]], [[Y]]
128 ; CHECK-NEXT: [[TMP21:%.*]] = sub i32 [[X]], [[TMP20]]
129 ; CHECK-NEXT: [[TMP22:%.*]] = icmp uge i32 [[TMP21]], [[Y]]
130 ; CHECK-NEXT: [[TMP23:%.*]] = sub i32 [[TMP21]], [[Y]]
131 ; CHECK-NEXT: [[TMP24:%.*]] = select i1 [[TMP22]], i32 [[TMP23]], i32 [[TMP21]]
132 ; CHECK-NEXT: [[TMP25:%.*]] = icmp uge i32 [[TMP24]], [[Y]]
133 ; CHECK-NEXT: [[TMP26:%.*]] = sub i32 [[TMP24]], [[Y]]
134 ; CHECK-NEXT: [[TMP27:%.*]] = select i1 [[TMP25]], i32 [[TMP26]], i32 [[TMP24]]
135 ; CHECK-NEXT: store i32 [[TMP27]], ptr addrspace(1) [[OUT:%.*]], align 4
136 ; CHECK-NEXT: ret void
138 ; GFX6-LABEL: urem_i32:
140 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
141 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
142 ; GFX6-NEXT: s_mov_b32 s6, -1
143 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
144 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s3
145 ; GFX6-NEXT: s_sub_i32 s4, 0, s3
146 ; GFX6-NEXT: s_mov_b32 s5, s1
147 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
148 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
149 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
150 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v0
151 ; GFX6-NEXT: s_mov_b32 s4, s0
152 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
153 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
154 ; GFX6-NEXT: v_mul_hi_u32 v0, s2, v0
155 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
156 ; GFX6-NEXT: s_mul_i32 s0, s0, s3
157 ; GFX6-NEXT: s_sub_i32 s0, s2, s0
158 ; GFX6-NEXT: s_sub_i32 s1, s0, s3
159 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
160 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
161 ; GFX6-NEXT: s_sub_i32 s1, s0, s3
162 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
163 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
164 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
165 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
166 ; GFX6-NEXT: s_endpgm
168 ; GFX9-LABEL: urem_i32:
170 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
171 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
172 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
173 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s7
174 ; GFX9-NEXT: s_sub_i32 s0, 0, s7
175 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
176 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
177 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
178 ; GFX9-NEXT: v_readfirstlane_b32 s1, v0
179 ; GFX9-NEXT: s_mul_i32 s0, s0, s1
180 ; GFX9-NEXT: s_mul_hi_u32 s0, s1, s0
181 ; GFX9-NEXT: s_add_i32 s1, s1, s0
182 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s1
183 ; GFX9-NEXT: s_mul_i32 s0, s0, s7
184 ; GFX9-NEXT: s_sub_i32 s0, s6, s0
185 ; GFX9-NEXT: s_sub_i32 s1, s0, s7
186 ; GFX9-NEXT: s_cmp_ge_u32 s0, s7
187 ; GFX9-NEXT: s_cselect_b32 s0, s1, s0
188 ; GFX9-NEXT: s_sub_i32 s1, s0, s7
189 ; GFX9-NEXT: s_cmp_ge_u32 s0, s7
190 ; GFX9-NEXT: s_cselect_b32 s0, s1, s0
191 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
192 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
193 ; GFX9-NEXT: s_endpgm
195 store i32 %r, ptr addrspace(1) %out
199 define amdgpu_kernel void @sdiv_i32(ptr addrspace(1) %out, i32 %x, i32 %y) {
200 ; CHECK-LABEL: @sdiv_i32(
201 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 31
202 ; CHECK-NEXT: [[TMP2:%.*]] = ashr i32 [[Y:%.*]], 31
203 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
204 ; CHECK-NEXT: [[TMP4:%.*]] = add i32 [[X]], [[TMP1]]
205 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[Y]], [[TMP2]]
206 ; CHECK-NEXT: [[TMP6:%.*]] = xor i32 [[TMP4]], [[TMP1]]
207 ; CHECK-NEXT: [[TMP7:%.*]] = xor i32 [[TMP5]], [[TMP2]]
208 ; CHECK-NEXT: [[TMP8:%.*]] = uitofp i32 [[TMP7]] to float
209 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP8]])
210 ; CHECK-NEXT: [[TMP10:%.*]] = fmul fast float [[TMP9]], 0x41EFFFFFC0000000
211 ; CHECK-NEXT: [[TMP11:%.*]] = fptoui float [[TMP10]] to i32
212 ; CHECK-NEXT: [[TMP12:%.*]] = sub i32 0, [[TMP7]]
213 ; CHECK-NEXT: [[TMP13:%.*]] = mul i32 [[TMP12]], [[TMP11]]
214 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[TMP11]] to i64
215 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP13]] to i64
216 ; CHECK-NEXT: [[TMP16:%.*]] = mul i64 [[TMP14]], [[TMP15]]
217 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i64 [[TMP16]] to i32
218 ; CHECK-NEXT: [[TMP18:%.*]] = lshr i64 [[TMP16]], 32
219 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
220 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP11]], [[TMP19]]
221 ; CHECK-NEXT: [[TMP21:%.*]] = zext i32 [[TMP6]] to i64
222 ; CHECK-NEXT: [[TMP22:%.*]] = zext i32 [[TMP20]] to i64
223 ; CHECK-NEXT: [[TMP23:%.*]] = mul i64 [[TMP21]], [[TMP22]]
224 ; CHECK-NEXT: [[TMP24:%.*]] = trunc i64 [[TMP23]] to i32
225 ; CHECK-NEXT: [[TMP25:%.*]] = lshr i64 [[TMP23]], 32
226 ; CHECK-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP25]] to i32
227 ; CHECK-NEXT: [[TMP27:%.*]] = mul i32 [[TMP26]], [[TMP7]]
228 ; CHECK-NEXT: [[TMP28:%.*]] = sub i32 [[TMP6]], [[TMP27]]
229 ; CHECK-NEXT: [[TMP29:%.*]] = icmp uge i32 [[TMP28]], [[TMP7]]
230 ; CHECK-NEXT: [[TMP30:%.*]] = add i32 [[TMP26]], 1
231 ; CHECK-NEXT: [[TMP31:%.*]] = select i1 [[TMP29]], i32 [[TMP30]], i32 [[TMP26]]
232 ; CHECK-NEXT: [[TMP32:%.*]] = sub i32 [[TMP28]], [[TMP7]]
233 ; CHECK-NEXT: [[TMP33:%.*]] = select i1 [[TMP29]], i32 [[TMP32]], i32 [[TMP28]]
234 ; CHECK-NEXT: [[TMP34:%.*]] = icmp uge i32 [[TMP33]], [[TMP7]]
235 ; CHECK-NEXT: [[TMP35:%.*]] = add i32 [[TMP31]], 1
236 ; CHECK-NEXT: [[TMP36:%.*]] = select i1 [[TMP34]], i32 [[TMP35]], i32 [[TMP31]]
237 ; CHECK-NEXT: [[TMP37:%.*]] = xor i32 [[TMP36]], [[TMP3]]
238 ; CHECK-NEXT: [[TMP38:%.*]] = sub i32 [[TMP37]], [[TMP3]]
239 ; CHECK-NEXT: store i32 [[TMP38]], ptr addrspace(1) [[OUT:%.*]], align 4
240 ; CHECK-NEXT: ret void
242 ; GFX6-LABEL: sdiv_i32:
244 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
245 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
246 ; GFX6-NEXT: s_mov_b32 s6, -1
247 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
248 ; GFX6-NEXT: s_abs_i32 s8, s3
249 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s8
250 ; GFX6-NEXT: s_sub_i32 s4, 0, s8
251 ; GFX6-NEXT: s_mov_b32 s5, s1
252 ; GFX6-NEXT: s_xor_b32 s1, s2, s3
253 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
254 ; GFX6-NEXT: s_ashr_i32 s1, s1, 31
255 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
256 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
257 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v0
258 ; GFX6-NEXT: s_mov_b32 s4, s0
259 ; GFX6-NEXT: s_abs_i32 s0, s2
260 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
261 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
262 ; GFX6-NEXT: v_mul_hi_u32 v0, s0, v0
263 ; GFX6-NEXT: v_readfirstlane_b32 s2, v0
264 ; GFX6-NEXT: s_mul_i32 s2, s2, s8
265 ; GFX6-NEXT: s_sub_i32 s0, s0, s2
266 ; GFX6-NEXT: s_sub_i32 s2, s0, s8
267 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
268 ; GFX6-NEXT: s_cmp_ge_u32 s0, s8
269 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
270 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
271 ; GFX6-NEXT: s_cselect_b32 s0, s2, s0
272 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
273 ; GFX6-NEXT: s_cmp_ge_u32 s0, s8
274 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
275 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
276 ; GFX6-NEXT: v_xor_b32_e32 v0, s1, v0
277 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s1, v0
278 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
279 ; GFX6-NEXT: s_endpgm
281 ; GFX9-LABEL: sdiv_i32:
283 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
284 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
285 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
286 ; GFX9-NEXT: s_abs_i32 s0, s7
287 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
288 ; GFX9-NEXT: s_xor_b32 s1, s6, s7
289 ; GFX9-NEXT: s_abs_i32 s2, s6
290 ; GFX9-NEXT: s_sub_i32 s3, 0, s0
291 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
292 ; GFX9-NEXT: s_ashr_i32 s1, s1, 31
293 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
294 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
295 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
296 ; GFX9-NEXT: s_mul_i32 s3, s3, s6
297 ; GFX9-NEXT: s_mul_hi_u32 s3, s6, s3
298 ; GFX9-NEXT: s_add_i32 s6, s6, s3
299 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, s6
300 ; GFX9-NEXT: s_mul_i32 s6, s3, s0
301 ; GFX9-NEXT: s_sub_i32 s2, s2, s6
302 ; GFX9-NEXT: s_add_i32 s7, s3, 1
303 ; GFX9-NEXT: s_sub_i32 s6, s2, s0
304 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
305 ; GFX9-NEXT: s_cselect_b32 s3, s7, s3
306 ; GFX9-NEXT: s_cselect_b32 s2, s6, s2
307 ; GFX9-NEXT: s_add_i32 s6, s3, 1
308 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
309 ; GFX9-NEXT: s_cselect_b32 s0, s6, s3
310 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
311 ; GFX9-NEXT: s_sub_i32 s0, s0, s1
312 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
313 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
314 ; GFX9-NEXT: s_endpgm
316 store i32 %r, ptr addrspace(1) %out
320 define amdgpu_kernel void @srem_i32(ptr addrspace(1) %out, i32 %x, i32 %y) {
321 ; CHECK-LABEL: @srem_i32(
322 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 31
323 ; CHECK-NEXT: [[TMP2:%.*]] = ashr i32 [[Y:%.*]], 31
324 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[X]], [[TMP1]]
325 ; CHECK-NEXT: [[TMP4:%.*]] = add i32 [[Y]], [[TMP2]]
326 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP1]]
327 ; CHECK-NEXT: [[TMP6:%.*]] = xor i32 [[TMP4]], [[TMP2]]
328 ; CHECK-NEXT: [[TMP7:%.*]] = uitofp i32 [[TMP6]] to float
329 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
330 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP8]], 0x41EFFFFFC0000000
331 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP9]] to i32
332 ; CHECK-NEXT: [[TMP11:%.*]] = sub i32 0, [[TMP6]]
333 ; CHECK-NEXT: [[TMP12:%.*]] = mul i32 [[TMP11]], [[TMP10]]
334 ; CHECK-NEXT: [[TMP13:%.*]] = zext i32 [[TMP10]] to i64
335 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[TMP12]] to i64
336 ; CHECK-NEXT: [[TMP15:%.*]] = mul i64 [[TMP13]], [[TMP14]]
337 ; CHECK-NEXT: [[TMP16:%.*]] = trunc i64 [[TMP15]] to i32
338 ; CHECK-NEXT: [[TMP17:%.*]] = lshr i64 [[TMP15]], 32
339 ; CHECK-NEXT: [[TMP18:%.*]] = trunc i64 [[TMP17]] to i32
340 ; CHECK-NEXT: [[TMP19:%.*]] = add i32 [[TMP10]], [[TMP18]]
341 ; CHECK-NEXT: [[TMP20:%.*]] = zext i32 [[TMP5]] to i64
342 ; CHECK-NEXT: [[TMP21:%.*]] = zext i32 [[TMP19]] to i64
343 ; CHECK-NEXT: [[TMP22:%.*]] = mul i64 [[TMP20]], [[TMP21]]
344 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i64 [[TMP22]] to i32
345 ; CHECK-NEXT: [[TMP24:%.*]] = lshr i64 [[TMP22]], 32
346 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i64 [[TMP24]] to i32
347 ; CHECK-NEXT: [[TMP26:%.*]] = mul i32 [[TMP25]], [[TMP6]]
348 ; CHECK-NEXT: [[TMP27:%.*]] = sub i32 [[TMP5]], [[TMP26]]
349 ; CHECK-NEXT: [[TMP28:%.*]] = icmp uge i32 [[TMP27]], [[TMP6]]
350 ; CHECK-NEXT: [[TMP29:%.*]] = sub i32 [[TMP27]], [[TMP6]]
351 ; CHECK-NEXT: [[TMP30:%.*]] = select i1 [[TMP28]], i32 [[TMP29]], i32 [[TMP27]]
352 ; CHECK-NEXT: [[TMP31:%.*]] = icmp uge i32 [[TMP30]], [[TMP6]]
353 ; CHECK-NEXT: [[TMP32:%.*]] = sub i32 [[TMP30]], [[TMP6]]
354 ; CHECK-NEXT: [[TMP33:%.*]] = select i1 [[TMP31]], i32 [[TMP32]], i32 [[TMP30]]
355 ; CHECK-NEXT: [[TMP34:%.*]] = xor i32 [[TMP33]], [[TMP1]]
356 ; CHECK-NEXT: [[TMP35:%.*]] = sub i32 [[TMP34]], [[TMP1]]
357 ; CHECK-NEXT: store i32 [[TMP35]], ptr addrspace(1) [[OUT:%.*]], align 4
358 ; CHECK-NEXT: ret void
360 ; GFX6-LABEL: srem_i32:
362 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
363 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
364 ; GFX6-NEXT: s_mov_b32 s6, -1
365 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
366 ; GFX6-NEXT: s_abs_i32 s3, s3
367 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s3
368 ; GFX6-NEXT: s_sub_i32 s4, 0, s3
369 ; GFX6-NEXT: s_abs_i32 s8, s2
370 ; GFX6-NEXT: s_mov_b32 s5, s1
371 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
372 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
373 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
374 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v0
375 ; GFX6-NEXT: s_mov_b32 s4, s0
376 ; GFX6-NEXT: s_ashr_i32 s0, s2, 31
377 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
378 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
379 ; GFX6-NEXT: v_mul_hi_u32 v0, s8, v0
380 ; GFX6-NEXT: v_readfirstlane_b32 s1, v0
381 ; GFX6-NEXT: s_mul_i32 s1, s1, s3
382 ; GFX6-NEXT: s_sub_i32 s1, s8, s1
383 ; GFX6-NEXT: s_sub_i32 s2, s1, s3
384 ; GFX6-NEXT: s_cmp_ge_u32 s1, s3
385 ; GFX6-NEXT: s_cselect_b32 s1, s2, s1
386 ; GFX6-NEXT: s_sub_i32 s2, s1, s3
387 ; GFX6-NEXT: s_cmp_ge_u32 s1, s3
388 ; GFX6-NEXT: s_cselect_b32 s1, s2, s1
389 ; GFX6-NEXT: s_xor_b32 s1, s1, s0
390 ; GFX6-NEXT: s_sub_i32 s0, s1, s0
391 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
392 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
393 ; GFX6-NEXT: s_endpgm
395 ; GFX9-LABEL: srem_i32:
397 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
398 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
399 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
400 ; GFX9-NEXT: s_abs_i32 s0, s7
401 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
402 ; GFX9-NEXT: s_ashr_i32 s1, s6, 31
403 ; GFX9-NEXT: s_abs_i32 s2, s6
404 ; GFX9-NEXT: s_sub_i32 s3, 0, s0
405 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
406 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
407 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
408 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
409 ; GFX9-NEXT: s_mul_i32 s3, s3, s6
410 ; GFX9-NEXT: s_mul_hi_u32 s3, s6, s3
411 ; GFX9-NEXT: s_add_i32 s6, s6, s3
412 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, s6
413 ; GFX9-NEXT: s_mul_i32 s3, s3, s0
414 ; GFX9-NEXT: s_sub_i32 s2, s2, s3
415 ; GFX9-NEXT: s_sub_i32 s3, s2, s0
416 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
417 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
418 ; GFX9-NEXT: s_sub_i32 s3, s2, s0
419 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
420 ; GFX9-NEXT: s_cselect_b32 s0, s3, s2
421 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
422 ; GFX9-NEXT: s_sub_i32 s0, s0, s1
423 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
424 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
425 ; GFX9-NEXT: s_endpgm
427 store i32 %r, ptr addrspace(1) %out
431 define amdgpu_kernel void @udiv_i16(ptr addrspace(1) %out, i16 %x, i16 %y) {
432 ; CHECK-LABEL: @udiv_i16(
433 ; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[X:%.*]] to i32
434 ; CHECK-NEXT: [[TMP2:%.*]] = zext i16 [[Y:%.*]] to i32
435 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
436 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
437 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
438 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
439 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
440 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
441 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
442 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
443 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
444 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
445 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
446 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
447 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
448 ; CHECK-NEXT: [[TMP16:%.*]] = and i32 [[TMP15]], 65535
449 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i32 [[TMP16]] to i16
450 ; CHECK-NEXT: store i16 [[TMP17]], ptr addrspace(1) [[OUT:%.*]], align 2
451 ; CHECK-NEXT: ret void
453 ; GFX6-LABEL: udiv_i16:
455 ; GFX6-NEXT: s_load_dword s0, s[2:3], 0xb
456 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
457 ; GFX6-NEXT: s_lshr_b32 s1, s0, 16
458 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s1
459 ; GFX6-NEXT: s_and_b32 s0, s0, 0xffff
460 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s0
461 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
462 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
463 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
464 ; GFX6-NEXT: s_mov_b32 s2, -1
465 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
466 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
467 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v2
468 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
469 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
470 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
471 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
472 ; GFX6-NEXT: buffer_store_short v0, off, s[0:3], 0
473 ; GFX6-NEXT: s_endpgm
475 ; GFX9-LABEL: udiv_i16:
477 ; GFX9-NEXT: s_load_dword s0, s[2:3], 0x2c
478 ; GFX9-NEXT: v_mov_b32_e32 v3, 0
479 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
480 ; GFX9-NEXT: s_lshr_b32 s1, s0, 16
481 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
482 ; GFX9-NEXT: s_and_b32 s0, s0, 0xffff
483 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s0
484 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
485 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
486 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
487 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
488 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v2
489 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
490 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
491 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v4, vcc
492 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
493 ; GFX9-NEXT: global_store_short v3, v0, s[0:1]
494 ; GFX9-NEXT: s_endpgm
496 store i16 %r, ptr addrspace(1) %out
500 define amdgpu_kernel void @urem_i16(ptr addrspace(1) %out, i16 %x, i16 %y) {
501 ; CHECK-LABEL: @urem_i16(
502 ; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[X:%.*]] to i32
503 ; CHECK-NEXT: [[TMP2:%.*]] = zext i16 [[Y:%.*]] to i32
504 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
505 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
506 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
507 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
508 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
509 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
510 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
511 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
512 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
513 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
514 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
515 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
516 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
517 ; CHECK-NEXT: [[TMP16:%.*]] = mul i32 [[TMP15]], [[TMP2]]
518 ; CHECK-NEXT: [[TMP17:%.*]] = sub i32 [[TMP1]], [[TMP16]]
519 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 65535
520 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i16
521 ; CHECK-NEXT: store i16 [[TMP19]], ptr addrspace(1) [[OUT:%.*]], align 2
522 ; CHECK-NEXT: ret void
524 ; GFX6-LABEL: urem_i16:
526 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
527 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
528 ; GFX6-NEXT: s_lshr_b32 s5, s4, 16
529 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s5
530 ; GFX6-NEXT: s_and_b32 s0, s4, 0xffff
531 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s0
532 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
533 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
534 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
535 ; GFX6-NEXT: s_mov_b32 s2, -1
536 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
537 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
538 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v2
539 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
540 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
541 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
542 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s5
543 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
544 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
545 ; GFX6-NEXT: buffer_store_short v0, off, s[0:3], 0
546 ; GFX6-NEXT: s_endpgm
548 ; GFX9-LABEL: urem_i16:
550 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
551 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
552 ; GFX9-NEXT: s_lshr_b32 s5, s4, 16
553 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s5
554 ; GFX9-NEXT: s_and_b32 s0, s4, 0xffff
555 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s0
556 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
557 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
558 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
559 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
560 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v2
561 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
562 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
563 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
564 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v3, vcc
565 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s5
566 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
567 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
568 ; GFX9-NEXT: global_store_short v1, v0, s[0:1]
569 ; GFX9-NEXT: s_endpgm
571 store i16 %r, ptr addrspace(1) %out
575 define amdgpu_kernel void @sdiv_i16(ptr addrspace(1) %out, i16 %x, i16 %y) {
576 ; CHECK-LABEL: @sdiv_i16(
577 ; CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[X:%.*]] to i32
578 ; CHECK-NEXT: [[TMP2:%.*]] = sext i16 [[Y:%.*]] to i32
579 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
580 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
581 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
582 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
583 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
584 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
585 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
586 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
587 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
588 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
589 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
590 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
591 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
592 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
593 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
594 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
595 ; CHECK-NEXT: [[TMP19:%.*]] = shl i32 [[TMP18]], 16
596 ; CHECK-NEXT: [[TMP20:%.*]] = ashr i32 [[TMP19]], 16
597 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i16
598 ; CHECK-NEXT: store i16 [[TMP21]], ptr addrspace(1) [[OUT:%.*]], align 2
599 ; CHECK-NEXT: ret void
601 ; GFX6-LABEL: sdiv_i16:
603 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
604 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
605 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
606 ; GFX6-NEXT: s_mov_b32 s2, -1
607 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
608 ; GFX6-NEXT: s_ashr_i32 s5, s4, 16
609 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s5
610 ; GFX6-NEXT: s_sext_i32_i16 s4, s4
611 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s4
612 ; GFX6-NEXT: s_xor_b32 s4, s4, s5
613 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
614 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
615 ; GFX6-NEXT: s_or_b32 s6, s4, 1
616 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
617 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
618 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
619 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
620 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[4:5], |v1|, |v0|
621 ; GFX6-NEXT: s_and_b64 s[4:5], s[4:5], exec
622 ; GFX6-NEXT: s_cselect_b32 s4, s6, 0
623 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v2
624 ; GFX6-NEXT: buffer_store_short v0, off, s[0:3], 0
625 ; GFX6-NEXT: s_endpgm
627 ; GFX9-LABEL: sdiv_i16:
629 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
630 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
631 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
632 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
633 ; GFX9-NEXT: s_ashr_i32 s2, s4, 16
634 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
635 ; GFX9-NEXT: s_sext_i32_i16 s3, s4
636 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s3
637 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
638 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
639 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
640 ; GFX9-NEXT: s_or_b32 s4, s2, 1
641 ; GFX9-NEXT: v_mul_f32_e32 v3, v2, v3
642 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
643 ; GFX9-NEXT: v_mad_f32 v2, -v3, v0, v2
644 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
645 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v2|, |v0|
646 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
647 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
648 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v3
649 ; GFX9-NEXT: global_store_short v1, v0, s[0:1]
650 ; GFX9-NEXT: s_endpgm
652 store i16 %r, ptr addrspace(1) %out
656 define amdgpu_kernel void @srem_i16(ptr addrspace(1) %out, i16 %x, i16 %y) {
657 ; CHECK-LABEL: @srem_i16(
658 ; CHECK-NEXT: [[TMP1:%.*]] = sext i16 [[X:%.*]] to i32
659 ; CHECK-NEXT: [[TMP2:%.*]] = sext i16 [[Y:%.*]] to i32
660 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
661 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
662 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
663 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
664 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
665 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
666 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
667 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
668 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
669 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
670 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
671 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
672 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
673 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
674 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
675 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
676 ; CHECK-NEXT: [[TMP19:%.*]] = mul i32 [[TMP18]], [[TMP2]]
677 ; CHECK-NEXT: [[TMP20:%.*]] = sub i32 [[TMP1]], [[TMP19]]
678 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 16
679 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 16
680 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i16
681 ; CHECK-NEXT: store i16 [[TMP23]], ptr addrspace(1) [[OUT:%.*]], align 2
682 ; CHECK-NEXT: ret void
684 ; GFX6-LABEL: srem_i16:
686 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
687 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
688 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
689 ; GFX6-NEXT: s_ashr_i32 s5, s4, 16
690 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s5
691 ; GFX6-NEXT: s_sext_i32_i16 s2, s4
692 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s2
693 ; GFX6-NEXT: s_xor_b32 s2, s2, s5
694 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
695 ; GFX6-NEXT: s_ashr_i32 s2, s2, 30
696 ; GFX6-NEXT: s_or_b32 s6, s2, 1
697 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
698 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
699 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
700 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
701 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
702 ; GFX6-NEXT: s_and_b64 s[2:3], s[2:3], exec
703 ; GFX6-NEXT: s_cselect_b32 s2, s6, 0
704 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s2, v2
705 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s5
706 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
707 ; GFX6-NEXT: s_mov_b32 s2, -1
708 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
709 ; GFX6-NEXT: buffer_store_short v0, off, s[0:3], 0
710 ; GFX6-NEXT: s_endpgm
712 ; GFX9-LABEL: srem_i16:
714 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
715 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
716 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
717 ; GFX9-NEXT: s_ashr_i32 s5, s4, 16
718 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s5
719 ; GFX9-NEXT: s_sext_i32_i16 s2, s4
720 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s2
721 ; GFX9-NEXT: s_xor_b32 s2, s2, s5
722 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
723 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
724 ; GFX9-NEXT: s_or_b32 s6, s2, 1
725 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
726 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
727 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
728 ; GFX9-NEXT: v_cvt_i32_f32_e32 v2, v2
729 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
730 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
731 ; GFX9-NEXT: s_cselect_b32 s2, s6, 0
732 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v2
733 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s5
734 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
735 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
736 ; GFX9-NEXT: global_store_short v1, v0, s[0:1]
737 ; GFX9-NEXT: s_endpgm
739 store i16 %r, ptr addrspace(1) %out
743 define amdgpu_kernel void @udiv_i8(ptr addrspace(1) %out, i8 %x, i8 %y) {
744 ; CHECK-LABEL: @udiv_i8(
745 ; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i32
746 ; CHECK-NEXT: [[TMP2:%.*]] = zext i8 [[Y:%.*]] to i32
747 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
748 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
749 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
750 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
751 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
752 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
753 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
754 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
755 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
756 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
757 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
758 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
759 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
760 ; CHECK-NEXT: [[TMP16:%.*]] = and i32 [[TMP15]], 255
761 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i32 [[TMP16]] to i8
762 ; CHECK-NEXT: store i8 [[TMP17]], ptr addrspace(1) [[OUT:%.*]], align 1
763 ; CHECK-NEXT: ret void
765 ; GFX6-LABEL: udiv_i8:
767 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
768 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
769 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
770 ; GFX6-NEXT: s_mov_b32 s2, -1
771 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
772 ; GFX6-NEXT: v_cvt_f32_ubyte1_e32 v0, s4
773 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v1, v0
774 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v2, s4
775 ; GFX6-NEXT: v_mul_f32_e32 v1, v2, v1
776 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
777 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v1
778 ; GFX6-NEXT: v_mad_f32 v1, -v1, v0, v2
779 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
780 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
781 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
782 ; GFX6-NEXT: s_endpgm
784 ; GFX9-LABEL: udiv_i8:
786 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
787 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
788 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
789 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
790 ; GFX9-NEXT: v_cvt_f32_ubyte1_e32 v0, s4
791 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v0
792 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v3, s4
793 ; GFX9-NEXT: v_mul_f32_e32 v1, v3, v1
794 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
795 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v1
796 ; GFX9-NEXT: v_mad_f32 v1, -v1, v0, v3
797 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
798 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v4, vcc
799 ; GFX9-NEXT: global_store_byte v2, v0, s[0:1]
800 ; GFX9-NEXT: s_endpgm
802 store i8 %r, ptr addrspace(1) %out
806 define amdgpu_kernel void @urem_i8(ptr addrspace(1) %out, i8 %x, i8 %y) {
807 ; CHECK-LABEL: @urem_i8(
808 ; CHECK-NEXT: [[TMP1:%.*]] = zext i8 [[X:%.*]] to i32
809 ; CHECK-NEXT: [[TMP2:%.*]] = zext i8 [[Y:%.*]] to i32
810 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
811 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
812 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
813 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
814 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
815 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
816 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
817 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
818 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
819 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
820 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
821 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
822 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
823 ; CHECK-NEXT: [[TMP16:%.*]] = mul i32 [[TMP15]], [[TMP2]]
824 ; CHECK-NEXT: [[TMP17:%.*]] = sub i32 [[TMP1]], [[TMP16]]
825 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 255
826 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i8
827 ; CHECK-NEXT: store i8 [[TMP19]], ptr addrspace(1) [[OUT:%.*]], align 1
828 ; CHECK-NEXT: ret void
830 ; GFX6-LABEL: urem_i8:
832 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
833 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
834 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
835 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
836 ; GFX6-NEXT: v_cvt_f32_ubyte1_e32 v0, s4
837 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v1, v0
838 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v2, s4
839 ; GFX6-NEXT: s_lshr_b32 s2, s4, 8
840 ; GFX6-NEXT: v_mul_f32_e32 v1, v2, v1
841 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
842 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v1
843 ; GFX6-NEXT: v_mad_f32 v1, -v1, v0, v2
844 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
845 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
846 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s2
847 ; GFX6-NEXT: s_mov_b32 s2, -1
848 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
849 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
850 ; GFX6-NEXT: s_endpgm
852 ; GFX9-LABEL: urem_i8:
854 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
855 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
856 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
857 ; GFX9-NEXT: v_cvt_f32_ubyte1_e32 v0, s4
858 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v0
859 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v2, s4
860 ; GFX9-NEXT: s_lshr_b32 s2, s4, 8
861 ; GFX9-NEXT: v_mul_f32_e32 v1, v2, v1
862 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
863 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v1
864 ; GFX9-NEXT: v_mad_f32 v1, -v1, v0, v2
865 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
866 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
867 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v3, vcc
868 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s2
869 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
870 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
871 ; GFX9-NEXT: s_endpgm
873 store i8 %r, ptr addrspace(1) %out
877 define amdgpu_kernel void @sdiv_i8(ptr addrspace(1) %out, i8 %x, i8 %y) {
878 ; CHECK-LABEL: @sdiv_i8(
879 ; CHECK-NEXT: [[TMP1:%.*]] = sext i8 [[X:%.*]] to i32
880 ; CHECK-NEXT: [[TMP2:%.*]] = sext i8 [[Y:%.*]] to i32
881 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
882 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
883 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
884 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
885 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
886 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
887 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
888 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
889 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
890 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
891 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
892 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
893 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
894 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
895 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
896 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
897 ; CHECK-NEXT: [[TMP19:%.*]] = shl i32 [[TMP18]], 24
898 ; CHECK-NEXT: [[TMP20:%.*]] = ashr i32 [[TMP19]], 24
899 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i8
900 ; CHECK-NEXT: store i8 [[TMP21]], ptr addrspace(1) [[OUT:%.*]], align 1
901 ; CHECK-NEXT: ret void
903 ; GFX6-LABEL: sdiv_i8:
905 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
906 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
907 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
908 ; GFX6-NEXT: s_mov_b32 s2, -1
909 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
910 ; GFX6-NEXT: s_bfe_i32 s5, s4, 0x80008
911 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s5
912 ; GFX6-NEXT: s_sext_i32_i8 s4, s4
913 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s4
914 ; GFX6-NEXT: s_xor_b32 s4, s4, s5
915 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
916 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
917 ; GFX6-NEXT: s_or_b32 s6, s4, 1
918 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
919 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
920 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
921 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
922 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[4:5], |v1|, |v0|
923 ; GFX6-NEXT: s_and_b64 s[4:5], s[4:5], exec
924 ; GFX6-NEXT: s_cselect_b32 s4, s6, 0
925 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v2
926 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
927 ; GFX6-NEXT: s_endpgm
929 ; GFX9-LABEL: sdiv_i8:
931 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
932 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
933 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
934 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
935 ; GFX9-NEXT: s_bfe_i32 s2, s4, 0x80008
936 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
937 ; GFX9-NEXT: s_sext_i32_i8 s3, s4
938 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s3
939 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
940 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
941 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
942 ; GFX9-NEXT: s_or_b32 s4, s2, 1
943 ; GFX9-NEXT: v_mul_f32_e32 v3, v2, v3
944 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
945 ; GFX9-NEXT: v_mad_f32 v2, -v3, v0, v2
946 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
947 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v2|, |v0|
948 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
949 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
950 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v3
951 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
952 ; GFX9-NEXT: s_endpgm
954 store i8 %r, ptr addrspace(1) %out
958 define amdgpu_kernel void @srem_i8(ptr addrspace(1) %out, i8 %x, i8 %y) {
959 ; CHECK-LABEL: @srem_i8(
960 ; CHECK-NEXT: [[TMP1:%.*]] = sext i8 [[X:%.*]] to i32
961 ; CHECK-NEXT: [[TMP2:%.*]] = sext i8 [[Y:%.*]] to i32
962 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
963 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
964 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
965 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
966 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
967 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
968 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
969 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
970 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
971 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
972 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
973 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
974 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
975 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
976 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
977 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
978 ; CHECK-NEXT: [[TMP19:%.*]] = mul i32 [[TMP18]], [[TMP2]]
979 ; CHECK-NEXT: [[TMP20:%.*]] = sub i32 [[TMP1]], [[TMP19]]
980 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 24
981 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 24
982 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i8
983 ; CHECK-NEXT: store i8 [[TMP23]], ptr addrspace(1) [[OUT:%.*]], align 1
984 ; CHECK-NEXT: ret void
986 ; GFX6-LABEL: srem_i8:
988 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
989 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
990 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
991 ; GFX6-NEXT: s_bfe_i32 s2, s4, 0x80008
992 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s2
993 ; GFX6-NEXT: s_sext_i32_i8 s3, s4
994 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s3
995 ; GFX6-NEXT: s_xor_b32 s2, s3, s2
996 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
997 ; GFX6-NEXT: s_ashr_i32 s2, s2, 30
998 ; GFX6-NEXT: s_lshr_b32 s5, s4, 8
999 ; GFX6-NEXT: s_or_b32 s6, s2, 1
1000 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
1001 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
1002 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
1003 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
1004 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
1005 ; GFX6-NEXT: s_and_b64 s[2:3], s[2:3], exec
1006 ; GFX6-NEXT: s_cselect_b32 s2, s6, 0
1007 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s2, v2
1008 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s5
1009 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
1010 ; GFX6-NEXT: s_mov_b32 s2, -1
1011 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
1012 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
1013 ; GFX6-NEXT: s_endpgm
1015 ; GFX9-LABEL: srem_i8:
1017 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
1018 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
1019 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
1020 ; GFX9-NEXT: s_bfe_i32 s2, s4, 0x80008
1021 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
1022 ; GFX9-NEXT: s_sext_i32_i8 s3, s4
1023 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s3
1024 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
1025 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
1026 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
1027 ; GFX9-NEXT: s_lshr_b32 s5, s4, 8
1028 ; GFX9-NEXT: s_or_b32 s6, s2, 1
1029 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
1030 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
1031 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
1032 ; GFX9-NEXT: v_cvt_i32_f32_e32 v2, v2
1033 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
1034 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
1035 ; GFX9-NEXT: s_cselect_b32 s2, s6, 0
1036 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v2
1037 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s5
1038 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
1039 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
1040 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
1041 ; GFX9-NEXT: s_endpgm
1043 store i8 %r, ptr addrspace(1) %out
1047 define amdgpu_kernel void @udiv_v4i32(ptr addrspace(1) %out, <4 x i32> %x, <4 x i32> %y) {
1048 ; CHECK-LABEL: @udiv_v4i32(
1049 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[X:%.*]], i64 0
1050 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[Y:%.*]], i64 0
1051 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP2]] to float
1052 ; CHECK-NEXT: [[TMP4:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP3]])
1053 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast float [[TMP4]], 0x41EFFFFFC0000000
1054 ; CHECK-NEXT: [[TMP6:%.*]] = fptoui float [[TMP5]] to i32
1055 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 0, [[TMP2]]
1056 ; CHECK-NEXT: [[TMP8:%.*]] = mul i32 [[TMP7]], [[TMP6]]
1057 ; CHECK-NEXT: [[TMP9:%.*]] = zext i32 [[TMP6]] to i64
1058 ; CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP8]] to i64
1059 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP9]], [[TMP10]]
1060 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
1061 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i64 [[TMP11]], 32
1062 ; CHECK-NEXT: [[TMP14:%.*]] = trunc i64 [[TMP13]] to i32
1063 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP6]], [[TMP14]]
1064 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP1]] to i64
1065 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
1066 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
1067 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
1068 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
1069 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
1070 ; CHECK-NEXT: [[TMP22:%.*]] = mul i32 [[TMP21]], [[TMP2]]
1071 ; CHECK-NEXT: [[TMP23:%.*]] = sub i32 [[TMP1]], [[TMP22]]
1072 ; CHECK-NEXT: [[TMP24:%.*]] = icmp uge i32 [[TMP23]], [[TMP2]]
1073 ; CHECK-NEXT: [[TMP25:%.*]] = add i32 [[TMP21]], 1
1074 ; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP24]], i32 [[TMP25]], i32 [[TMP21]]
1075 ; CHECK-NEXT: [[TMP27:%.*]] = sub i32 [[TMP23]], [[TMP2]]
1076 ; CHECK-NEXT: [[TMP28:%.*]] = select i1 [[TMP24]], i32 [[TMP27]], i32 [[TMP23]]
1077 ; CHECK-NEXT: [[TMP29:%.*]] = icmp uge i32 [[TMP28]], [[TMP2]]
1078 ; CHECK-NEXT: [[TMP30:%.*]] = add i32 [[TMP26]], 1
1079 ; CHECK-NEXT: [[TMP31:%.*]] = select i1 [[TMP29]], i32 [[TMP30]], i32 [[TMP26]]
1080 ; CHECK-NEXT: [[TMP32:%.*]] = insertelement <4 x i32> poison, i32 [[TMP31]], i64 0
1081 ; CHECK-NEXT: [[TMP33:%.*]] = extractelement <4 x i32> [[X]], i64 1
1082 ; CHECK-NEXT: [[TMP34:%.*]] = extractelement <4 x i32> [[Y]], i64 1
1083 ; CHECK-NEXT: [[TMP35:%.*]] = uitofp i32 [[TMP34]] to float
1084 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP35]])
1085 ; CHECK-NEXT: [[TMP37:%.*]] = fmul fast float [[TMP36]], 0x41EFFFFFC0000000
1086 ; CHECK-NEXT: [[TMP38:%.*]] = fptoui float [[TMP37]] to i32
1087 ; CHECK-NEXT: [[TMP39:%.*]] = sub i32 0, [[TMP34]]
1088 ; CHECK-NEXT: [[TMP40:%.*]] = mul i32 [[TMP39]], [[TMP38]]
1089 ; CHECK-NEXT: [[TMP41:%.*]] = zext i32 [[TMP38]] to i64
1090 ; CHECK-NEXT: [[TMP42:%.*]] = zext i32 [[TMP40]] to i64
1091 ; CHECK-NEXT: [[TMP43:%.*]] = mul i64 [[TMP41]], [[TMP42]]
1092 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i64 [[TMP43]] to i32
1093 ; CHECK-NEXT: [[TMP45:%.*]] = lshr i64 [[TMP43]], 32
1094 ; CHECK-NEXT: [[TMP46:%.*]] = trunc i64 [[TMP45]] to i32
1095 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP38]], [[TMP46]]
1096 ; CHECK-NEXT: [[TMP48:%.*]] = zext i32 [[TMP33]] to i64
1097 ; CHECK-NEXT: [[TMP49:%.*]] = zext i32 [[TMP47]] to i64
1098 ; CHECK-NEXT: [[TMP50:%.*]] = mul i64 [[TMP48]], [[TMP49]]
1099 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i64 [[TMP50]] to i32
1100 ; CHECK-NEXT: [[TMP52:%.*]] = lshr i64 [[TMP50]], 32
1101 ; CHECK-NEXT: [[TMP53:%.*]] = trunc i64 [[TMP52]] to i32
1102 ; CHECK-NEXT: [[TMP54:%.*]] = mul i32 [[TMP53]], [[TMP34]]
1103 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 [[TMP33]], [[TMP54]]
1104 ; CHECK-NEXT: [[TMP56:%.*]] = icmp uge i32 [[TMP55]], [[TMP34]]
1105 ; CHECK-NEXT: [[TMP57:%.*]] = add i32 [[TMP53]], 1
1106 ; CHECK-NEXT: [[TMP58:%.*]] = select i1 [[TMP56]], i32 [[TMP57]], i32 [[TMP53]]
1107 ; CHECK-NEXT: [[TMP59:%.*]] = sub i32 [[TMP55]], [[TMP34]]
1108 ; CHECK-NEXT: [[TMP60:%.*]] = select i1 [[TMP56]], i32 [[TMP59]], i32 [[TMP55]]
1109 ; CHECK-NEXT: [[TMP61:%.*]] = icmp uge i32 [[TMP60]], [[TMP34]]
1110 ; CHECK-NEXT: [[TMP62:%.*]] = add i32 [[TMP58]], 1
1111 ; CHECK-NEXT: [[TMP63:%.*]] = select i1 [[TMP61]], i32 [[TMP62]], i32 [[TMP58]]
1112 ; CHECK-NEXT: [[TMP64:%.*]] = insertelement <4 x i32> [[TMP32]], i32 [[TMP63]], i64 1
1113 ; CHECK-NEXT: [[TMP65:%.*]] = extractelement <4 x i32> [[X]], i64 2
1114 ; CHECK-NEXT: [[TMP66:%.*]] = extractelement <4 x i32> [[Y]], i64 2
1115 ; CHECK-NEXT: [[TMP67:%.*]] = uitofp i32 [[TMP66]] to float
1116 ; CHECK-NEXT: [[TMP68:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP67]])
1117 ; CHECK-NEXT: [[TMP69:%.*]] = fmul fast float [[TMP68]], 0x41EFFFFFC0000000
1118 ; CHECK-NEXT: [[TMP70:%.*]] = fptoui float [[TMP69]] to i32
1119 ; CHECK-NEXT: [[TMP71:%.*]] = sub i32 0, [[TMP66]]
1120 ; CHECK-NEXT: [[TMP72:%.*]] = mul i32 [[TMP71]], [[TMP70]]
1121 ; CHECK-NEXT: [[TMP73:%.*]] = zext i32 [[TMP70]] to i64
1122 ; CHECK-NEXT: [[TMP74:%.*]] = zext i32 [[TMP72]] to i64
1123 ; CHECK-NEXT: [[TMP75:%.*]] = mul i64 [[TMP73]], [[TMP74]]
1124 ; CHECK-NEXT: [[TMP76:%.*]] = trunc i64 [[TMP75]] to i32
1125 ; CHECK-NEXT: [[TMP77:%.*]] = lshr i64 [[TMP75]], 32
1126 ; CHECK-NEXT: [[TMP78:%.*]] = trunc i64 [[TMP77]] to i32
1127 ; CHECK-NEXT: [[TMP79:%.*]] = add i32 [[TMP70]], [[TMP78]]
1128 ; CHECK-NEXT: [[TMP80:%.*]] = zext i32 [[TMP65]] to i64
1129 ; CHECK-NEXT: [[TMP81:%.*]] = zext i32 [[TMP79]] to i64
1130 ; CHECK-NEXT: [[TMP82:%.*]] = mul i64 [[TMP80]], [[TMP81]]
1131 ; CHECK-NEXT: [[TMP83:%.*]] = trunc i64 [[TMP82]] to i32
1132 ; CHECK-NEXT: [[TMP84:%.*]] = lshr i64 [[TMP82]], 32
1133 ; CHECK-NEXT: [[TMP85:%.*]] = trunc i64 [[TMP84]] to i32
1134 ; CHECK-NEXT: [[TMP86:%.*]] = mul i32 [[TMP85]], [[TMP66]]
1135 ; CHECK-NEXT: [[TMP87:%.*]] = sub i32 [[TMP65]], [[TMP86]]
1136 ; CHECK-NEXT: [[TMP88:%.*]] = icmp uge i32 [[TMP87]], [[TMP66]]
1137 ; CHECK-NEXT: [[TMP89:%.*]] = add i32 [[TMP85]], 1
1138 ; CHECK-NEXT: [[TMP90:%.*]] = select i1 [[TMP88]], i32 [[TMP89]], i32 [[TMP85]]
1139 ; CHECK-NEXT: [[TMP91:%.*]] = sub i32 [[TMP87]], [[TMP66]]
1140 ; CHECK-NEXT: [[TMP92:%.*]] = select i1 [[TMP88]], i32 [[TMP91]], i32 [[TMP87]]
1141 ; CHECK-NEXT: [[TMP93:%.*]] = icmp uge i32 [[TMP92]], [[TMP66]]
1142 ; CHECK-NEXT: [[TMP94:%.*]] = add i32 [[TMP90]], 1
1143 ; CHECK-NEXT: [[TMP95:%.*]] = select i1 [[TMP93]], i32 [[TMP94]], i32 [[TMP90]]
1144 ; CHECK-NEXT: [[TMP96:%.*]] = insertelement <4 x i32> [[TMP64]], i32 [[TMP95]], i64 2
1145 ; CHECK-NEXT: [[TMP97:%.*]] = extractelement <4 x i32> [[X]], i64 3
1146 ; CHECK-NEXT: [[TMP98:%.*]] = extractelement <4 x i32> [[Y]], i64 3
1147 ; CHECK-NEXT: [[TMP99:%.*]] = uitofp i32 [[TMP98]] to float
1148 ; CHECK-NEXT: [[TMP100:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP99]])
1149 ; CHECK-NEXT: [[TMP101:%.*]] = fmul fast float [[TMP100]], 0x41EFFFFFC0000000
1150 ; CHECK-NEXT: [[TMP102:%.*]] = fptoui float [[TMP101]] to i32
1151 ; CHECK-NEXT: [[TMP103:%.*]] = sub i32 0, [[TMP98]]
1152 ; CHECK-NEXT: [[TMP104:%.*]] = mul i32 [[TMP103]], [[TMP102]]
1153 ; CHECK-NEXT: [[TMP105:%.*]] = zext i32 [[TMP102]] to i64
1154 ; CHECK-NEXT: [[TMP106:%.*]] = zext i32 [[TMP104]] to i64
1155 ; CHECK-NEXT: [[TMP107:%.*]] = mul i64 [[TMP105]], [[TMP106]]
1156 ; CHECK-NEXT: [[TMP108:%.*]] = trunc i64 [[TMP107]] to i32
1157 ; CHECK-NEXT: [[TMP109:%.*]] = lshr i64 [[TMP107]], 32
1158 ; CHECK-NEXT: [[TMP110:%.*]] = trunc i64 [[TMP109]] to i32
1159 ; CHECK-NEXT: [[TMP111:%.*]] = add i32 [[TMP102]], [[TMP110]]
1160 ; CHECK-NEXT: [[TMP112:%.*]] = zext i32 [[TMP97]] to i64
1161 ; CHECK-NEXT: [[TMP113:%.*]] = zext i32 [[TMP111]] to i64
1162 ; CHECK-NEXT: [[TMP114:%.*]] = mul i64 [[TMP112]], [[TMP113]]
1163 ; CHECK-NEXT: [[TMP115:%.*]] = trunc i64 [[TMP114]] to i32
1164 ; CHECK-NEXT: [[TMP116:%.*]] = lshr i64 [[TMP114]], 32
1165 ; CHECK-NEXT: [[TMP117:%.*]] = trunc i64 [[TMP116]] to i32
1166 ; CHECK-NEXT: [[TMP118:%.*]] = mul i32 [[TMP117]], [[TMP98]]
1167 ; CHECK-NEXT: [[TMP119:%.*]] = sub i32 [[TMP97]], [[TMP118]]
1168 ; CHECK-NEXT: [[TMP120:%.*]] = icmp uge i32 [[TMP119]], [[TMP98]]
1169 ; CHECK-NEXT: [[TMP121:%.*]] = add i32 [[TMP117]], 1
1170 ; CHECK-NEXT: [[TMP122:%.*]] = select i1 [[TMP120]], i32 [[TMP121]], i32 [[TMP117]]
1171 ; CHECK-NEXT: [[TMP123:%.*]] = sub i32 [[TMP119]], [[TMP98]]
1172 ; CHECK-NEXT: [[TMP124:%.*]] = select i1 [[TMP120]], i32 [[TMP123]], i32 [[TMP119]]
1173 ; CHECK-NEXT: [[TMP125:%.*]] = icmp uge i32 [[TMP124]], [[TMP98]]
1174 ; CHECK-NEXT: [[TMP126:%.*]] = add i32 [[TMP122]], 1
1175 ; CHECK-NEXT: [[TMP127:%.*]] = select i1 [[TMP125]], i32 [[TMP126]], i32 [[TMP122]]
1176 ; CHECK-NEXT: [[TMP128:%.*]] = insertelement <4 x i32> [[TMP96]], i32 [[TMP127]], i64 3
1177 ; CHECK-NEXT: store <4 x i32> [[TMP128]], ptr addrspace(1) [[OUT:%.*]], align 16
1178 ; CHECK-NEXT: ret void
1180 ; GFX6-LABEL: udiv_v4i32:
1182 ; GFX6-NEXT: s_load_dwordx8 s[8:15], s[2:3], 0xd
1183 ; GFX6-NEXT: s_load_dwordx2 s[16:17], s[2:3], 0x9
1184 ; GFX6-NEXT: s_mov_b32 s19, 0xf000
1185 ; GFX6-NEXT: s_mov_b32 s18, -1
1186 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1187 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s12
1188 ; GFX6-NEXT: s_sub_i32 s0, 0, s12
1189 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s13
1190 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s14
1191 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
1192 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s15
1193 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
1194 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v4
1195 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1196 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
1197 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v6
1198 ; GFX6-NEXT: v_mul_lo_u32 v1, s0, v0
1199 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
1200 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1201 ; GFX6-NEXT: v_mul_hi_u32 v0, s8, v0
1202 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
1203 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
1204 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
1205 ; GFX6-NEXT: s_mul_i32 s0, s0, s12
1206 ; GFX6-NEXT: s_sub_i32 s0, s8, s0
1207 ; GFX6-NEXT: s_sub_i32 s1, s0, s12
1208 ; GFX6-NEXT: s_cmp_ge_u32 s0, s12
1209 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
1210 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1211 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1212 ; GFX6-NEXT: s_cmp_ge_u32 s0, s12
1213 ; GFX6-NEXT: s_cselect_b64 s[0:1], -1, 0
1214 ; GFX6-NEXT: s_sub_i32 s4, 0, s13
1215 ; GFX6-NEXT: v_mul_lo_u32 v3, s4, v1
1216 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
1217 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
1218 ; GFX6-NEXT: v_mul_hi_u32 v3, v1, v3
1219 ; GFX6-NEXT: v_cndmask_b32_e64 v0, v0, v2, s[0:1]
1220 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v3
1221 ; GFX6-NEXT: v_mul_hi_u32 v1, s9, v1
1222 ; GFX6-NEXT: v_mul_f32_e32 v3, 0x4f7ffffe, v4
1223 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v3
1224 ; GFX6-NEXT: v_readfirstlane_b32 s4, v1
1225 ; GFX6-NEXT: s_mul_i32 s4, s4, s13
1226 ; GFX6-NEXT: s_sub_i32 s4, s9, s4
1227 ; GFX6-NEXT: s_sub_i32 s5, s4, s13
1228 ; GFX6-NEXT: s_cmp_ge_u32 s4, s13
1229 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, 1, v1
1230 ; GFX6-NEXT: s_cselect_b32 s4, s5, s4
1231 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1232 ; GFX6-NEXT: s_cmp_ge_u32 s4, s13
1233 ; GFX6-NEXT: s_cselect_b64 s[4:5], -1, 0
1234 ; GFX6-NEXT: s_sub_i32 s6, 0, s14
1235 ; GFX6-NEXT: v_mul_lo_u32 v5, s6, v3
1236 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v4, vcc
1237 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, 1, v1
1238 ; GFX6-NEXT: v_mul_hi_u32 v5, v3, v5
1239 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, v4, s[4:5]
1240 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
1241 ; GFX6-NEXT: v_mul_hi_u32 v3, s10, v3
1242 ; GFX6-NEXT: v_mul_f32_e32 v5, 0x4f7ffffe, v6
1243 ; GFX6-NEXT: v_cvt_u32_f32_e32 v5, v5
1244 ; GFX6-NEXT: v_readfirstlane_b32 s6, v3
1245 ; GFX6-NEXT: s_mul_i32 s6, s6, s14
1246 ; GFX6-NEXT: s_sub_i32 s6, s10, s6
1247 ; GFX6-NEXT: s_sub_i32 s7, s6, s14
1248 ; GFX6-NEXT: s_cmp_ge_u32 s6, s14
1249 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 1, v3
1250 ; GFX6-NEXT: s_cselect_b32 s6, s7, s6
1251 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1252 ; GFX6-NEXT: s_cmp_ge_u32 s6, s14
1253 ; GFX6-NEXT: s_cselect_b64 s[6:7], -1, 0
1254 ; GFX6-NEXT: s_sub_i32 s8, 0, s15
1255 ; GFX6-NEXT: v_mul_lo_u32 v7, s8, v5
1256 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v6, vcc
1257 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 1, v3
1258 ; GFX6-NEXT: v_mul_hi_u32 v7, v5, v7
1259 ; GFX6-NEXT: v_cndmask_b32_e64 v2, v3, v6, s[6:7]
1260 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v5, v7
1261 ; GFX6-NEXT: v_mul_hi_u32 v5, s11, v5
1262 ; GFX6-NEXT: v_readfirstlane_b32 s0, v5
1263 ; GFX6-NEXT: s_mul_i32 s0, s0, s15
1264 ; GFX6-NEXT: s_sub_i32 s0, s11, s0
1265 ; GFX6-NEXT: s_sub_i32 s1, s0, s15
1266 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, 1, v5
1267 ; GFX6-NEXT: s_cmp_ge_u32 s0, s15
1268 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1269 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
1270 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1271 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, 1, v3
1272 ; GFX6-NEXT: s_cmp_ge_u32 s0, s15
1273 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1274 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v4, vcc
1275 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[16:19], 0
1276 ; GFX6-NEXT: s_endpgm
1278 ; GFX9-LABEL: udiv_v4i32:
1280 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
1281 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
1282 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
1283 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
1284 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s8
1285 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s9
1286 ; GFX9-NEXT: s_sub_i32 s2, 0, s8
1287 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s10
1288 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
1289 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v1
1290 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1291 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1292 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v1
1293 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
1294 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
1295 ; GFX9-NEXT: s_mul_i32 s2, s2, s3
1296 ; GFX9-NEXT: s_mul_hi_u32 s2, s3, s2
1297 ; GFX9-NEXT: s_add_i32 s3, s3, s2
1298 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, s3
1299 ; GFX9-NEXT: s_mul_i32 s3, s2, s8
1300 ; GFX9-NEXT: s_sub_i32 s3, s4, s3
1301 ; GFX9-NEXT: s_add_i32 s13, s2, 1
1302 ; GFX9-NEXT: s_sub_i32 s4, s3, s8
1303 ; GFX9-NEXT: s_cmp_ge_u32 s3, s8
1304 ; GFX9-NEXT: s_cselect_b32 s2, s13, s2
1305 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
1306 ; GFX9-NEXT: s_add_i32 s4, s2, 1
1307 ; GFX9-NEXT: s_cmp_ge_u32 s3, s8
1308 ; GFX9-NEXT: v_readfirstlane_b32 s12, v1
1309 ; GFX9-NEXT: s_cselect_b32 s2, s4, s2
1310 ; GFX9-NEXT: s_sub_i32 s3, 0, s9
1311 ; GFX9-NEXT: s_mul_i32 s3, s3, s12
1312 ; GFX9-NEXT: s_mul_hi_u32 s3, s12, s3
1313 ; GFX9-NEXT: s_add_i32 s12, s12, s3
1314 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v2
1315 ; GFX9-NEXT: s_mul_hi_u32 s3, s5, s12
1316 ; GFX9-NEXT: s_mul_i32 s4, s3, s9
1317 ; GFX9-NEXT: s_sub_i32 s4, s5, s4
1318 ; GFX9-NEXT: s_add_i32 s8, s3, 1
1319 ; GFX9-NEXT: s_sub_i32 s5, s4, s9
1320 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1321 ; GFX9-NEXT: s_cmp_ge_u32 s4, s9
1322 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1323 ; GFX9-NEXT: s_cselect_b32 s3, s8, s3
1324 ; GFX9-NEXT: s_cselect_b32 s4, s5, s4
1325 ; GFX9-NEXT: s_add_i32 s5, s3, 1
1326 ; GFX9-NEXT: s_cmp_ge_u32 s4, s9
1327 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
1328 ; GFX9-NEXT: v_readfirstlane_b32 s5, v0
1329 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s11
1330 ; GFX9-NEXT: s_sub_i32 s4, 0, s10
1331 ; GFX9-NEXT: s_mul_i32 s4, s4, s5
1332 ; GFX9-NEXT: s_mul_hi_u32 s4, s5, s4
1333 ; GFX9-NEXT: s_add_i32 s5, s5, s4
1334 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
1335 ; GFX9-NEXT: s_mul_hi_u32 s4, s6, s5
1336 ; GFX9-NEXT: s_mul_i32 s5, s4, s10
1337 ; GFX9-NEXT: s_sub_i32 s5, s6, s5
1338 ; GFX9-NEXT: s_add_i32 s6, s4, 1
1339 ; GFX9-NEXT: s_sub_i32 s8, s5, s10
1340 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1341 ; GFX9-NEXT: s_cmp_ge_u32 s5, s10
1342 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1343 ; GFX9-NEXT: s_cselect_b32 s4, s6, s4
1344 ; GFX9-NEXT: s_cselect_b32 s5, s8, s5
1345 ; GFX9-NEXT: s_add_i32 s6, s4, 1
1346 ; GFX9-NEXT: s_cmp_ge_u32 s5, s10
1347 ; GFX9-NEXT: s_cselect_b32 s4, s6, s4
1348 ; GFX9-NEXT: s_sub_i32 s5, 0, s11
1349 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
1350 ; GFX9-NEXT: s_mul_i32 s5, s5, s6
1351 ; GFX9-NEXT: s_mul_hi_u32 s5, s6, s5
1352 ; GFX9-NEXT: s_add_i32 s6, s6, s5
1353 ; GFX9-NEXT: s_mul_hi_u32 s5, s7, s6
1354 ; GFX9-NEXT: s_mul_i32 s6, s5, s11
1355 ; GFX9-NEXT: s_sub_i32 s6, s7, s6
1356 ; GFX9-NEXT: s_add_i32 s7, s5, 1
1357 ; GFX9-NEXT: s_sub_i32 s8, s6, s11
1358 ; GFX9-NEXT: s_cmp_ge_u32 s6, s11
1359 ; GFX9-NEXT: s_cselect_b32 s5, s7, s5
1360 ; GFX9-NEXT: s_cselect_b32 s6, s8, s6
1361 ; GFX9-NEXT: s_add_i32 s7, s5, 1
1362 ; GFX9-NEXT: s_cmp_ge_u32 s6, s11
1363 ; GFX9-NEXT: s_cselect_b32 s5, s7, s5
1364 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
1365 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
1366 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
1367 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
1368 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
1369 ; GFX9-NEXT: s_endpgm
1370 %r = udiv <4 x i32> %x, %y
1371 store <4 x i32> %r, ptr addrspace(1) %out
1375 define amdgpu_kernel void @urem_v4i32(ptr addrspace(1) %out, <4 x i32> %x, <4 x i32> %y) {
1376 ; CHECK-LABEL: @urem_v4i32(
1377 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[X:%.*]], i64 0
1378 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[Y:%.*]], i64 0
1379 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP2]] to float
1380 ; CHECK-NEXT: [[TMP4:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP3]])
1381 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast float [[TMP4]], 0x41EFFFFFC0000000
1382 ; CHECK-NEXT: [[TMP6:%.*]] = fptoui float [[TMP5]] to i32
1383 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 0, [[TMP2]]
1384 ; CHECK-NEXT: [[TMP8:%.*]] = mul i32 [[TMP7]], [[TMP6]]
1385 ; CHECK-NEXT: [[TMP9:%.*]] = zext i32 [[TMP6]] to i64
1386 ; CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP8]] to i64
1387 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP9]], [[TMP10]]
1388 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
1389 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i64 [[TMP11]], 32
1390 ; CHECK-NEXT: [[TMP14:%.*]] = trunc i64 [[TMP13]] to i32
1391 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP6]], [[TMP14]]
1392 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP1]] to i64
1393 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
1394 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
1395 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
1396 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
1397 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
1398 ; CHECK-NEXT: [[TMP22:%.*]] = mul i32 [[TMP21]], [[TMP2]]
1399 ; CHECK-NEXT: [[TMP23:%.*]] = sub i32 [[TMP1]], [[TMP22]]
1400 ; CHECK-NEXT: [[TMP24:%.*]] = icmp uge i32 [[TMP23]], [[TMP2]]
1401 ; CHECK-NEXT: [[TMP25:%.*]] = sub i32 [[TMP23]], [[TMP2]]
1402 ; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP24]], i32 [[TMP25]], i32 [[TMP23]]
1403 ; CHECK-NEXT: [[TMP27:%.*]] = icmp uge i32 [[TMP26]], [[TMP2]]
1404 ; CHECK-NEXT: [[TMP28:%.*]] = sub i32 [[TMP26]], [[TMP2]]
1405 ; CHECK-NEXT: [[TMP29:%.*]] = select i1 [[TMP27]], i32 [[TMP28]], i32 [[TMP26]]
1406 ; CHECK-NEXT: [[TMP30:%.*]] = insertelement <4 x i32> poison, i32 [[TMP29]], i64 0
1407 ; CHECK-NEXT: [[TMP31:%.*]] = extractelement <4 x i32> [[X]], i64 1
1408 ; CHECK-NEXT: [[TMP32:%.*]] = extractelement <4 x i32> [[Y]], i64 1
1409 ; CHECK-NEXT: [[TMP33:%.*]] = uitofp i32 [[TMP32]] to float
1410 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP33]])
1411 ; CHECK-NEXT: [[TMP35:%.*]] = fmul fast float [[TMP34]], 0x41EFFFFFC0000000
1412 ; CHECK-NEXT: [[TMP36:%.*]] = fptoui float [[TMP35]] to i32
1413 ; CHECK-NEXT: [[TMP37:%.*]] = sub i32 0, [[TMP32]]
1414 ; CHECK-NEXT: [[TMP38:%.*]] = mul i32 [[TMP37]], [[TMP36]]
1415 ; CHECK-NEXT: [[TMP39:%.*]] = zext i32 [[TMP36]] to i64
1416 ; CHECK-NEXT: [[TMP40:%.*]] = zext i32 [[TMP38]] to i64
1417 ; CHECK-NEXT: [[TMP41:%.*]] = mul i64 [[TMP39]], [[TMP40]]
1418 ; CHECK-NEXT: [[TMP42:%.*]] = trunc i64 [[TMP41]] to i32
1419 ; CHECK-NEXT: [[TMP43:%.*]] = lshr i64 [[TMP41]], 32
1420 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i64 [[TMP43]] to i32
1421 ; CHECK-NEXT: [[TMP45:%.*]] = add i32 [[TMP36]], [[TMP44]]
1422 ; CHECK-NEXT: [[TMP46:%.*]] = zext i32 [[TMP31]] to i64
1423 ; CHECK-NEXT: [[TMP47:%.*]] = zext i32 [[TMP45]] to i64
1424 ; CHECK-NEXT: [[TMP48:%.*]] = mul i64 [[TMP46]], [[TMP47]]
1425 ; CHECK-NEXT: [[TMP49:%.*]] = trunc i64 [[TMP48]] to i32
1426 ; CHECK-NEXT: [[TMP50:%.*]] = lshr i64 [[TMP48]], 32
1427 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i64 [[TMP50]] to i32
1428 ; CHECK-NEXT: [[TMP52:%.*]] = mul i32 [[TMP51]], [[TMP32]]
1429 ; CHECK-NEXT: [[TMP53:%.*]] = sub i32 [[TMP31]], [[TMP52]]
1430 ; CHECK-NEXT: [[TMP54:%.*]] = icmp uge i32 [[TMP53]], [[TMP32]]
1431 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 [[TMP53]], [[TMP32]]
1432 ; CHECK-NEXT: [[TMP56:%.*]] = select i1 [[TMP54]], i32 [[TMP55]], i32 [[TMP53]]
1433 ; CHECK-NEXT: [[TMP57:%.*]] = icmp uge i32 [[TMP56]], [[TMP32]]
1434 ; CHECK-NEXT: [[TMP58:%.*]] = sub i32 [[TMP56]], [[TMP32]]
1435 ; CHECK-NEXT: [[TMP59:%.*]] = select i1 [[TMP57]], i32 [[TMP58]], i32 [[TMP56]]
1436 ; CHECK-NEXT: [[TMP60:%.*]] = insertelement <4 x i32> [[TMP30]], i32 [[TMP59]], i64 1
1437 ; CHECK-NEXT: [[TMP61:%.*]] = extractelement <4 x i32> [[X]], i64 2
1438 ; CHECK-NEXT: [[TMP62:%.*]] = extractelement <4 x i32> [[Y]], i64 2
1439 ; CHECK-NEXT: [[TMP63:%.*]] = uitofp i32 [[TMP62]] to float
1440 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP63]])
1441 ; CHECK-NEXT: [[TMP65:%.*]] = fmul fast float [[TMP64]], 0x41EFFFFFC0000000
1442 ; CHECK-NEXT: [[TMP66:%.*]] = fptoui float [[TMP65]] to i32
1443 ; CHECK-NEXT: [[TMP67:%.*]] = sub i32 0, [[TMP62]]
1444 ; CHECK-NEXT: [[TMP68:%.*]] = mul i32 [[TMP67]], [[TMP66]]
1445 ; CHECK-NEXT: [[TMP69:%.*]] = zext i32 [[TMP66]] to i64
1446 ; CHECK-NEXT: [[TMP70:%.*]] = zext i32 [[TMP68]] to i64
1447 ; CHECK-NEXT: [[TMP71:%.*]] = mul i64 [[TMP69]], [[TMP70]]
1448 ; CHECK-NEXT: [[TMP72:%.*]] = trunc i64 [[TMP71]] to i32
1449 ; CHECK-NEXT: [[TMP73:%.*]] = lshr i64 [[TMP71]], 32
1450 ; CHECK-NEXT: [[TMP74:%.*]] = trunc i64 [[TMP73]] to i32
1451 ; CHECK-NEXT: [[TMP75:%.*]] = add i32 [[TMP66]], [[TMP74]]
1452 ; CHECK-NEXT: [[TMP76:%.*]] = zext i32 [[TMP61]] to i64
1453 ; CHECK-NEXT: [[TMP77:%.*]] = zext i32 [[TMP75]] to i64
1454 ; CHECK-NEXT: [[TMP78:%.*]] = mul i64 [[TMP76]], [[TMP77]]
1455 ; CHECK-NEXT: [[TMP79:%.*]] = trunc i64 [[TMP78]] to i32
1456 ; CHECK-NEXT: [[TMP80:%.*]] = lshr i64 [[TMP78]], 32
1457 ; CHECK-NEXT: [[TMP81:%.*]] = trunc i64 [[TMP80]] to i32
1458 ; CHECK-NEXT: [[TMP82:%.*]] = mul i32 [[TMP81]], [[TMP62]]
1459 ; CHECK-NEXT: [[TMP83:%.*]] = sub i32 [[TMP61]], [[TMP82]]
1460 ; CHECK-NEXT: [[TMP84:%.*]] = icmp uge i32 [[TMP83]], [[TMP62]]
1461 ; CHECK-NEXT: [[TMP85:%.*]] = sub i32 [[TMP83]], [[TMP62]]
1462 ; CHECK-NEXT: [[TMP86:%.*]] = select i1 [[TMP84]], i32 [[TMP85]], i32 [[TMP83]]
1463 ; CHECK-NEXT: [[TMP87:%.*]] = icmp uge i32 [[TMP86]], [[TMP62]]
1464 ; CHECK-NEXT: [[TMP88:%.*]] = sub i32 [[TMP86]], [[TMP62]]
1465 ; CHECK-NEXT: [[TMP89:%.*]] = select i1 [[TMP87]], i32 [[TMP88]], i32 [[TMP86]]
1466 ; CHECK-NEXT: [[TMP90:%.*]] = insertelement <4 x i32> [[TMP60]], i32 [[TMP89]], i64 2
1467 ; CHECK-NEXT: [[TMP91:%.*]] = extractelement <4 x i32> [[X]], i64 3
1468 ; CHECK-NEXT: [[TMP92:%.*]] = extractelement <4 x i32> [[Y]], i64 3
1469 ; CHECK-NEXT: [[TMP93:%.*]] = uitofp i32 [[TMP92]] to float
1470 ; CHECK-NEXT: [[TMP94:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP93]])
1471 ; CHECK-NEXT: [[TMP95:%.*]] = fmul fast float [[TMP94]], 0x41EFFFFFC0000000
1472 ; CHECK-NEXT: [[TMP96:%.*]] = fptoui float [[TMP95]] to i32
1473 ; CHECK-NEXT: [[TMP97:%.*]] = sub i32 0, [[TMP92]]
1474 ; CHECK-NEXT: [[TMP98:%.*]] = mul i32 [[TMP97]], [[TMP96]]
1475 ; CHECK-NEXT: [[TMP99:%.*]] = zext i32 [[TMP96]] to i64
1476 ; CHECK-NEXT: [[TMP100:%.*]] = zext i32 [[TMP98]] to i64
1477 ; CHECK-NEXT: [[TMP101:%.*]] = mul i64 [[TMP99]], [[TMP100]]
1478 ; CHECK-NEXT: [[TMP102:%.*]] = trunc i64 [[TMP101]] to i32
1479 ; CHECK-NEXT: [[TMP103:%.*]] = lshr i64 [[TMP101]], 32
1480 ; CHECK-NEXT: [[TMP104:%.*]] = trunc i64 [[TMP103]] to i32
1481 ; CHECK-NEXT: [[TMP105:%.*]] = add i32 [[TMP96]], [[TMP104]]
1482 ; CHECK-NEXT: [[TMP106:%.*]] = zext i32 [[TMP91]] to i64
1483 ; CHECK-NEXT: [[TMP107:%.*]] = zext i32 [[TMP105]] to i64
1484 ; CHECK-NEXT: [[TMP108:%.*]] = mul i64 [[TMP106]], [[TMP107]]
1485 ; CHECK-NEXT: [[TMP109:%.*]] = trunc i64 [[TMP108]] to i32
1486 ; CHECK-NEXT: [[TMP110:%.*]] = lshr i64 [[TMP108]], 32
1487 ; CHECK-NEXT: [[TMP111:%.*]] = trunc i64 [[TMP110]] to i32
1488 ; CHECK-NEXT: [[TMP112:%.*]] = mul i32 [[TMP111]], [[TMP92]]
1489 ; CHECK-NEXT: [[TMP113:%.*]] = sub i32 [[TMP91]], [[TMP112]]
1490 ; CHECK-NEXT: [[TMP114:%.*]] = icmp uge i32 [[TMP113]], [[TMP92]]
1491 ; CHECK-NEXT: [[TMP115:%.*]] = sub i32 [[TMP113]], [[TMP92]]
1492 ; CHECK-NEXT: [[TMP116:%.*]] = select i1 [[TMP114]], i32 [[TMP115]], i32 [[TMP113]]
1493 ; CHECK-NEXT: [[TMP117:%.*]] = icmp uge i32 [[TMP116]], [[TMP92]]
1494 ; CHECK-NEXT: [[TMP118:%.*]] = sub i32 [[TMP116]], [[TMP92]]
1495 ; CHECK-NEXT: [[TMP119:%.*]] = select i1 [[TMP117]], i32 [[TMP118]], i32 [[TMP116]]
1496 ; CHECK-NEXT: [[TMP120:%.*]] = insertelement <4 x i32> [[TMP90]], i32 [[TMP119]], i64 3
1497 ; CHECK-NEXT: store <4 x i32> [[TMP120]], ptr addrspace(1) [[OUT:%.*]], align 16
1498 ; CHECK-NEXT: ret void
1500 ; GFX6-LABEL: urem_v4i32:
1502 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
1503 ; GFX6-NEXT: s_load_dwordx2 s[12:13], s[2:3], 0x9
1504 ; GFX6-NEXT: s_mov_b32 s15, 0xf000
1505 ; GFX6-NEXT: s_mov_b32 s14, -1
1506 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1507 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s8
1508 ; GFX6-NEXT: s_sub_i32 s0, 0, s8
1509 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s9
1510 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
1511 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
1512 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1513 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
1514 ; GFX6-NEXT: v_mul_lo_u32 v1, s0, v0
1515 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
1516 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1517 ; GFX6-NEXT: v_mul_hi_u32 v0, s4, v0
1518 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
1519 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
1520 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s10
1521 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
1522 ; GFX6-NEXT: s_mul_i32 s0, s0, s8
1523 ; GFX6-NEXT: s_sub_i32 s0, s4, s0
1524 ; GFX6-NEXT: s_sub_i32 s1, s0, s8
1525 ; GFX6-NEXT: s_cmp_ge_u32 s0, s8
1526 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1527 ; GFX6-NEXT: s_sub_i32 s1, s0, s8
1528 ; GFX6-NEXT: s_cmp_ge_u32 s0, s8
1529 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1530 ; GFX6-NEXT: s_sub_i32 s1, 0, s9
1531 ; GFX6-NEXT: v_mul_lo_u32 v0, s1, v1
1532 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
1533 ; GFX6-NEXT: v_mul_hi_u32 v0, v1, v0
1534 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
1535 ; GFX6-NEXT: v_mul_hi_u32 v0, s5, v0
1536 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
1537 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
1538 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s11
1539 ; GFX6-NEXT: v_readfirstlane_b32 s1, v0
1540 ; GFX6-NEXT: s_mul_i32 s1, s1, s9
1541 ; GFX6-NEXT: s_sub_i32 s1, s5, s1
1542 ; GFX6-NEXT: s_sub_i32 s4, s1, s9
1543 ; GFX6-NEXT: s_cmp_ge_u32 s1, s9
1544 ; GFX6-NEXT: s_cselect_b32 s1, s4, s1
1545 ; GFX6-NEXT: s_sub_i32 s4, s1, s9
1546 ; GFX6-NEXT: s_cmp_ge_u32 s1, s9
1547 ; GFX6-NEXT: s_cselect_b32 s1, s4, s1
1548 ; GFX6-NEXT: s_sub_i32 s4, 0, s10
1549 ; GFX6-NEXT: v_mul_lo_u32 v0, s4, v1
1550 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
1551 ; GFX6-NEXT: v_mul_hi_u32 v0, v1, v0
1552 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
1553 ; GFX6-NEXT: v_mul_hi_u32 v0, s6, v0
1554 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
1555 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
1556 ; GFX6-NEXT: v_readfirstlane_b32 s4, v0
1557 ; GFX6-NEXT: s_mul_i32 s4, s4, s10
1558 ; GFX6-NEXT: s_sub_i32 s4, s6, s4
1559 ; GFX6-NEXT: s_sub_i32 s5, s4, s10
1560 ; GFX6-NEXT: s_cmp_ge_u32 s4, s10
1561 ; GFX6-NEXT: s_cselect_b32 s4, s5, s4
1562 ; GFX6-NEXT: s_sub_i32 s5, s4, s10
1563 ; GFX6-NEXT: s_cmp_ge_u32 s4, s10
1564 ; GFX6-NEXT: s_cselect_b32 s4, s5, s4
1565 ; GFX6-NEXT: s_sub_i32 s5, 0, s11
1566 ; GFX6-NEXT: v_mul_lo_u32 v0, s5, v1
1567 ; GFX6-NEXT: v_mul_hi_u32 v0, v1, v0
1568 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
1569 ; GFX6-NEXT: v_mul_hi_u32 v2, s7, v0
1570 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
1571 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
1572 ; GFX6-NEXT: v_readfirstlane_b32 s0, v2
1573 ; GFX6-NEXT: s_mul_i32 s0, s0, s11
1574 ; GFX6-NEXT: s_sub_i32 s0, s7, s0
1575 ; GFX6-NEXT: s_sub_i32 s1, s0, s11
1576 ; GFX6-NEXT: s_cmp_ge_u32 s0, s11
1577 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1578 ; GFX6-NEXT: s_sub_i32 s1, s0, s11
1579 ; GFX6-NEXT: s_cmp_ge_u32 s0, s11
1580 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
1581 ; GFX6-NEXT: v_mov_b32_e32 v2, s4
1582 ; GFX6-NEXT: v_mov_b32_e32 v3, s0
1583 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[12:15], 0
1584 ; GFX6-NEXT: s_endpgm
1586 ; GFX9-LABEL: urem_v4i32:
1588 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
1589 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
1590 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
1591 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
1592 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s8
1593 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s9
1594 ; GFX9-NEXT: s_sub_i32 s2, 0, s8
1595 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s10
1596 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
1597 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v1
1598 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v2
1599 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1600 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1601 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v1
1602 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
1603 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x4f7ffffe, v2
1604 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
1605 ; GFX9-NEXT: s_mul_i32 s2, s2, s3
1606 ; GFX9-NEXT: s_mul_hi_u32 s2, s3, s2
1607 ; GFX9-NEXT: s_add_i32 s3, s3, s2
1608 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, s3
1609 ; GFX9-NEXT: s_mul_i32 s2, s2, s8
1610 ; GFX9-NEXT: s_sub_i32 s2, s4, s2
1611 ; GFX9-NEXT: s_sub_i32 s3, s2, s8
1612 ; GFX9-NEXT: s_cmp_ge_u32 s2, s8
1613 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
1614 ; GFX9-NEXT: s_sub_i32 s3, s2, s8
1615 ; GFX9-NEXT: s_cmp_ge_u32 s2, s8
1616 ; GFX9-NEXT: v_readfirstlane_b32 s12, v1
1617 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
1618 ; GFX9-NEXT: s_sub_i32 s3, 0, s9
1619 ; GFX9-NEXT: s_mul_i32 s3, s3, s12
1620 ; GFX9-NEXT: s_mul_hi_u32 s3, s12, s3
1621 ; GFX9-NEXT: s_add_i32 s12, s12, s3
1622 ; GFX9-NEXT: s_mul_hi_u32 s3, s5, s12
1623 ; GFX9-NEXT: s_mul_i32 s3, s3, s9
1624 ; GFX9-NEXT: s_sub_i32 s3, s5, s3
1625 ; GFX9-NEXT: s_sub_i32 s4, s3, s9
1626 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
1627 ; GFX9-NEXT: s_cmp_ge_u32 s3, s9
1628 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
1629 ; GFX9-NEXT: s_sub_i32 s4, s3, s9
1630 ; GFX9-NEXT: s_cmp_ge_u32 s3, s9
1631 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s11
1632 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
1633 ; GFX9-NEXT: s_sub_i32 s4, 0, s10
1634 ; GFX9-NEXT: v_readfirstlane_b32 s5, v2
1635 ; GFX9-NEXT: s_mul_i32 s4, s4, s5
1636 ; GFX9-NEXT: s_mul_hi_u32 s4, s5, s4
1637 ; GFX9-NEXT: s_add_i32 s5, s5, s4
1638 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
1639 ; GFX9-NEXT: s_mul_hi_u32 s4, s6, s5
1640 ; GFX9-NEXT: s_mul_i32 s4, s4, s10
1641 ; GFX9-NEXT: s_sub_i32 s4, s6, s4
1642 ; GFX9-NEXT: s_sub_i32 s5, s4, s10
1643 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1644 ; GFX9-NEXT: s_cmp_ge_u32 s4, s10
1645 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1646 ; GFX9-NEXT: s_cselect_b32 s4, s5, s4
1647 ; GFX9-NEXT: s_sub_i32 s5, s4, s10
1648 ; GFX9-NEXT: s_cmp_ge_u32 s4, s10
1649 ; GFX9-NEXT: s_cselect_b32 s4, s5, s4
1650 ; GFX9-NEXT: s_sub_i32 s5, 0, s11
1651 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
1652 ; GFX9-NEXT: s_mul_i32 s5, s5, s6
1653 ; GFX9-NEXT: s_mul_hi_u32 s5, s6, s5
1654 ; GFX9-NEXT: s_add_i32 s6, s6, s5
1655 ; GFX9-NEXT: s_mul_hi_u32 s5, s7, s6
1656 ; GFX9-NEXT: s_mul_i32 s5, s5, s11
1657 ; GFX9-NEXT: s_sub_i32 s5, s7, s5
1658 ; GFX9-NEXT: s_sub_i32 s6, s5, s11
1659 ; GFX9-NEXT: s_cmp_ge_u32 s5, s11
1660 ; GFX9-NEXT: s_cselect_b32 s5, s6, s5
1661 ; GFX9-NEXT: s_sub_i32 s6, s5, s11
1662 ; GFX9-NEXT: s_cmp_ge_u32 s5, s11
1663 ; GFX9-NEXT: s_cselect_b32 s5, s6, s5
1664 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
1665 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
1666 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
1667 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
1668 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
1669 ; GFX9-NEXT: s_endpgm
1670 %r = urem <4 x i32> %x, %y
1671 store <4 x i32> %r, ptr addrspace(1) %out
1675 define amdgpu_kernel void @sdiv_v4i32(ptr addrspace(1) %out, <4 x i32> %x, <4 x i32> %y) {
1676 ; CHECK-LABEL: @sdiv_v4i32(
1677 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[X:%.*]], i64 0
1678 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[Y:%.*]], i64 0
1679 ; CHECK-NEXT: [[TMP3:%.*]] = ashr i32 [[TMP1]], 31
1680 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP2]], 31
1681 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
1682 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP1]], [[TMP3]]
1683 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 [[TMP2]], [[TMP4]]
1684 ; CHECK-NEXT: [[TMP8:%.*]] = xor i32 [[TMP6]], [[TMP3]]
1685 ; CHECK-NEXT: [[TMP9:%.*]] = xor i32 [[TMP7]], [[TMP4]]
1686 ; CHECK-NEXT: [[TMP10:%.*]] = uitofp i32 [[TMP9]] to float
1687 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP10]])
1688 ; CHECK-NEXT: [[TMP12:%.*]] = fmul fast float [[TMP11]], 0x41EFFFFFC0000000
1689 ; CHECK-NEXT: [[TMP13:%.*]] = fptoui float [[TMP12]] to i32
1690 ; CHECK-NEXT: [[TMP14:%.*]] = sub i32 0, [[TMP9]]
1691 ; CHECK-NEXT: [[TMP15:%.*]] = mul i32 [[TMP14]], [[TMP13]]
1692 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP13]] to i64
1693 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
1694 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
1695 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
1696 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
1697 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
1698 ; CHECK-NEXT: [[TMP22:%.*]] = add i32 [[TMP13]], [[TMP21]]
1699 ; CHECK-NEXT: [[TMP23:%.*]] = zext i32 [[TMP8]] to i64
1700 ; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP22]] to i64
1701 ; CHECK-NEXT: [[TMP25:%.*]] = mul i64 [[TMP23]], [[TMP24]]
1702 ; CHECK-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP25]] to i32
1703 ; CHECK-NEXT: [[TMP27:%.*]] = lshr i64 [[TMP25]], 32
1704 ; CHECK-NEXT: [[TMP28:%.*]] = trunc i64 [[TMP27]] to i32
1705 ; CHECK-NEXT: [[TMP29:%.*]] = mul i32 [[TMP28]], [[TMP9]]
1706 ; CHECK-NEXT: [[TMP30:%.*]] = sub i32 [[TMP8]], [[TMP29]]
1707 ; CHECK-NEXT: [[TMP31:%.*]] = icmp uge i32 [[TMP30]], [[TMP9]]
1708 ; CHECK-NEXT: [[TMP32:%.*]] = add i32 [[TMP28]], 1
1709 ; CHECK-NEXT: [[TMP33:%.*]] = select i1 [[TMP31]], i32 [[TMP32]], i32 [[TMP28]]
1710 ; CHECK-NEXT: [[TMP34:%.*]] = sub i32 [[TMP30]], [[TMP9]]
1711 ; CHECK-NEXT: [[TMP35:%.*]] = select i1 [[TMP31]], i32 [[TMP34]], i32 [[TMP30]]
1712 ; CHECK-NEXT: [[TMP36:%.*]] = icmp uge i32 [[TMP35]], [[TMP9]]
1713 ; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP33]], 1
1714 ; CHECK-NEXT: [[TMP38:%.*]] = select i1 [[TMP36]], i32 [[TMP37]], i32 [[TMP33]]
1715 ; CHECK-NEXT: [[TMP39:%.*]] = xor i32 [[TMP38]], [[TMP5]]
1716 ; CHECK-NEXT: [[TMP40:%.*]] = sub i32 [[TMP39]], [[TMP5]]
1717 ; CHECK-NEXT: [[TMP41:%.*]] = insertelement <4 x i32> poison, i32 [[TMP40]], i64 0
1718 ; CHECK-NEXT: [[TMP42:%.*]] = extractelement <4 x i32> [[X]], i64 1
1719 ; CHECK-NEXT: [[TMP43:%.*]] = extractelement <4 x i32> [[Y]], i64 1
1720 ; CHECK-NEXT: [[TMP44:%.*]] = ashr i32 [[TMP42]], 31
1721 ; CHECK-NEXT: [[TMP45:%.*]] = ashr i32 [[TMP43]], 31
1722 ; CHECK-NEXT: [[TMP46:%.*]] = xor i32 [[TMP44]], [[TMP45]]
1723 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP42]], [[TMP44]]
1724 ; CHECK-NEXT: [[TMP48:%.*]] = add i32 [[TMP43]], [[TMP45]]
1725 ; CHECK-NEXT: [[TMP49:%.*]] = xor i32 [[TMP47]], [[TMP44]]
1726 ; CHECK-NEXT: [[TMP50:%.*]] = xor i32 [[TMP48]], [[TMP45]]
1727 ; CHECK-NEXT: [[TMP51:%.*]] = uitofp i32 [[TMP50]] to float
1728 ; CHECK-NEXT: [[TMP52:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP51]])
1729 ; CHECK-NEXT: [[TMP53:%.*]] = fmul fast float [[TMP52]], 0x41EFFFFFC0000000
1730 ; CHECK-NEXT: [[TMP54:%.*]] = fptoui float [[TMP53]] to i32
1731 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 0, [[TMP50]]
1732 ; CHECK-NEXT: [[TMP56:%.*]] = mul i32 [[TMP55]], [[TMP54]]
1733 ; CHECK-NEXT: [[TMP57:%.*]] = zext i32 [[TMP54]] to i64
1734 ; CHECK-NEXT: [[TMP58:%.*]] = zext i32 [[TMP56]] to i64
1735 ; CHECK-NEXT: [[TMP59:%.*]] = mul i64 [[TMP57]], [[TMP58]]
1736 ; CHECK-NEXT: [[TMP60:%.*]] = trunc i64 [[TMP59]] to i32
1737 ; CHECK-NEXT: [[TMP61:%.*]] = lshr i64 [[TMP59]], 32
1738 ; CHECK-NEXT: [[TMP62:%.*]] = trunc i64 [[TMP61]] to i32
1739 ; CHECK-NEXT: [[TMP63:%.*]] = add i32 [[TMP54]], [[TMP62]]
1740 ; CHECK-NEXT: [[TMP64:%.*]] = zext i32 [[TMP49]] to i64
1741 ; CHECK-NEXT: [[TMP65:%.*]] = zext i32 [[TMP63]] to i64
1742 ; CHECK-NEXT: [[TMP66:%.*]] = mul i64 [[TMP64]], [[TMP65]]
1743 ; CHECK-NEXT: [[TMP67:%.*]] = trunc i64 [[TMP66]] to i32
1744 ; CHECK-NEXT: [[TMP68:%.*]] = lshr i64 [[TMP66]], 32
1745 ; CHECK-NEXT: [[TMP69:%.*]] = trunc i64 [[TMP68]] to i32
1746 ; CHECK-NEXT: [[TMP70:%.*]] = mul i32 [[TMP69]], [[TMP50]]
1747 ; CHECK-NEXT: [[TMP71:%.*]] = sub i32 [[TMP49]], [[TMP70]]
1748 ; CHECK-NEXT: [[TMP72:%.*]] = icmp uge i32 [[TMP71]], [[TMP50]]
1749 ; CHECK-NEXT: [[TMP73:%.*]] = add i32 [[TMP69]], 1
1750 ; CHECK-NEXT: [[TMP74:%.*]] = select i1 [[TMP72]], i32 [[TMP73]], i32 [[TMP69]]
1751 ; CHECK-NEXT: [[TMP75:%.*]] = sub i32 [[TMP71]], [[TMP50]]
1752 ; CHECK-NEXT: [[TMP76:%.*]] = select i1 [[TMP72]], i32 [[TMP75]], i32 [[TMP71]]
1753 ; CHECK-NEXT: [[TMP77:%.*]] = icmp uge i32 [[TMP76]], [[TMP50]]
1754 ; CHECK-NEXT: [[TMP78:%.*]] = add i32 [[TMP74]], 1
1755 ; CHECK-NEXT: [[TMP79:%.*]] = select i1 [[TMP77]], i32 [[TMP78]], i32 [[TMP74]]
1756 ; CHECK-NEXT: [[TMP80:%.*]] = xor i32 [[TMP79]], [[TMP46]]
1757 ; CHECK-NEXT: [[TMP81:%.*]] = sub i32 [[TMP80]], [[TMP46]]
1758 ; CHECK-NEXT: [[TMP82:%.*]] = insertelement <4 x i32> [[TMP41]], i32 [[TMP81]], i64 1
1759 ; CHECK-NEXT: [[TMP83:%.*]] = extractelement <4 x i32> [[X]], i64 2
1760 ; CHECK-NEXT: [[TMP84:%.*]] = extractelement <4 x i32> [[Y]], i64 2
1761 ; CHECK-NEXT: [[TMP85:%.*]] = ashr i32 [[TMP83]], 31
1762 ; CHECK-NEXT: [[TMP86:%.*]] = ashr i32 [[TMP84]], 31
1763 ; CHECK-NEXT: [[TMP87:%.*]] = xor i32 [[TMP85]], [[TMP86]]
1764 ; CHECK-NEXT: [[TMP88:%.*]] = add i32 [[TMP83]], [[TMP85]]
1765 ; CHECK-NEXT: [[TMP89:%.*]] = add i32 [[TMP84]], [[TMP86]]
1766 ; CHECK-NEXT: [[TMP90:%.*]] = xor i32 [[TMP88]], [[TMP85]]
1767 ; CHECK-NEXT: [[TMP91:%.*]] = xor i32 [[TMP89]], [[TMP86]]
1768 ; CHECK-NEXT: [[TMP92:%.*]] = uitofp i32 [[TMP91]] to float
1769 ; CHECK-NEXT: [[TMP93:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP92]])
1770 ; CHECK-NEXT: [[TMP94:%.*]] = fmul fast float [[TMP93]], 0x41EFFFFFC0000000
1771 ; CHECK-NEXT: [[TMP95:%.*]] = fptoui float [[TMP94]] to i32
1772 ; CHECK-NEXT: [[TMP96:%.*]] = sub i32 0, [[TMP91]]
1773 ; CHECK-NEXT: [[TMP97:%.*]] = mul i32 [[TMP96]], [[TMP95]]
1774 ; CHECK-NEXT: [[TMP98:%.*]] = zext i32 [[TMP95]] to i64
1775 ; CHECK-NEXT: [[TMP99:%.*]] = zext i32 [[TMP97]] to i64
1776 ; CHECK-NEXT: [[TMP100:%.*]] = mul i64 [[TMP98]], [[TMP99]]
1777 ; CHECK-NEXT: [[TMP101:%.*]] = trunc i64 [[TMP100]] to i32
1778 ; CHECK-NEXT: [[TMP102:%.*]] = lshr i64 [[TMP100]], 32
1779 ; CHECK-NEXT: [[TMP103:%.*]] = trunc i64 [[TMP102]] to i32
1780 ; CHECK-NEXT: [[TMP104:%.*]] = add i32 [[TMP95]], [[TMP103]]
1781 ; CHECK-NEXT: [[TMP105:%.*]] = zext i32 [[TMP90]] to i64
1782 ; CHECK-NEXT: [[TMP106:%.*]] = zext i32 [[TMP104]] to i64
1783 ; CHECK-NEXT: [[TMP107:%.*]] = mul i64 [[TMP105]], [[TMP106]]
1784 ; CHECK-NEXT: [[TMP108:%.*]] = trunc i64 [[TMP107]] to i32
1785 ; CHECK-NEXT: [[TMP109:%.*]] = lshr i64 [[TMP107]], 32
1786 ; CHECK-NEXT: [[TMP110:%.*]] = trunc i64 [[TMP109]] to i32
1787 ; CHECK-NEXT: [[TMP111:%.*]] = mul i32 [[TMP110]], [[TMP91]]
1788 ; CHECK-NEXT: [[TMP112:%.*]] = sub i32 [[TMP90]], [[TMP111]]
1789 ; CHECK-NEXT: [[TMP113:%.*]] = icmp uge i32 [[TMP112]], [[TMP91]]
1790 ; CHECK-NEXT: [[TMP114:%.*]] = add i32 [[TMP110]], 1
1791 ; CHECK-NEXT: [[TMP115:%.*]] = select i1 [[TMP113]], i32 [[TMP114]], i32 [[TMP110]]
1792 ; CHECK-NEXT: [[TMP116:%.*]] = sub i32 [[TMP112]], [[TMP91]]
1793 ; CHECK-NEXT: [[TMP117:%.*]] = select i1 [[TMP113]], i32 [[TMP116]], i32 [[TMP112]]
1794 ; CHECK-NEXT: [[TMP118:%.*]] = icmp uge i32 [[TMP117]], [[TMP91]]
1795 ; CHECK-NEXT: [[TMP119:%.*]] = add i32 [[TMP115]], 1
1796 ; CHECK-NEXT: [[TMP120:%.*]] = select i1 [[TMP118]], i32 [[TMP119]], i32 [[TMP115]]
1797 ; CHECK-NEXT: [[TMP121:%.*]] = xor i32 [[TMP120]], [[TMP87]]
1798 ; CHECK-NEXT: [[TMP122:%.*]] = sub i32 [[TMP121]], [[TMP87]]
1799 ; CHECK-NEXT: [[TMP123:%.*]] = insertelement <4 x i32> [[TMP82]], i32 [[TMP122]], i64 2
1800 ; CHECK-NEXT: [[TMP124:%.*]] = extractelement <4 x i32> [[X]], i64 3
1801 ; CHECK-NEXT: [[TMP125:%.*]] = extractelement <4 x i32> [[Y]], i64 3
1802 ; CHECK-NEXT: [[TMP126:%.*]] = ashr i32 [[TMP124]], 31
1803 ; CHECK-NEXT: [[TMP127:%.*]] = ashr i32 [[TMP125]], 31
1804 ; CHECK-NEXT: [[TMP128:%.*]] = xor i32 [[TMP126]], [[TMP127]]
1805 ; CHECK-NEXT: [[TMP129:%.*]] = add i32 [[TMP124]], [[TMP126]]
1806 ; CHECK-NEXT: [[TMP130:%.*]] = add i32 [[TMP125]], [[TMP127]]
1807 ; CHECK-NEXT: [[TMP131:%.*]] = xor i32 [[TMP129]], [[TMP126]]
1808 ; CHECK-NEXT: [[TMP132:%.*]] = xor i32 [[TMP130]], [[TMP127]]
1809 ; CHECK-NEXT: [[TMP133:%.*]] = uitofp i32 [[TMP132]] to float
1810 ; CHECK-NEXT: [[TMP134:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP133]])
1811 ; CHECK-NEXT: [[TMP135:%.*]] = fmul fast float [[TMP134]], 0x41EFFFFFC0000000
1812 ; CHECK-NEXT: [[TMP136:%.*]] = fptoui float [[TMP135]] to i32
1813 ; CHECK-NEXT: [[TMP137:%.*]] = sub i32 0, [[TMP132]]
1814 ; CHECK-NEXT: [[TMP138:%.*]] = mul i32 [[TMP137]], [[TMP136]]
1815 ; CHECK-NEXT: [[TMP139:%.*]] = zext i32 [[TMP136]] to i64
1816 ; CHECK-NEXT: [[TMP140:%.*]] = zext i32 [[TMP138]] to i64
1817 ; CHECK-NEXT: [[TMP141:%.*]] = mul i64 [[TMP139]], [[TMP140]]
1818 ; CHECK-NEXT: [[TMP142:%.*]] = trunc i64 [[TMP141]] to i32
1819 ; CHECK-NEXT: [[TMP143:%.*]] = lshr i64 [[TMP141]], 32
1820 ; CHECK-NEXT: [[TMP144:%.*]] = trunc i64 [[TMP143]] to i32
1821 ; CHECK-NEXT: [[TMP145:%.*]] = add i32 [[TMP136]], [[TMP144]]
1822 ; CHECK-NEXT: [[TMP146:%.*]] = zext i32 [[TMP131]] to i64
1823 ; CHECK-NEXT: [[TMP147:%.*]] = zext i32 [[TMP145]] to i64
1824 ; CHECK-NEXT: [[TMP148:%.*]] = mul i64 [[TMP146]], [[TMP147]]
1825 ; CHECK-NEXT: [[TMP149:%.*]] = trunc i64 [[TMP148]] to i32
1826 ; CHECK-NEXT: [[TMP150:%.*]] = lshr i64 [[TMP148]], 32
1827 ; CHECK-NEXT: [[TMP151:%.*]] = trunc i64 [[TMP150]] to i32
1828 ; CHECK-NEXT: [[TMP152:%.*]] = mul i32 [[TMP151]], [[TMP132]]
1829 ; CHECK-NEXT: [[TMP153:%.*]] = sub i32 [[TMP131]], [[TMP152]]
1830 ; CHECK-NEXT: [[TMP154:%.*]] = icmp uge i32 [[TMP153]], [[TMP132]]
1831 ; CHECK-NEXT: [[TMP155:%.*]] = add i32 [[TMP151]], 1
1832 ; CHECK-NEXT: [[TMP156:%.*]] = select i1 [[TMP154]], i32 [[TMP155]], i32 [[TMP151]]
1833 ; CHECK-NEXT: [[TMP157:%.*]] = sub i32 [[TMP153]], [[TMP132]]
1834 ; CHECK-NEXT: [[TMP158:%.*]] = select i1 [[TMP154]], i32 [[TMP157]], i32 [[TMP153]]
1835 ; CHECK-NEXT: [[TMP159:%.*]] = icmp uge i32 [[TMP158]], [[TMP132]]
1836 ; CHECK-NEXT: [[TMP160:%.*]] = add i32 [[TMP156]], 1
1837 ; CHECK-NEXT: [[TMP161:%.*]] = select i1 [[TMP159]], i32 [[TMP160]], i32 [[TMP156]]
1838 ; CHECK-NEXT: [[TMP162:%.*]] = xor i32 [[TMP161]], [[TMP128]]
1839 ; CHECK-NEXT: [[TMP163:%.*]] = sub i32 [[TMP162]], [[TMP128]]
1840 ; CHECK-NEXT: [[TMP164:%.*]] = insertelement <4 x i32> [[TMP123]], i32 [[TMP163]], i64 3
1841 ; CHECK-NEXT: store <4 x i32> [[TMP164]], ptr addrspace(1) [[OUT:%.*]], align 16
1842 ; CHECK-NEXT: ret void
1844 ; GFX6-LABEL: sdiv_v4i32:
1846 ; GFX6-NEXT: s_load_dwordx8 s[8:15], s[2:3], 0xd
1847 ; GFX6-NEXT: s_load_dwordx2 s[16:17], s[2:3], 0x9
1848 ; GFX6-NEXT: s_mov_b32 s19, 0xf000
1849 ; GFX6-NEXT: s_mov_b32 s18, -1
1850 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1851 ; GFX6-NEXT: s_abs_i32 s0, s12
1852 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s0
1853 ; GFX6-NEXT: s_sub_i32 s1, 0, s0
1854 ; GFX6-NEXT: s_xor_b32 s4, s8, s12
1855 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
1856 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1857 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
1858 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v0
1859 ; GFX6-NEXT: s_abs_i32 s1, s8
1860 ; GFX6-NEXT: s_ashr_i32 s8, s4, 31
1861 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
1862 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1863 ; GFX6-NEXT: v_mul_hi_u32 v0, s1, v0
1864 ; GFX6-NEXT: v_readfirstlane_b32 s4, v0
1865 ; GFX6-NEXT: s_mul_i32 s4, s4, s0
1866 ; GFX6-NEXT: s_sub_i32 s1, s1, s4
1867 ; GFX6-NEXT: s_sub_i32 s4, s1, s0
1868 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
1869 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
1870 ; GFX6-NEXT: s_cselect_b32 s1, s4, s1
1871 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1872 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
1873 ; GFX6-NEXT: s_cselect_b64 s[0:1], -1, 0
1874 ; GFX6-NEXT: s_abs_i32 s4, s13
1875 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s4
1876 ; GFX6-NEXT: s_sub_i32 s5, 0, s4
1877 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
1878 ; GFX6-NEXT: s_xor_b32 s6, s9, s13
1879 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
1880 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
1881 ; GFX6-NEXT: v_cndmask_b32_e64 v0, v0, v1, s[0:1]
1882 ; GFX6-NEXT: v_mul_f32_e32 v2, 0x4f7ffffe, v2
1883 ; GFX6-NEXT: v_cvt_u32_f32_e32 v2, v2
1884 ; GFX6-NEXT: v_xor_b32_e32 v0, s8, v0
1885 ; GFX6-NEXT: v_mul_lo_u32 v3, s5, v2
1886 ; GFX6-NEXT: s_abs_i32 s5, s9
1887 ; GFX6-NEXT: s_ashr_i32 s9, s6, 31
1888 ; GFX6-NEXT: v_mul_hi_u32 v3, v2, v3
1889 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
1890 ; GFX6-NEXT: v_mul_hi_u32 v2, s5, v2
1891 ; GFX6-NEXT: v_readfirstlane_b32 s6, v2
1892 ; GFX6-NEXT: s_mul_i32 s6, s6, s4
1893 ; GFX6-NEXT: s_sub_i32 s5, s5, s6
1894 ; GFX6-NEXT: s_sub_i32 s6, s5, s4
1895 ; GFX6-NEXT: s_cmp_ge_u32 s5, s4
1896 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, 1, v2
1897 ; GFX6-NEXT: s_cselect_b32 s5, s6, s5
1898 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1899 ; GFX6-NEXT: s_cmp_ge_u32 s5, s4
1900 ; GFX6-NEXT: s_cselect_b64 s[4:5], -1, 0
1901 ; GFX6-NEXT: s_abs_i32 s6, s14
1902 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s6
1903 ; GFX6-NEXT: s_sub_i32 s7, 0, s6
1904 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v3, vcc
1905 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, 1, v2
1906 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v4
1907 ; GFX6-NEXT: v_mul_f32_e32 v4, 0x4f7ffffe, v4
1908 ; GFX6-NEXT: v_cvt_u32_f32_e32 v4, v4
1909 ; GFX6-NEXT: v_mul_lo_u32 v5, s7, v4
1910 ; GFX6-NEXT: s_abs_i32 s7, s10
1911 ; GFX6-NEXT: s_xor_b32 s10, s10, s14
1912 ; GFX6-NEXT: s_ashr_i32 s10, s10, 31
1913 ; GFX6-NEXT: v_mul_hi_u32 v5, v4, v5
1914 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
1915 ; GFX6-NEXT: v_mul_hi_u32 v4, s7, v4
1916 ; GFX6-NEXT: v_readfirstlane_b32 s12, v4
1917 ; GFX6-NEXT: s_mul_i32 s12, s12, s6
1918 ; GFX6-NEXT: s_sub_i32 s7, s7, s12
1919 ; GFX6-NEXT: s_sub_i32 s12, s7, s6
1920 ; GFX6-NEXT: s_cmp_ge_u32 s7, s6
1921 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, 1, v4
1922 ; GFX6-NEXT: s_cselect_b32 s7, s12, s7
1923 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1924 ; GFX6-NEXT: s_cmp_ge_u32 s7, s6
1925 ; GFX6-NEXT: s_cselect_b64 s[6:7], -1, 0
1926 ; GFX6-NEXT: s_abs_i32 s12, s15
1927 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s12
1928 ; GFX6-NEXT: s_sub_i32 s0, 0, s12
1929 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
1930 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, 1, v4
1931 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v1, v6
1932 ; GFX6-NEXT: s_abs_i32 s1, s11
1933 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s8, v0
1934 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v1
1935 ; GFX6-NEXT: v_cvt_u32_f32_e32 v6, v1
1936 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v2, v3, s[4:5]
1937 ; GFX6-NEXT: v_cndmask_b32_e64 v3, v4, v5, s[6:7]
1938 ; GFX6-NEXT: v_xor_b32_e32 v1, s9, v1
1939 ; GFX6-NEXT: v_mul_lo_u32 v2, s0, v6
1940 ; GFX6-NEXT: s_xor_b32 s0, s11, s15
1941 ; GFX6-NEXT: v_xor_b32_e32 v3, s10, v3
1942 ; GFX6-NEXT: s_ashr_i32 s0, s0, 31
1943 ; GFX6-NEXT: v_mul_hi_u32 v2, v6, v2
1944 ; GFX6-NEXT: v_subrev_i32_e32 v1, vcc, s9, v1
1945 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v6, v2
1946 ; GFX6-NEXT: v_mul_hi_u32 v4, s1, v2
1947 ; GFX6-NEXT: v_subrev_i32_e32 v2, vcc, s10, v3
1948 ; GFX6-NEXT: v_readfirstlane_b32 s2, v4
1949 ; GFX6-NEXT: s_mul_i32 s2, s2, s12
1950 ; GFX6-NEXT: s_sub_i32 s1, s1, s2
1951 ; GFX6-NEXT: s_sub_i32 s2, s1, s12
1952 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, 1, v4
1953 ; GFX6-NEXT: s_cmp_ge_u32 s1, s12
1954 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1955 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v4, v3, vcc
1956 ; GFX6-NEXT: s_cselect_b32 s1, s2, s1
1957 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, 1, v3
1958 ; GFX6-NEXT: s_cmp_ge_u32 s1, s12
1959 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
1960 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v4, vcc
1961 ; GFX6-NEXT: v_xor_b32_e32 v3, s0, v3
1962 ; GFX6-NEXT: v_subrev_i32_e32 v3, vcc, s0, v3
1963 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[16:19], 0
1964 ; GFX6-NEXT: s_endpgm
1966 ; GFX9-LABEL: sdiv_v4i32:
1968 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
1969 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
1970 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
1971 ; GFX9-NEXT: s_abs_i32 s0, s8
1972 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
1973 ; GFX9-NEXT: s_xor_b32 s1, s4, s8
1974 ; GFX9-NEXT: s_sub_i32 s8, 0, s0
1975 ; GFX9-NEXT: s_abs_i32 s4, s4
1976 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
1977 ; GFX9-NEXT: s_ashr_i32 s1, s1, 31
1978 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
1979 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
1980 ; GFX9-NEXT: v_readfirstlane_b32 s12, v0
1981 ; GFX9-NEXT: s_mul_i32 s8, s8, s12
1982 ; GFX9-NEXT: s_mul_hi_u32 s8, s12, s8
1983 ; GFX9-NEXT: s_add_i32 s12, s12, s8
1984 ; GFX9-NEXT: s_mul_hi_u32 s8, s4, s12
1985 ; GFX9-NEXT: s_mul_i32 s12, s8, s0
1986 ; GFX9-NEXT: s_sub_i32 s4, s4, s12
1987 ; GFX9-NEXT: s_add_i32 s13, s8, 1
1988 ; GFX9-NEXT: s_sub_i32 s12, s4, s0
1989 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
1990 ; GFX9-NEXT: s_cselect_b32 s8, s13, s8
1991 ; GFX9-NEXT: s_cselect_b32 s4, s12, s4
1992 ; GFX9-NEXT: s_add_i32 s12, s8, 1
1993 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
1994 ; GFX9-NEXT: s_cselect_b32 s0, s12, s8
1995 ; GFX9-NEXT: s_abs_i32 s4, s9
1996 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s4
1997 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
1998 ; GFX9-NEXT: s_xor_b32 s8, s5, s9
1999 ; GFX9-NEXT: s_sub_i32 s9, 0, s4
2000 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
2001 ; GFX9-NEXT: s_sub_i32 s12, s0, s1
2002 ; GFX9-NEXT: s_abs_i32 s5, s5
2003 ; GFX9-NEXT: s_ashr_i32 s8, s8, 31
2004 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2005 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
2006 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2007 ; GFX9-NEXT: s_mul_i32 s9, s9, s0
2008 ; GFX9-NEXT: s_mul_hi_u32 s1, s0, s9
2009 ; GFX9-NEXT: s_add_i32 s0, s0, s1
2010 ; GFX9-NEXT: s_mul_hi_u32 s0, s5, s0
2011 ; GFX9-NEXT: s_mul_i32 s1, s0, s4
2012 ; GFX9-NEXT: s_sub_i32 s1, s5, s1
2013 ; GFX9-NEXT: s_add_i32 s9, s0, 1
2014 ; GFX9-NEXT: s_sub_i32 s5, s1, s4
2015 ; GFX9-NEXT: s_cmp_ge_u32 s1, s4
2016 ; GFX9-NEXT: s_cselect_b32 s0, s9, s0
2017 ; GFX9-NEXT: s_cselect_b32 s1, s5, s1
2018 ; GFX9-NEXT: s_add_i32 s5, s0, 1
2019 ; GFX9-NEXT: s_cmp_ge_u32 s1, s4
2020 ; GFX9-NEXT: s_cselect_b32 s0, s5, s0
2021 ; GFX9-NEXT: s_abs_i32 s1, s10
2022 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
2023 ; GFX9-NEXT: s_xor_b32 s0, s0, s8
2024 ; GFX9-NEXT: s_xor_b32 s4, s6, s10
2025 ; GFX9-NEXT: s_abs_i32 s5, s6
2026 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
2027 ; GFX9-NEXT: s_sub_i32 s6, 0, s1
2028 ; GFX9-NEXT: s_sub_i32 s8, s0, s8
2029 ; GFX9-NEXT: s_ashr_i32 s4, s4, 31
2030 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2031 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
2032 ; GFX9-NEXT: v_mov_b32_e32 v1, s8
2033 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2034 ; GFX9-NEXT: s_mul_i32 s6, s6, s0
2035 ; GFX9-NEXT: s_mul_hi_u32 s6, s0, s6
2036 ; GFX9-NEXT: s_add_i32 s0, s0, s6
2037 ; GFX9-NEXT: s_mul_hi_u32 s0, s5, s0
2038 ; GFX9-NEXT: s_mul_i32 s6, s0, s1
2039 ; GFX9-NEXT: s_sub_i32 s5, s5, s6
2040 ; GFX9-NEXT: s_add_i32 s9, s0, 1
2041 ; GFX9-NEXT: s_sub_i32 s6, s5, s1
2042 ; GFX9-NEXT: s_cmp_ge_u32 s5, s1
2043 ; GFX9-NEXT: s_cselect_b32 s0, s9, s0
2044 ; GFX9-NEXT: s_cselect_b32 s5, s6, s5
2045 ; GFX9-NEXT: s_add_i32 s6, s0, 1
2046 ; GFX9-NEXT: s_cmp_ge_u32 s5, s1
2047 ; GFX9-NEXT: s_cselect_b32 s5, s6, s0
2048 ; GFX9-NEXT: s_abs_i32 s6, s11
2049 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s6
2050 ; GFX9-NEXT: s_xor_b32 s5, s5, s4
2051 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
2052 ; GFX9-NEXT: s_xor_b32 s2, s7, s11
2053 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v2
2054 ; GFX9-NEXT: s_abs_i32 s3, s7
2055 ; GFX9-NEXT: s_sub_i32 s7, 0, s6
2056 ; GFX9-NEXT: s_sub_i32 s4, s5, s4
2057 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x4f7ffffe, v2
2058 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
2059 ; GFX9-NEXT: s_ashr_i32 s2, s2, 31
2060 ; GFX9-NEXT: v_mov_b32_e32 v0, s12
2061 ; GFX9-NEXT: v_readfirstlane_b32 s5, v2
2062 ; GFX9-NEXT: s_mul_i32 s7, s7, s5
2063 ; GFX9-NEXT: s_mul_hi_u32 s7, s5, s7
2064 ; GFX9-NEXT: s_add_i32 s5, s5, s7
2065 ; GFX9-NEXT: s_mul_hi_u32 s5, s3, s5
2066 ; GFX9-NEXT: s_mul_i32 s7, s5, s6
2067 ; GFX9-NEXT: s_sub_i32 s3, s3, s7
2068 ; GFX9-NEXT: s_add_i32 s8, s5, 1
2069 ; GFX9-NEXT: s_sub_i32 s7, s3, s6
2070 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
2071 ; GFX9-NEXT: s_cselect_b32 s5, s8, s5
2072 ; GFX9-NEXT: s_cselect_b32 s3, s7, s3
2073 ; GFX9-NEXT: s_add_i32 s7, s5, 1
2074 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
2075 ; GFX9-NEXT: s_cselect_b32 s3, s7, s5
2076 ; GFX9-NEXT: s_xor_b32 s3, s3, s2
2077 ; GFX9-NEXT: s_sub_i32 s2, s3, s2
2078 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
2079 ; GFX9-NEXT: v_mov_b32_e32 v3, s2
2080 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2081 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
2082 ; GFX9-NEXT: s_endpgm
2083 %r = sdiv <4 x i32> %x, %y
2084 store <4 x i32> %r, ptr addrspace(1) %out
2088 define amdgpu_kernel void @srem_v4i32(ptr addrspace(1) %out, <4 x i32> %x, <4 x i32> %y) {
2089 ; CHECK-LABEL: @srem_v4i32(
2090 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[X:%.*]], i64 0
2091 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[Y:%.*]], i64 0
2092 ; CHECK-NEXT: [[TMP3:%.*]] = ashr i32 [[TMP1]], 31
2093 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP2]], 31
2094 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[TMP1]], [[TMP3]]
2095 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP2]], [[TMP4]]
2096 ; CHECK-NEXT: [[TMP7:%.*]] = xor i32 [[TMP5]], [[TMP3]]
2097 ; CHECK-NEXT: [[TMP8:%.*]] = xor i32 [[TMP6]], [[TMP4]]
2098 ; CHECK-NEXT: [[TMP9:%.*]] = uitofp i32 [[TMP8]] to float
2099 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
2100 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP10]], 0x41EFFFFFC0000000
2101 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP11]] to i32
2102 ; CHECK-NEXT: [[TMP13:%.*]] = sub i32 0, [[TMP8]]
2103 ; CHECK-NEXT: [[TMP14:%.*]] = mul i32 [[TMP13]], [[TMP12]]
2104 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP12]] to i64
2105 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP14]] to i64
2106 ; CHECK-NEXT: [[TMP17:%.*]] = mul i64 [[TMP15]], [[TMP16]]
2107 ; CHECK-NEXT: [[TMP18:%.*]] = trunc i64 [[TMP17]] to i32
2108 ; CHECK-NEXT: [[TMP19:%.*]] = lshr i64 [[TMP17]], 32
2109 ; CHECK-NEXT: [[TMP20:%.*]] = trunc i64 [[TMP19]] to i32
2110 ; CHECK-NEXT: [[TMP21:%.*]] = add i32 [[TMP12]], [[TMP20]]
2111 ; CHECK-NEXT: [[TMP22:%.*]] = zext i32 [[TMP7]] to i64
2112 ; CHECK-NEXT: [[TMP23:%.*]] = zext i32 [[TMP21]] to i64
2113 ; CHECK-NEXT: [[TMP24:%.*]] = mul i64 [[TMP22]], [[TMP23]]
2114 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i64 [[TMP24]] to i32
2115 ; CHECK-NEXT: [[TMP26:%.*]] = lshr i64 [[TMP24]], 32
2116 ; CHECK-NEXT: [[TMP27:%.*]] = trunc i64 [[TMP26]] to i32
2117 ; CHECK-NEXT: [[TMP28:%.*]] = mul i32 [[TMP27]], [[TMP8]]
2118 ; CHECK-NEXT: [[TMP29:%.*]] = sub i32 [[TMP7]], [[TMP28]]
2119 ; CHECK-NEXT: [[TMP30:%.*]] = icmp uge i32 [[TMP29]], [[TMP8]]
2120 ; CHECK-NEXT: [[TMP31:%.*]] = sub i32 [[TMP29]], [[TMP8]]
2121 ; CHECK-NEXT: [[TMP32:%.*]] = select i1 [[TMP30]], i32 [[TMP31]], i32 [[TMP29]]
2122 ; CHECK-NEXT: [[TMP33:%.*]] = icmp uge i32 [[TMP32]], [[TMP8]]
2123 ; CHECK-NEXT: [[TMP34:%.*]] = sub i32 [[TMP32]], [[TMP8]]
2124 ; CHECK-NEXT: [[TMP35:%.*]] = select i1 [[TMP33]], i32 [[TMP34]], i32 [[TMP32]]
2125 ; CHECK-NEXT: [[TMP36:%.*]] = xor i32 [[TMP35]], [[TMP3]]
2126 ; CHECK-NEXT: [[TMP37:%.*]] = sub i32 [[TMP36]], [[TMP3]]
2127 ; CHECK-NEXT: [[TMP38:%.*]] = insertelement <4 x i32> poison, i32 [[TMP37]], i64 0
2128 ; CHECK-NEXT: [[TMP39:%.*]] = extractelement <4 x i32> [[X]], i64 1
2129 ; CHECK-NEXT: [[TMP40:%.*]] = extractelement <4 x i32> [[Y]], i64 1
2130 ; CHECK-NEXT: [[TMP41:%.*]] = ashr i32 [[TMP39]], 31
2131 ; CHECK-NEXT: [[TMP42:%.*]] = ashr i32 [[TMP40]], 31
2132 ; CHECK-NEXT: [[TMP43:%.*]] = add i32 [[TMP39]], [[TMP41]]
2133 ; CHECK-NEXT: [[TMP44:%.*]] = add i32 [[TMP40]], [[TMP42]]
2134 ; CHECK-NEXT: [[TMP45:%.*]] = xor i32 [[TMP43]], [[TMP41]]
2135 ; CHECK-NEXT: [[TMP46:%.*]] = xor i32 [[TMP44]], [[TMP42]]
2136 ; CHECK-NEXT: [[TMP47:%.*]] = uitofp i32 [[TMP46]] to float
2137 ; CHECK-NEXT: [[TMP48:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP47]])
2138 ; CHECK-NEXT: [[TMP49:%.*]] = fmul fast float [[TMP48]], 0x41EFFFFFC0000000
2139 ; CHECK-NEXT: [[TMP50:%.*]] = fptoui float [[TMP49]] to i32
2140 ; CHECK-NEXT: [[TMP51:%.*]] = sub i32 0, [[TMP46]]
2141 ; CHECK-NEXT: [[TMP52:%.*]] = mul i32 [[TMP51]], [[TMP50]]
2142 ; CHECK-NEXT: [[TMP53:%.*]] = zext i32 [[TMP50]] to i64
2143 ; CHECK-NEXT: [[TMP54:%.*]] = zext i32 [[TMP52]] to i64
2144 ; CHECK-NEXT: [[TMP55:%.*]] = mul i64 [[TMP53]], [[TMP54]]
2145 ; CHECK-NEXT: [[TMP56:%.*]] = trunc i64 [[TMP55]] to i32
2146 ; CHECK-NEXT: [[TMP57:%.*]] = lshr i64 [[TMP55]], 32
2147 ; CHECK-NEXT: [[TMP58:%.*]] = trunc i64 [[TMP57]] to i32
2148 ; CHECK-NEXT: [[TMP59:%.*]] = add i32 [[TMP50]], [[TMP58]]
2149 ; CHECK-NEXT: [[TMP60:%.*]] = zext i32 [[TMP45]] to i64
2150 ; CHECK-NEXT: [[TMP61:%.*]] = zext i32 [[TMP59]] to i64
2151 ; CHECK-NEXT: [[TMP62:%.*]] = mul i64 [[TMP60]], [[TMP61]]
2152 ; CHECK-NEXT: [[TMP63:%.*]] = trunc i64 [[TMP62]] to i32
2153 ; CHECK-NEXT: [[TMP64:%.*]] = lshr i64 [[TMP62]], 32
2154 ; CHECK-NEXT: [[TMP65:%.*]] = trunc i64 [[TMP64]] to i32
2155 ; CHECK-NEXT: [[TMP66:%.*]] = mul i32 [[TMP65]], [[TMP46]]
2156 ; CHECK-NEXT: [[TMP67:%.*]] = sub i32 [[TMP45]], [[TMP66]]
2157 ; CHECK-NEXT: [[TMP68:%.*]] = icmp uge i32 [[TMP67]], [[TMP46]]
2158 ; CHECK-NEXT: [[TMP69:%.*]] = sub i32 [[TMP67]], [[TMP46]]
2159 ; CHECK-NEXT: [[TMP70:%.*]] = select i1 [[TMP68]], i32 [[TMP69]], i32 [[TMP67]]
2160 ; CHECK-NEXT: [[TMP71:%.*]] = icmp uge i32 [[TMP70]], [[TMP46]]
2161 ; CHECK-NEXT: [[TMP72:%.*]] = sub i32 [[TMP70]], [[TMP46]]
2162 ; CHECK-NEXT: [[TMP73:%.*]] = select i1 [[TMP71]], i32 [[TMP72]], i32 [[TMP70]]
2163 ; CHECK-NEXT: [[TMP74:%.*]] = xor i32 [[TMP73]], [[TMP41]]
2164 ; CHECK-NEXT: [[TMP75:%.*]] = sub i32 [[TMP74]], [[TMP41]]
2165 ; CHECK-NEXT: [[TMP76:%.*]] = insertelement <4 x i32> [[TMP38]], i32 [[TMP75]], i64 1
2166 ; CHECK-NEXT: [[TMP77:%.*]] = extractelement <4 x i32> [[X]], i64 2
2167 ; CHECK-NEXT: [[TMP78:%.*]] = extractelement <4 x i32> [[Y]], i64 2
2168 ; CHECK-NEXT: [[TMP79:%.*]] = ashr i32 [[TMP77]], 31
2169 ; CHECK-NEXT: [[TMP80:%.*]] = ashr i32 [[TMP78]], 31
2170 ; CHECK-NEXT: [[TMP81:%.*]] = add i32 [[TMP77]], [[TMP79]]
2171 ; CHECK-NEXT: [[TMP82:%.*]] = add i32 [[TMP78]], [[TMP80]]
2172 ; CHECK-NEXT: [[TMP83:%.*]] = xor i32 [[TMP81]], [[TMP79]]
2173 ; CHECK-NEXT: [[TMP84:%.*]] = xor i32 [[TMP82]], [[TMP80]]
2174 ; CHECK-NEXT: [[TMP85:%.*]] = uitofp i32 [[TMP84]] to float
2175 ; CHECK-NEXT: [[TMP86:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP85]])
2176 ; CHECK-NEXT: [[TMP87:%.*]] = fmul fast float [[TMP86]], 0x41EFFFFFC0000000
2177 ; CHECK-NEXT: [[TMP88:%.*]] = fptoui float [[TMP87]] to i32
2178 ; CHECK-NEXT: [[TMP89:%.*]] = sub i32 0, [[TMP84]]
2179 ; CHECK-NEXT: [[TMP90:%.*]] = mul i32 [[TMP89]], [[TMP88]]
2180 ; CHECK-NEXT: [[TMP91:%.*]] = zext i32 [[TMP88]] to i64
2181 ; CHECK-NEXT: [[TMP92:%.*]] = zext i32 [[TMP90]] to i64
2182 ; CHECK-NEXT: [[TMP93:%.*]] = mul i64 [[TMP91]], [[TMP92]]
2183 ; CHECK-NEXT: [[TMP94:%.*]] = trunc i64 [[TMP93]] to i32
2184 ; CHECK-NEXT: [[TMP95:%.*]] = lshr i64 [[TMP93]], 32
2185 ; CHECK-NEXT: [[TMP96:%.*]] = trunc i64 [[TMP95]] to i32
2186 ; CHECK-NEXT: [[TMP97:%.*]] = add i32 [[TMP88]], [[TMP96]]
2187 ; CHECK-NEXT: [[TMP98:%.*]] = zext i32 [[TMP83]] to i64
2188 ; CHECK-NEXT: [[TMP99:%.*]] = zext i32 [[TMP97]] to i64
2189 ; CHECK-NEXT: [[TMP100:%.*]] = mul i64 [[TMP98]], [[TMP99]]
2190 ; CHECK-NEXT: [[TMP101:%.*]] = trunc i64 [[TMP100]] to i32
2191 ; CHECK-NEXT: [[TMP102:%.*]] = lshr i64 [[TMP100]], 32
2192 ; CHECK-NEXT: [[TMP103:%.*]] = trunc i64 [[TMP102]] to i32
2193 ; CHECK-NEXT: [[TMP104:%.*]] = mul i32 [[TMP103]], [[TMP84]]
2194 ; CHECK-NEXT: [[TMP105:%.*]] = sub i32 [[TMP83]], [[TMP104]]
2195 ; CHECK-NEXT: [[TMP106:%.*]] = icmp uge i32 [[TMP105]], [[TMP84]]
2196 ; CHECK-NEXT: [[TMP107:%.*]] = sub i32 [[TMP105]], [[TMP84]]
2197 ; CHECK-NEXT: [[TMP108:%.*]] = select i1 [[TMP106]], i32 [[TMP107]], i32 [[TMP105]]
2198 ; CHECK-NEXT: [[TMP109:%.*]] = icmp uge i32 [[TMP108]], [[TMP84]]
2199 ; CHECK-NEXT: [[TMP110:%.*]] = sub i32 [[TMP108]], [[TMP84]]
2200 ; CHECK-NEXT: [[TMP111:%.*]] = select i1 [[TMP109]], i32 [[TMP110]], i32 [[TMP108]]
2201 ; CHECK-NEXT: [[TMP112:%.*]] = xor i32 [[TMP111]], [[TMP79]]
2202 ; CHECK-NEXT: [[TMP113:%.*]] = sub i32 [[TMP112]], [[TMP79]]
2203 ; CHECK-NEXT: [[TMP114:%.*]] = insertelement <4 x i32> [[TMP76]], i32 [[TMP113]], i64 2
2204 ; CHECK-NEXT: [[TMP115:%.*]] = extractelement <4 x i32> [[X]], i64 3
2205 ; CHECK-NEXT: [[TMP116:%.*]] = extractelement <4 x i32> [[Y]], i64 3
2206 ; CHECK-NEXT: [[TMP117:%.*]] = ashr i32 [[TMP115]], 31
2207 ; CHECK-NEXT: [[TMP118:%.*]] = ashr i32 [[TMP116]], 31
2208 ; CHECK-NEXT: [[TMP119:%.*]] = add i32 [[TMP115]], [[TMP117]]
2209 ; CHECK-NEXT: [[TMP120:%.*]] = add i32 [[TMP116]], [[TMP118]]
2210 ; CHECK-NEXT: [[TMP121:%.*]] = xor i32 [[TMP119]], [[TMP117]]
2211 ; CHECK-NEXT: [[TMP122:%.*]] = xor i32 [[TMP120]], [[TMP118]]
2212 ; CHECK-NEXT: [[TMP123:%.*]] = uitofp i32 [[TMP122]] to float
2213 ; CHECK-NEXT: [[TMP124:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP123]])
2214 ; CHECK-NEXT: [[TMP125:%.*]] = fmul fast float [[TMP124]], 0x41EFFFFFC0000000
2215 ; CHECK-NEXT: [[TMP126:%.*]] = fptoui float [[TMP125]] to i32
2216 ; CHECK-NEXT: [[TMP127:%.*]] = sub i32 0, [[TMP122]]
2217 ; CHECK-NEXT: [[TMP128:%.*]] = mul i32 [[TMP127]], [[TMP126]]
2218 ; CHECK-NEXT: [[TMP129:%.*]] = zext i32 [[TMP126]] to i64
2219 ; CHECK-NEXT: [[TMP130:%.*]] = zext i32 [[TMP128]] to i64
2220 ; CHECK-NEXT: [[TMP131:%.*]] = mul i64 [[TMP129]], [[TMP130]]
2221 ; CHECK-NEXT: [[TMP132:%.*]] = trunc i64 [[TMP131]] to i32
2222 ; CHECK-NEXT: [[TMP133:%.*]] = lshr i64 [[TMP131]], 32
2223 ; CHECK-NEXT: [[TMP134:%.*]] = trunc i64 [[TMP133]] to i32
2224 ; CHECK-NEXT: [[TMP135:%.*]] = add i32 [[TMP126]], [[TMP134]]
2225 ; CHECK-NEXT: [[TMP136:%.*]] = zext i32 [[TMP121]] to i64
2226 ; CHECK-NEXT: [[TMP137:%.*]] = zext i32 [[TMP135]] to i64
2227 ; CHECK-NEXT: [[TMP138:%.*]] = mul i64 [[TMP136]], [[TMP137]]
2228 ; CHECK-NEXT: [[TMP139:%.*]] = trunc i64 [[TMP138]] to i32
2229 ; CHECK-NEXT: [[TMP140:%.*]] = lshr i64 [[TMP138]], 32
2230 ; CHECK-NEXT: [[TMP141:%.*]] = trunc i64 [[TMP140]] to i32
2231 ; CHECK-NEXT: [[TMP142:%.*]] = mul i32 [[TMP141]], [[TMP122]]
2232 ; CHECK-NEXT: [[TMP143:%.*]] = sub i32 [[TMP121]], [[TMP142]]
2233 ; CHECK-NEXT: [[TMP144:%.*]] = icmp uge i32 [[TMP143]], [[TMP122]]
2234 ; CHECK-NEXT: [[TMP145:%.*]] = sub i32 [[TMP143]], [[TMP122]]
2235 ; CHECK-NEXT: [[TMP146:%.*]] = select i1 [[TMP144]], i32 [[TMP145]], i32 [[TMP143]]
2236 ; CHECK-NEXT: [[TMP147:%.*]] = icmp uge i32 [[TMP146]], [[TMP122]]
2237 ; CHECK-NEXT: [[TMP148:%.*]] = sub i32 [[TMP146]], [[TMP122]]
2238 ; CHECK-NEXT: [[TMP149:%.*]] = select i1 [[TMP147]], i32 [[TMP148]], i32 [[TMP146]]
2239 ; CHECK-NEXT: [[TMP150:%.*]] = xor i32 [[TMP149]], [[TMP117]]
2240 ; CHECK-NEXT: [[TMP151:%.*]] = sub i32 [[TMP150]], [[TMP117]]
2241 ; CHECK-NEXT: [[TMP152:%.*]] = insertelement <4 x i32> [[TMP114]], i32 [[TMP151]], i64 3
2242 ; CHECK-NEXT: store <4 x i32> [[TMP152]], ptr addrspace(1) [[OUT:%.*]], align 16
2243 ; CHECK-NEXT: ret void
2245 ; GFX6-LABEL: srem_v4i32:
2247 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
2248 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2249 ; GFX6-NEXT: s_abs_i32 s0, s8
2250 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s0
2251 ; GFX6-NEXT: s_sub_i32 s1, 0, s0
2252 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
2253 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2254 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
2255 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v0
2256 ; GFX6-NEXT: s_abs_i32 s1, s4
2257 ; GFX6-NEXT: s_ashr_i32 s4, s4, 31
2258 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
2259 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
2260 ; GFX6-NEXT: v_mul_hi_u32 v0, s1, v0
2261 ; GFX6-NEXT: v_readfirstlane_b32 s8, v0
2262 ; GFX6-NEXT: s_mul_i32 s8, s8, s0
2263 ; GFX6-NEXT: s_sub_i32 s1, s1, s8
2264 ; GFX6-NEXT: s_sub_i32 s8, s1, s0
2265 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
2266 ; GFX6-NEXT: s_cselect_b32 s1, s8, s1
2267 ; GFX6-NEXT: s_sub_i32 s8, s1, s0
2268 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
2269 ; GFX6-NEXT: s_cselect_b32 s0, s8, s1
2270 ; GFX6-NEXT: s_abs_i32 s1, s9
2271 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s1
2272 ; GFX6-NEXT: s_sub_i32 s8, 0, s1
2273 ; GFX6-NEXT: s_xor_b32 s0, s0, s4
2274 ; GFX6-NEXT: s_sub_i32 s0, s0, s4
2275 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
2276 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2277 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
2278 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v0
2279 ; GFX6-NEXT: s_abs_i32 s8, s5
2280 ; GFX6-NEXT: s_ashr_i32 s5, s5, 31
2281 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
2282 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
2283 ; GFX6-NEXT: v_mul_hi_u32 v0, s8, v0
2284 ; GFX6-NEXT: v_readfirstlane_b32 s4, v0
2285 ; GFX6-NEXT: s_mul_i32 s4, s4, s1
2286 ; GFX6-NEXT: s_sub_i32 s4, s8, s4
2287 ; GFX6-NEXT: s_sub_i32 s8, s4, s1
2288 ; GFX6-NEXT: s_cmp_ge_u32 s4, s1
2289 ; GFX6-NEXT: s_cselect_b32 s4, s8, s4
2290 ; GFX6-NEXT: s_sub_i32 s8, s4, s1
2291 ; GFX6-NEXT: s_cmp_ge_u32 s4, s1
2292 ; GFX6-NEXT: s_cselect_b32 s1, s8, s4
2293 ; GFX6-NEXT: s_abs_i32 s4, s10
2294 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s4
2295 ; GFX6-NEXT: s_sub_i32 s8, 0, s4
2296 ; GFX6-NEXT: s_xor_b32 s1, s1, s5
2297 ; GFX6-NEXT: s_sub_i32 s1, s1, s5
2298 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
2299 ; GFX6-NEXT: s_mov_b32 s10, -1
2300 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2301 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
2302 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v0
2303 ; GFX6-NEXT: s_abs_i32 s8, s6
2304 ; GFX6-NEXT: s_ashr_i32 s6, s6, 31
2305 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
2306 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
2307 ; GFX6-NEXT: v_mul_hi_u32 v0, s8, v0
2308 ; GFX6-NEXT: v_readfirstlane_b32 s5, v0
2309 ; GFX6-NEXT: s_mul_i32 s5, s5, s4
2310 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
2311 ; GFX6-NEXT: s_sub_i32 s8, s5, s4
2312 ; GFX6-NEXT: s_cmp_ge_u32 s5, s4
2313 ; GFX6-NEXT: s_cselect_b32 s5, s8, s5
2314 ; GFX6-NEXT: s_sub_i32 s8, s5, s4
2315 ; GFX6-NEXT: s_cmp_ge_u32 s5, s4
2316 ; GFX6-NEXT: s_cselect_b32 s4, s8, s5
2317 ; GFX6-NEXT: s_abs_i32 s5, s11
2318 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s5
2319 ; GFX6-NEXT: s_sub_i32 s8, 0, s5
2320 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
2321 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
2322 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2323 ; GFX6-NEXT: v_cvt_u32_f32_e32 v2, v0
2324 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
2325 ; GFX6-NEXT: s_abs_i32 s0, s7
2326 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v2
2327 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x9
2328 ; GFX6-NEXT: s_xor_b32 s2, s4, s6
2329 ; GFX6-NEXT: s_sub_i32 s2, s2, s6
2330 ; GFX6-NEXT: v_mul_hi_u32 v3, v2, v1
2331 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
2332 ; GFX6-NEXT: s_ashr_i32 s1, s7, 31
2333 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
2334 ; GFX6-NEXT: v_mul_hi_u32 v2, s0, v2
2335 ; GFX6-NEXT: v_readfirstlane_b32 s3, v2
2336 ; GFX6-NEXT: s_mul_i32 s3, s3, s5
2337 ; GFX6-NEXT: s_sub_i32 s0, s0, s3
2338 ; GFX6-NEXT: s_sub_i32 s3, s0, s5
2339 ; GFX6-NEXT: s_cmp_ge_u32 s0, s5
2340 ; GFX6-NEXT: s_cselect_b32 s0, s3, s0
2341 ; GFX6-NEXT: s_sub_i32 s3, s0, s5
2342 ; GFX6-NEXT: s_cmp_ge_u32 s0, s5
2343 ; GFX6-NEXT: s_cselect_b32 s0, s3, s0
2344 ; GFX6-NEXT: s_xor_b32 s0, s0, s1
2345 ; GFX6-NEXT: s_sub_i32 s0, s0, s1
2346 ; GFX6-NEXT: v_mov_b32_e32 v2, s2
2347 ; GFX6-NEXT: v_mov_b32_e32 v3, s0
2348 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2349 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
2350 ; GFX6-NEXT: s_endpgm
2352 ; GFX9-LABEL: srem_v4i32:
2354 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
2355 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
2356 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2357 ; GFX9-NEXT: s_abs_i32 s0, s8
2358 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
2359 ; GFX9-NEXT: s_sub_i32 s8, 0, s0
2360 ; GFX9-NEXT: s_ashr_i32 s1, s4, 31
2361 ; GFX9-NEXT: s_abs_i32 s4, s4
2362 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
2363 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2364 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
2365 ; GFX9-NEXT: v_readfirstlane_b32 s12, v0
2366 ; GFX9-NEXT: s_mul_i32 s8, s8, s12
2367 ; GFX9-NEXT: s_mul_hi_u32 s8, s12, s8
2368 ; GFX9-NEXT: s_add_i32 s12, s12, s8
2369 ; GFX9-NEXT: s_mul_hi_u32 s8, s4, s12
2370 ; GFX9-NEXT: s_mul_i32 s8, s8, s0
2371 ; GFX9-NEXT: s_sub_i32 s4, s4, s8
2372 ; GFX9-NEXT: s_sub_i32 s8, s4, s0
2373 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
2374 ; GFX9-NEXT: s_cselect_b32 s4, s8, s4
2375 ; GFX9-NEXT: s_sub_i32 s8, s4, s0
2376 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
2377 ; GFX9-NEXT: s_cselect_b32 s0, s8, s4
2378 ; GFX9-NEXT: s_abs_i32 s4, s9
2379 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s4
2380 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
2381 ; GFX9-NEXT: s_sub_i32 s9, 0, s4
2382 ; GFX9-NEXT: s_sub_i32 s12, s0, s1
2383 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
2384 ; GFX9-NEXT: s_ashr_i32 s8, s5, 31
2385 ; GFX9-NEXT: s_abs_i32 s5, s5
2386 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2387 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
2388 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2389 ; GFX9-NEXT: s_mul_i32 s9, s9, s0
2390 ; GFX9-NEXT: s_mul_hi_u32 s1, s0, s9
2391 ; GFX9-NEXT: s_add_i32 s0, s0, s1
2392 ; GFX9-NEXT: s_mul_hi_u32 s0, s5, s0
2393 ; GFX9-NEXT: s_mul_i32 s0, s0, s4
2394 ; GFX9-NEXT: s_sub_i32 s0, s5, s0
2395 ; GFX9-NEXT: s_sub_i32 s1, s0, s4
2396 ; GFX9-NEXT: s_cmp_ge_u32 s0, s4
2397 ; GFX9-NEXT: s_cselect_b32 s0, s1, s0
2398 ; GFX9-NEXT: s_sub_i32 s1, s0, s4
2399 ; GFX9-NEXT: s_cmp_ge_u32 s0, s4
2400 ; GFX9-NEXT: s_cselect_b32 s0, s1, s0
2401 ; GFX9-NEXT: s_abs_i32 s1, s10
2402 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
2403 ; GFX9-NEXT: s_xor_b32 s0, s0, s8
2404 ; GFX9-NEXT: s_ashr_i32 s4, s6, 31
2405 ; GFX9-NEXT: s_abs_i32 s5, s6
2406 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
2407 ; GFX9-NEXT: s_sub_i32 s6, 0, s1
2408 ; GFX9-NEXT: s_sub_i32 s8, s0, s8
2409 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
2410 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
2411 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2412 ; GFX9-NEXT: s_mul_i32 s6, s6, s0
2413 ; GFX9-NEXT: s_mul_hi_u32 s6, s0, s6
2414 ; GFX9-NEXT: s_add_i32 s0, s0, s6
2415 ; GFX9-NEXT: s_mul_hi_u32 s0, s5, s0
2416 ; GFX9-NEXT: s_mul_i32 s0, s0, s1
2417 ; GFX9-NEXT: s_sub_i32 s0, s5, s0
2418 ; GFX9-NEXT: s_sub_i32 s5, s0, s1
2419 ; GFX9-NEXT: s_cmp_ge_u32 s0, s1
2420 ; GFX9-NEXT: s_cselect_b32 s0, s5, s0
2421 ; GFX9-NEXT: s_sub_i32 s5, s0, s1
2422 ; GFX9-NEXT: s_cmp_ge_u32 s0, s1
2423 ; GFX9-NEXT: s_cselect_b32 s5, s5, s0
2424 ; GFX9-NEXT: s_abs_i32 s6, s11
2425 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s6
2426 ; GFX9-NEXT: s_xor_b32 s5, s5, s4
2427 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
2428 ; GFX9-NEXT: s_ashr_i32 s2, s7, 31
2429 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v1
2430 ; GFX9-NEXT: s_abs_i32 s3, s7
2431 ; GFX9-NEXT: s_sub_i32 s7, 0, s6
2432 ; GFX9-NEXT: s_sub_i32 s4, s5, s4
2433 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x4f7ffffe, v2
2434 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
2435 ; GFX9-NEXT: v_mov_b32_e32 v0, s12
2436 ; GFX9-NEXT: v_mov_b32_e32 v1, s8
2437 ; GFX9-NEXT: v_readfirstlane_b32 s5, v2
2438 ; GFX9-NEXT: s_mul_i32 s7, s7, s5
2439 ; GFX9-NEXT: s_mul_hi_u32 s7, s5, s7
2440 ; GFX9-NEXT: s_add_i32 s5, s5, s7
2441 ; GFX9-NEXT: s_mul_hi_u32 s5, s3, s5
2442 ; GFX9-NEXT: s_mul_i32 s5, s5, s6
2443 ; GFX9-NEXT: s_sub_i32 s3, s3, s5
2444 ; GFX9-NEXT: s_sub_i32 s5, s3, s6
2445 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
2446 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
2447 ; GFX9-NEXT: s_sub_i32 s5, s3, s6
2448 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
2449 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
2450 ; GFX9-NEXT: s_xor_b32 s3, s3, s2
2451 ; GFX9-NEXT: s_sub_i32 s2, s3, s2
2452 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
2453 ; GFX9-NEXT: v_mov_b32_e32 v3, s2
2454 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2455 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
2456 ; GFX9-NEXT: s_endpgm
2457 %r = srem <4 x i32> %x, %y
2458 store <4 x i32> %r, ptr addrspace(1) %out
2462 define amdgpu_kernel void @udiv_v4i16(ptr addrspace(1) %out, <4 x i16> %x, <4 x i16> %y) {
2463 ; CHECK-LABEL: @udiv_v4i16(
2464 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i16> [[X:%.*]], i64 0
2465 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i16> [[Y:%.*]], i64 0
2466 ; CHECK-NEXT: [[TMP3:%.*]] = zext i16 [[TMP1]] to i32
2467 ; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP2]] to i32
2468 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
2469 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
2470 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
2471 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
2472 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
2473 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
2474 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
2475 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
2476 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
2477 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
2478 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
2479 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
2480 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
2481 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 65535
2482 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i16
2483 ; CHECK-NEXT: [[TMP20:%.*]] = insertelement <4 x i16> poison, i16 [[TMP19]], i64 0
2484 ; CHECK-NEXT: [[TMP21:%.*]] = extractelement <4 x i16> [[X]], i64 1
2485 ; CHECK-NEXT: [[TMP22:%.*]] = extractelement <4 x i16> [[Y]], i64 1
2486 ; CHECK-NEXT: [[TMP23:%.*]] = zext i16 [[TMP21]] to i32
2487 ; CHECK-NEXT: [[TMP24:%.*]] = zext i16 [[TMP22]] to i32
2488 ; CHECK-NEXT: [[TMP25:%.*]] = uitofp i32 [[TMP23]] to float
2489 ; CHECK-NEXT: [[TMP26:%.*]] = uitofp i32 [[TMP24]] to float
2490 ; CHECK-NEXT: [[TMP27:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP26]])
2491 ; CHECK-NEXT: [[TMP28:%.*]] = fmul fast float [[TMP25]], [[TMP27]]
2492 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.trunc.f32(float [[TMP28]])
2493 ; CHECK-NEXT: [[TMP30:%.*]] = fneg fast float [[TMP29]]
2494 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP30]], float [[TMP26]], float [[TMP25]])
2495 ; CHECK-NEXT: [[TMP32:%.*]] = fptoui float [[TMP29]] to i32
2496 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.fabs.f32(float [[TMP31]])
2497 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.fabs.f32(float [[TMP26]])
2498 ; CHECK-NEXT: [[TMP35:%.*]] = fcmp fast oge float [[TMP33]], [[TMP34]]
2499 ; CHECK-NEXT: [[TMP36:%.*]] = select i1 [[TMP35]], i32 1, i32 0
2500 ; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP32]], [[TMP36]]
2501 ; CHECK-NEXT: [[TMP38:%.*]] = and i32 [[TMP37]], 65535
2502 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i32 [[TMP38]] to i16
2503 ; CHECK-NEXT: [[TMP40:%.*]] = insertelement <4 x i16> [[TMP20]], i16 [[TMP39]], i64 1
2504 ; CHECK-NEXT: [[TMP41:%.*]] = extractelement <4 x i16> [[X]], i64 2
2505 ; CHECK-NEXT: [[TMP42:%.*]] = extractelement <4 x i16> [[Y]], i64 2
2506 ; CHECK-NEXT: [[TMP43:%.*]] = zext i16 [[TMP41]] to i32
2507 ; CHECK-NEXT: [[TMP44:%.*]] = zext i16 [[TMP42]] to i32
2508 ; CHECK-NEXT: [[TMP45:%.*]] = uitofp i32 [[TMP43]] to float
2509 ; CHECK-NEXT: [[TMP46:%.*]] = uitofp i32 [[TMP44]] to float
2510 ; CHECK-NEXT: [[TMP47:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP46]])
2511 ; CHECK-NEXT: [[TMP48:%.*]] = fmul fast float [[TMP45]], [[TMP47]]
2512 ; CHECK-NEXT: [[TMP49:%.*]] = call fast float @llvm.trunc.f32(float [[TMP48]])
2513 ; CHECK-NEXT: [[TMP50:%.*]] = fneg fast float [[TMP49]]
2514 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP50]], float [[TMP46]], float [[TMP45]])
2515 ; CHECK-NEXT: [[TMP52:%.*]] = fptoui float [[TMP49]] to i32
2516 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.fabs.f32(float [[TMP51]])
2517 ; CHECK-NEXT: [[TMP54:%.*]] = call fast float @llvm.fabs.f32(float [[TMP46]])
2518 ; CHECK-NEXT: [[TMP55:%.*]] = fcmp fast oge float [[TMP53]], [[TMP54]]
2519 ; CHECK-NEXT: [[TMP56:%.*]] = select i1 [[TMP55]], i32 1, i32 0
2520 ; CHECK-NEXT: [[TMP57:%.*]] = add i32 [[TMP52]], [[TMP56]]
2521 ; CHECK-NEXT: [[TMP58:%.*]] = and i32 [[TMP57]], 65535
2522 ; CHECK-NEXT: [[TMP59:%.*]] = trunc i32 [[TMP58]] to i16
2523 ; CHECK-NEXT: [[TMP60:%.*]] = insertelement <4 x i16> [[TMP40]], i16 [[TMP59]], i64 2
2524 ; CHECK-NEXT: [[TMP61:%.*]] = extractelement <4 x i16> [[X]], i64 3
2525 ; CHECK-NEXT: [[TMP62:%.*]] = extractelement <4 x i16> [[Y]], i64 3
2526 ; CHECK-NEXT: [[TMP63:%.*]] = zext i16 [[TMP61]] to i32
2527 ; CHECK-NEXT: [[TMP64:%.*]] = zext i16 [[TMP62]] to i32
2528 ; CHECK-NEXT: [[TMP65:%.*]] = uitofp i32 [[TMP63]] to float
2529 ; CHECK-NEXT: [[TMP66:%.*]] = uitofp i32 [[TMP64]] to float
2530 ; CHECK-NEXT: [[TMP67:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP66]])
2531 ; CHECK-NEXT: [[TMP68:%.*]] = fmul fast float [[TMP65]], [[TMP67]]
2532 ; CHECK-NEXT: [[TMP69:%.*]] = call fast float @llvm.trunc.f32(float [[TMP68]])
2533 ; CHECK-NEXT: [[TMP70:%.*]] = fneg fast float [[TMP69]]
2534 ; CHECK-NEXT: [[TMP71:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP70]], float [[TMP66]], float [[TMP65]])
2535 ; CHECK-NEXT: [[TMP72:%.*]] = fptoui float [[TMP69]] to i32
2536 ; CHECK-NEXT: [[TMP73:%.*]] = call fast float @llvm.fabs.f32(float [[TMP71]])
2537 ; CHECK-NEXT: [[TMP74:%.*]] = call fast float @llvm.fabs.f32(float [[TMP66]])
2538 ; CHECK-NEXT: [[TMP75:%.*]] = fcmp fast oge float [[TMP73]], [[TMP74]]
2539 ; CHECK-NEXT: [[TMP76:%.*]] = select i1 [[TMP75]], i32 1, i32 0
2540 ; CHECK-NEXT: [[TMP77:%.*]] = add i32 [[TMP72]], [[TMP76]]
2541 ; CHECK-NEXT: [[TMP78:%.*]] = and i32 [[TMP77]], 65535
2542 ; CHECK-NEXT: [[TMP79:%.*]] = trunc i32 [[TMP78]] to i16
2543 ; CHECK-NEXT: [[TMP80:%.*]] = insertelement <4 x i16> [[TMP60]], i16 [[TMP79]], i64 3
2544 ; CHECK-NEXT: store <4 x i16> [[TMP80]], ptr addrspace(1) [[OUT:%.*]], align 8
2545 ; CHECK-NEXT: ret void
2547 ; GFX6-LABEL: udiv_v4i16:
2549 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
2550 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
2551 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
2552 ; GFX6-NEXT: s_mov_b32 s2, -1
2553 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2554 ; GFX6-NEXT: s_and_b32 s9, s6, 0xffff
2555 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s9
2556 ; GFX6-NEXT: s_lshr_b32 s6, s6, 16
2557 ; GFX6-NEXT: s_and_b32 s8, s4, 0xffff
2558 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
2559 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s8
2560 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
2561 ; GFX6-NEXT: s_lshr_b32 s4, s4, 16
2562 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
2563 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
2564 ; GFX6-NEXT: v_mul_f32_e32 v3, v1, v3
2565 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
2566 ; GFX6-NEXT: v_mad_f32 v1, -v3, v0, v1
2567 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
2568 ; GFX6-NEXT: v_mul_f32_e32 v1, v4, v5
2569 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
2570 ; GFX6-NEXT: s_and_b32 s4, s7, 0xffff
2571 ; GFX6-NEXT: v_cvt_u32_f32_e32 v6, v3
2572 ; GFX6-NEXT: v_mad_f32 v3, -v1, v2, v4
2573 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
2574 ; GFX6-NEXT: s_and_b32 s4, s5, 0xffff
2575 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v6, vcc
2576 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
2577 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s4
2578 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v4
2579 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v2
2580 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v1, vcc
2581 ; GFX6-NEXT: v_mul_f32_e32 v1, v5, v6
2582 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
2583 ; GFX6-NEXT: s_lshr_b32 s4, s7, 16
2584 ; GFX6-NEXT: v_mad_f32 v3, -v1, v4, v5
2585 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s4
2586 ; GFX6-NEXT: s_lshr_b32 s4, s5, 16
2587 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s4
2588 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
2589 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v7, v5
2590 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v4
2591 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
2592 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
2593 ; GFX6-NEXT: v_mul_f32_e32 v3, v6, v7
2594 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
2595 ; GFX6-NEXT: v_cvt_u32_f32_e32 v4, v3
2596 ; GFX6-NEXT: v_mad_f32 v3, -v3, v5, v6
2597 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v5
2598 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
2599 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
2600 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
2601 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
2602 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v3
2603 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v2
2604 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
2605 ; GFX6-NEXT: s_endpgm
2607 ; GFX9-LABEL: udiv_v4i16:
2609 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
2610 ; GFX9-NEXT: v_mov_b32_e32 v6, 0
2611 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2612 ; GFX9-NEXT: s_and_b32 s1, s6, 0xffff
2613 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
2614 ; GFX9-NEXT: s_and_b32 s0, s4, 0xffff
2615 ; GFX9-NEXT: s_lshr_b32 s6, s6, 16
2616 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s0
2617 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
2618 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s6
2619 ; GFX9-NEXT: s_lshr_b32 s4, s4, 16
2620 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s4
2621 ; GFX9-NEXT: v_mul_f32_e32 v4, v2, v4
2622 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
2623 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
2624 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
2625 ; GFX9-NEXT: s_and_b32 s2, s7, 0xffff
2626 ; GFX9-NEXT: v_cvt_u32_f32_e32 v7, v4
2627 ; GFX9-NEXT: v_mad_f32 v2, -v4, v0, v2
2628 ; GFX9-NEXT: v_cvt_f32_u32_e32 v4, s2
2629 ; GFX9-NEXT: v_mul_f32_e32 v5, v3, v5
2630 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v0
2631 ; GFX9-NEXT: s_and_b32 s2, s5, 0xffff
2632 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v7, vcc
2633 ; GFX9-NEXT: v_trunc_f32_e32 v2, v5
2634 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s2
2635 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v4
2636 ; GFX9-NEXT: v_mad_f32 v3, -v2, v1, v3
2637 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v1
2638 ; GFX9-NEXT: s_lshr_b32 s2, s7, 16
2639 ; GFX9-NEXT: v_mul_f32_e32 v1, v5, v7
2640 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
2641 ; GFX9-NEXT: v_mad_f32 v3, -v1, v4, v5
2642 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s2
2643 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
2644 ; GFX9-NEXT: s_lshr_b32 s2, s5, 16
2645 ; GFX9-NEXT: v_cvt_f32_u32_e32 v7, s2
2646 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v8, v5
2647 ; GFX9-NEXT: v_addc_co_u32_e32 v2, vcc, 0, v2, vcc
2648 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
2649 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v4
2650 ; GFX9-NEXT: v_mul_f32_e32 v3, v7, v8
2651 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
2652 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v3
2653 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
2654 ; GFX9-NEXT: v_mad_f32 v3, -v3, v5, v7
2655 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v5
2656 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, 0, v4, vcc
2657 ; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1
2658 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0
2659 ; GFX9-NEXT: v_lshl_or_b32 v1, v3, 16, v1
2660 ; GFX9-NEXT: v_lshl_or_b32 v0, v2, 16, v0
2661 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2662 ; GFX9-NEXT: global_store_dwordx2 v6, v[0:1], s[0:1]
2663 ; GFX9-NEXT: s_endpgm
2664 %r = udiv <4 x i16> %x, %y
2665 store <4 x i16> %r, ptr addrspace(1) %out
2669 define amdgpu_kernel void @urem_v4i16(ptr addrspace(1) %out, <4 x i16> %x, <4 x i16> %y) {
2670 ; CHECK-LABEL: @urem_v4i16(
2671 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i16> [[X:%.*]], i64 0
2672 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i16> [[Y:%.*]], i64 0
2673 ; CHECK-NEXT: [[TMP3:%.*]] = zext i16 [[TMP1]] to i32
2674 ; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP2]] to i32
2675 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
2676 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
2677 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
2678 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
2679 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
2680 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
2681 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
2682 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
2683 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
2684 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
2685 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
2686 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
2687 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
2688 ; CHECK-NEXT: [[TMP18:%.*]] = mul i32 [[TMP17]], [[TMP4]]
2689 ; CHECK-NEXT: [[TMP19:%.*]] = sub i32 [[TMP3]], [[TMP18]]
2690 ; CHECK-NEXT: [[TMP20:%.*]] = and i32 [[TMP19]], 65535
2691 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i16
2692 ; CHECK-NEXT: [[TMP22:%.*]] = insertelement <4 x i16> poison, i16 [[TMP21]], i64 0
2693 ; CHECK-NEXT: [[TMP23:%.*]] = extractelement <4 x i16> [[X]], i64 1
2694 ; CHECK-NEXT: [[TMP24:%.*]] = extractelement <4 x i16> [[Y]], i64 1
2695 ; CHECK-NEXT: [[TMP25:%.*]] = zext i16 [[TMP23]] to i32
2696 ; CHECK-NEXT: [[TMP26:%.*]] = zext i16 [[TMP24]] to i32
2697 ; CHECK-NEXT: [[TMP27:%.*]] = uitofp i32 [[TMP25]] to float
2698 ; CHECK-NEXT: [[TMP28:%.*]] = uitofp i32 [[TMP26]] to float
2699 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP28]])
2700 ; CHECK-NEXT: [[TMP30:%.*]] = fmul fast float [[TMP27]], [[TMP29]]
2701 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.trunc.f32(float [[TMP30]])
2702 ; CHECK-NEXT: [[TMP32:%.*]] = fneg fast float [[TMP31]]
2703 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP32]], float [[TMP28]], float [[TMP27]])
2704 ; CHECK-NEXT: [[TMP34:%.*]] = fptoui float [[TMP31]] to i32
2705 ; CHECK-NEXT: [[TMP35:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
2706 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.fabs.f32(float [[TMP28]])
2707 ; CHECK-NEXT: [[TMP37:%.*]] = fcmp fast oge float [[TMP35]], [[TMP36]]
2708 ; CHECK-NEXT: [[TMP38:%.*]] = select i1 [[TMP37]], i32 1, i32 0
2709 ; CHECK-NEXT: [[TMP39:%.*]] = add i32 [[TMP34]], [[TMP38]]
2710 ; CHECK-NEXT: [[TMP40:%.*]] = mul i32 [[TMP39]], [[TMP26]]
2711 ; CHECK-NEXT: [[TMP41:%.*]] = sub i32 [[TMP25]], [[TMP40]]
2712 ; CHECK-NEXT: [[TMP42:%.*]] = and i32 [[TMP41]], 65535
2713 ; CHECK-NEXT: [[TMP43:%.*]] = trunc i32 [[TMP42]] to i16
2714 ; CHECK-NEXT: [[TMP44:%.*]] = insertelement <4 x i16> [[TMP22]], i16 [[TMP43]], i64 1
2715 ; CHECK-NEXT: [[TMP45:%.*]] = extractelement <4 x i16> [[X]], i64 2
2716 ; CHECK-NEXT: [[TMP46:%.*]] = extractelement <4 x i16> [[Y]], i64 2
2717 ; CHECK-NEXT: [[TMP47:%.*]] = zext i16 [[TMP45]] to i32
2718 ; CHECK-NEXT: [[TMP48:%.*]] = zext i16 [[TMP46]] to i32
2719 ; CHECK-NEXT: [[TMP49:%.*]] = uitofp i32 [[TMP47]] to float
2720 ; CHECK-NEXT: [[TMP50:%.*]] = uitofp i32 [[TMP48]] to float
2721 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP50]])
2722 ; CHECK-NEXT: [[TMP52:%.*]] = fmul fast float [[TMP49]], [[TMP51]]
2723 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.trunc.f32(float [[TMP52]])
2724 ; CHECK-NEXT: [[TMP54:%.*]] = fneg fast float [[TMP53]]
2725 ; CHECK-NEXT: [[TMP55:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP54]], float [[TMP50]], float [[TMP49]])
2726 ; CHECK-NEXT: [[TMP56:%.*]] = fptoui float [[TMP53]] to i32
2727 ; CHECK-NEXT: [[TMP57:%.*]] = call fast float @llvm.fabs.f32(float [[TMP55]])
2728 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.fabs.f32(float [[TMP50]])
2729 ; CHECK-NEXT: [[TMP59:%.*]] = fcmp fast oge float [[TMP57]], [[TMP58]]
2730 ; CHECK-NEXT: [[TMP60:%.*]] = select i1 [[TMP59]], i32 1, i32 0
2731 ; CHECK-NEXT: [[TMP61:%.*]] = add i32 [[TMP56]], [[TMP60]]
2732 ; CHECK-NEXT: [[TMP62:%.*]] = mul i32 [[TMP61]], [[TMP48]]
2733 ; CHECK-NEXT: [[TMP63:%.*]] = sub i32 [[TMP47]], [[TMP62]]
2734 ; CHECK-NEXT: [[TMP64:%.*]] = and i32 [[TMP63]], 65535
2735 ; CHECK-NEXT: [[TMP65:%.*]] = trunc i32 [[TMP64]] to i16
2736 ; CHECK-NEXT: [[TMP66:%.*]] = insertelement <4 x i16> [[TMP44]], i16 [[TMP65]], i64 2
2737 ; CHECK-NEXT: [[TMP67:%.*]] = extractelement <4 x i16> [[X]], i64 3
2738 ; CHECK-NEXT: [[TMP68:%.*]] = extractelement <4 x i16> [[Y]], i64 3
2739 ; CHECK-NEXT: [[TMP69:%.*]] = zext i16 [[TMP67]] to i32
2740 ; CHECK-NEXT: [[TMP70:%.*]] = zext i16 [[TMP68]] to i32
2741 ; CHECK-NEXT: [[TMP71:%.*]] = uitofp i32 [[TMP69]] to float
2742 ; CHECK-NEXT: [[TMP72:%.*]] = uitofp i32 [[TMP70]] to float
2743 ; CHECK-NEXT: [[TMP73:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP72]])
2744 ; CHECK-NEXT: [[TMP74:%.*]] = fmul fast float [[TMP71]], [[TMP73]]
2745 ; CHECK-NEXT: [[TMP75:%.*]] = call fast float @llvm.trunc.f32(float [[TMP74]])
2746 ; CHECK-NEXT: [[TMP76:%.*]] = fneg fast float [[TMP75]]
2747 ; CHECK-NEXT: [[TMP77:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP76]], float [[TMP72]], float [[TMP71]])
2748 ; CHECK-NEXT: [[TMP78:%.*]] = fptoui float [[TMP75]] to i32
2749 ; CHECK-NEXT: [[TMP79:%.*]] = call fast float @llvm.fabs.f32(float [[TMP77]])
2750 ; CHECK-NEXT: [[TMP80:%.*]] = call fast float @llvm.fabs.f32(float [[TMP72]])
2751 ; CHECK-NEXT: [[TMP81:%.*]] = fcmp fast oge float [[TMP79]], [[TMP80]]
2752 ; CHECK-NEXT: [[TMP82:%.*]] = select i1 [[TMP81]], i32 1, i32 0
2753 ; CHECK-NEXT: [[TMP83:%.*]] = add i32 [[TMP78]], [[TMP82]]
2754 ; CHECK-NEXT: [[TMP84:%.*]] = mul i32 [[TMP83]], [[TMP70]]
2755 ; CHECK-NEXT: [[TMP85:%.*]] = sub i32 [[TMP69]], [[TMP84]]
2756 ; CHECK-NEXT: [[TMP86:%.*]] = and i32 [[TMP85]], 65535
2757 ; CHECK-NEXT: [[TMP87:%.*]] = trunc i32 [[TMP86]] to i16
2758 ; CHECK-NEXT: [[TMP88:%.*]] = insertelement <4 x i16> [[TMP66]], i16 [[TMP87]], i64 3
2759 ; CHECK-NEXT: store <4 x i16> [[TMP88]], ptr addrspace(1) [[OUT:%.*]], align 8
2760 ; CHECK-NEXT: ret void
2762 ; GFX6-LABEL: urem_v4i16:
2764 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
2765 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
2766 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
2767 ; GFX6-NEXT: s_mov_b32 s2, -1
2768 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2769 ; GFX6-NEXT: s_and_b32 s9, s6, 0xffff
2770 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s9
2771 ; GFX6-NEXT: s_and_b32 s8, s4, 0xffff
2772 ; GFX6-NEXT: s_lshr_b32 s9, s6, 16
2773 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s8
2774 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
2775 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s9
2776 ; GFX6-NEXT: s_lshr_b32 s8, s4, 16
2777 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s8
2778 ; GFX6-NEXT: v_mul_f32_e32 v3, v1, v3
2779 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
2780 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
2781 ; GFX6-NEXT: v_cvt_u32_f32_e32 v6, v3
2782 ; GFX6-NEXT: v_mad_f32 v1, -v3, v0, v1
2783 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
2784 ; GFX6-NEXT: v_mul_f32_e32 v1, v4, v5
2785 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v6, vcc
2786 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
2787 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s6
2788 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v1
2789 ; GFX6-NEXT: v_mad_f32 v1, -v1, v2, v4
2790 ; GFX6-NEXT: s_and_b32 s6, s7, 0xffff
2791 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v2
2792 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
2793 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
2794 ; GFX6-NEXT: s_and_b32 s6, s5, 0xffff
2795 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s9
2796 ; GFX6-NEXT: v_cvt_f32_u32_e32 v3, s6
2797 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v2
2798 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
2799 ; GFX6-NEXT: s_lshr_b32 s4, s7, 16
2800 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s8, v1
2801 ; GFX6-NEXT: v_mul_f32_e32 v1, v3, v4
2802 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
2803 ; GFX6-NEXT: s_lshr_b32 s6, s5, 16
2804 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s6
2805 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
2806 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v7, v4
2807 ; GFX6-NEXT: v_mad_f32 v3, -v1, v2, v3
2808 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
2809 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v2
2810 ; GFX6-NEXT: v_mul_f32_e32 v2, v6, v7
2811 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
2812 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v2
2813 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
2814 ; GFX6-NEXT: v_mad_f32 v2, -v2, v4, v6
2815 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v4
2816 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
2817 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s7
2818 ; GFX6-NEXT: v_mul_lo_u32 v2, v2, s4
2819 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
2820 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s5, v1
2821 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s6, v2
2822 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
2823 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
2824 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
2825 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v5
2826 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v2
2827 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
2828 ; GFX6-NEXT: s_endpgm
2830 ; GFX9-LABEL: urem_v4i16:
2832 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
2833 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
2834 ; GFX9-NEXT: v_mov_b32_e32 v6, 0
2835 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
2836 ; GFX9-NEXT: s_and_b32 s9, s6, 0xffff
2837 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s9
2838 ; GFX9-NEXT: s_and_b32 s8, s4, 0xffff
2839 ; GFX9-NEXT: s_lshr_b32 s6, s6, 16
2840 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s6
2841 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s8
2842 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
2843 ; GFX9-NEXT: s_lshr_b32 s4, s4, 16
2844 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s4
2845 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
2846 ; GFX9-NEXT: v_mul_f32_e32 v4, v2, v4
2847 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
2848 ; GFX9-NEXT: s_and_b32 s2, s7, 0xffff
2849 ; GFX9-NEXT: v_cvt_u32_f32_e32 v7, v4
2850 ; GFX9-NEXT: v_mad_f32 v2, -v4, v0, v2
2851 ; GFX9-NEXT: v_cvt_f32_u32_e32 v4, s2
2852 ; GFX9-NEXT: v_mul_f32_e32 v5, v3, v5
2853 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v0
2854 ; GFX9-NEXT: v_trunc_f32_e32 v2, v5
2855 ; GFX9-NEXT: s_and_b32 s3, s5, 0xffff
2856 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v7, vcc
2857 ; GFX9-NEXT: v_mad_f32 v3, -v2, v1, v3
2858 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
2859 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s3
2860 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v4
2861 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v1
2862 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v2, vcc
2863 ; GFX9-NEXT: v_mul_f32_e32 v2, v5, v7
2864 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, s6
2865 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
2866 ; GFX9-NEXT: s_lshr_b32 s6, s7, 16
2867 ; GFX9-NEXT: v_mad_f32 v3, -v2, v4, v5
2868 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s6
2869 ; GFX9-NEXT: s_lshr_b32 s5, s5, 16
2870 ; GFX9-NEXT: v_cvt_f32_u32_e32 v7, s5
2871 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
2872 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v8, v5
2873 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v4
2874 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s9
2875 ; GFX9-NEXT: v_addc_co_u32_e32 v2, vcc, 0, v2, vcc
2876 ; GFX9-NEXT: v_mul_f32_e32 v3, v7, v8
2877 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
2878 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v3
2879 ; GFX9-NEXT: v_mad_f32 v3, -v3, v5, v7
2880 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v5
2881 ; GFX9-NEXT: v_mul_lo_u32 v2, v2, s2
2882 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, 0, v4, vcc
2883 ; GFX9-NEXT: v_mul_lo_u32 v3, v3, s6
2884 ; GFX9-NEXT: v_sub_u32_e32 v0, s8, v0
2885 ; GFX9-NEXT: v_sub_u32_e32 v4, s4, v1
2886 ; GFX9-NEXT: v_sub_u32_e32 v1, s3, v2
2887 ; GFX9-NEXT: v_sub_u32_e32 v2, s5, v3
2888 ; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1
2889 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0
2890 ; GFX9-NEXT: v_lshl_or_b32 v1, v2, 16, v1
2891 ; GFX9-NEXT: v_lshl_or_b32 v0, v4, 16, v0
2892 ; GFX9-NEXT: global_store_dwordx2 v6, v[0:1], s[0:1]
2893 ; GFX9-NEXT: s_endpgm
2894 %r = urem <4 x i16> %x, %y
2895 store <4 x i16> %r, ptr addrspace(1) %out
2899 define amdgpu_kernel void @sdiv_v4i16(ptr addrspace(1) %out, <4 x i16> %x, <4 x i16> %y) {
2900 ; CHECK-LABEL: @sdiv_v4i16(
2901 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i16> [[X:%.*]], i64 0
2902 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i16> [[Y:%.*]], i64 0
2903 ; CHECK-NEXT: [[TMP3:%.*]] = sext i16 [[TMP1]] to i32
2904 ; CHECK-NEXT: [[TMP4:%.*]] = sext i16 [[TMP2]] to i32
2905 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
2906 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
2907 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
2908 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
2909 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
2910 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
2911 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
2912 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
2913 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
2914 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
2915 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
2916 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
2917 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
2918 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
2919 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
2920 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
2921 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 16
2922 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 16
2923 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i16
2924 ; CHECK-NEXT: [[TMP24:%.*]] = insertelement <4 x i16> poison, i16 [[TMP23]], i64 0
2925 ; CHECK-NEXT: [[TMP25:%.*]] = extractelement <4 x i16> [[X]], i64 1
2926 ; CHECK-NEXT: [[TMP26:%.*]] = extractelement <4 x i16> [[Y]], i64 1
2927 ; CHECK-NEXT: [[TMP27:%.*]] = sext i16 [[TMP25]] to i32
2928 ; CHECK-NEXT: [[TMP28:%.*]] = sext i16 [[TMP26]] to i32
2929 ; CHECK-NEXT: [[TMP29:%.*]] = xor i32 [[TMP27]], [[TMP28]]
2930 ; CHECK-NEXT: [[TMP30:%.*]] = ashr i32 [[TMP29]], 30
2931 ; CHECK-NEXT: [[TMP31:%.*]] = or i32 [[TMP30]], 1
2932 ; CHECK-NEXT: [[TMP32:%.*]] = sitofp i32 [[TMP27]] to float
2933 ; CHECK-NEXT: [[TMP33:%.*]] = sitofp i32 [[TMP28]] to float
2934 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP33]])
2935 ; CHECK-NEXT: [[TMP35:%.*]] = fmul fast float [[TMP32]], [[TMP34]]
2936 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.trunc.f32(float [[TMP35]])
2937 ; CHECK-NEXT: [[TMP37:%.*]] = fneg fast float [[TMP36]]
2938 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP37]], float [[TMP33]], float [[TMP32]])
2939 ; CHECK-NEXT: [[TMP39:%.*]] = fptosi float [[TMP36]] to i32
2940 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.fabs.f32(float [[TMP38]])
2941 ; CHECK-NEXT: [[TMP41:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
2942 ; CHECK-NEXT: [[TMP42:%.*]] = fcmp fast oge float [[TMP40]], [[TMP41]]
2943 ; CHECK-NEXT: [[TMP43:%.*]] = select i1 [[TMP42]], i32 [[TMP31]], i32 0
2944 ; CHECK-NEXT: [[TMP44:%.*]] = add i32 [[TMP39]], [[TMP43]]
2945 ; CHECK-NEXT: [[TMP45:%.*]] = shl i32 [[TMP44]], 16
2946 ; CHECK-NEXT: [[TMP46:%.*]] = ashr i32 [[TMP45]], 16
2947 ; CHECK-NEXT: [[TMP47:%.*]] = trunc i32 [[TMP46]] to i16
2948 ; CHECK-NEXT: [[TMP48:%.*]] = insertelement <4 x i16> [[TMP24]], i16 [[TMP47]], i64 1
2949 ; CHECK-NEXT: [[TMP49:%.*]] = extractelement <4 x i16> [[X]], i64 2
2950 ; CHECK-NEXT: [[TMP50:%.*]] = extractelement <4 x i16> [[Y]], i64 2
2951 ; CHECK-NEXT: [[TMP51:%.*]] = sext i16 [[TMP49]] to i32
2952 ; CHECK-NEXT: [[TMP52:%.*]] = sext i16 [[TMP50]] to i32
2953 ; CHECK-NEXT: [[TMP53:%.*]] = xor i32 [[TMP51]], [[TMP52]]
2954 ; CHECK-NEXT: [[TMP54:%.*]] = ashr i32 [[TMP53]], 30
2955 ; CHECK-NEXT: [[TMP55:%.*]] = or i32 [[TMP54]], 1
2956 ; CHECK-NEXT: [[TMP56:%.*]] = sitofp i32 [[TMP51]] to float
2957 ; CHECK-NEXT: [[TMP57:%.*]] = sitofp i32 [[TMP52]] to float
2958 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP57]])
2959 ; CHECK-NEXT: [[TMP59:%.*]] = fmul fast float [[TMP56]], [[TMP58]]
2960 ; CHECK-NEXT: [[TMP60:%.*]] = call fast float @llvm.trunc.f32(float [[TMP59]])
2961 ; CHECK-NEXT: [[TMP61:%.*]] = fneg fast float [[TMP60]]
2962 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP61]], float [[TMP57]], float [[TMP56]])
2963 ; CHECK-NEXT: [[TMP63:%.*]] = fptosi float [[TMP60]] to i32
2964 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.fabs.f32(float [[TMP62]])
2965 ; CHECK-NEXT: [[TMP65:%.*]] = call fast float @llvm.fabs.f32(float [[TMP57]])
2966 ; CHECK-NEXT: [[TMP66:%.*]] = fcmp fast oge float [[TMP64]], [[TMP65]]
2967 ; CHECK-NEXT: [[TMP67:%.*]] = select i1 [[TMP66]], i32 [[TMP55]], i32 0
2968 ; CHECK-NEXT: [[TMP68:%.*]] = add i32 [[TMP63]], [[TMP67]]
2969 ; CHECK-NEXT: [[TMP69:%.*]] = shl i32 [[TMP68]], 16
2970 ; CHECK-NEXT: [[TMP70:%.*]] = ashr i32 [[TMP69]], 16
2971 ; CHECK-NEXT: [[TMP71:%.*]] = trunc i32 [[TMP70]] to i16
2972 ; CHECK-NEXT: [[TMP72:%.*]] = insertelement <4 x i16> [[TMP48]], i16 [[TMP71]], i64 2
2973 ; CHECK-NEXT: [[TMP73:%.*]] = extractelement <4 x i16> [[X]], i64 3
2974 ; CHECK-NEXT: [[TMP74:%.*]] = extractelement <4 x i16> [[Y]], i64 3
2975 ; CHECK-NEXT: [[TMP75:%.*]] = sext i16 [[TMP73]] to i32
2976 ; CHECK-NEXT: [[TMP76:%.*]] = sext i16 [[TMP74]] to i32
2977 ; CHECK-NEXT: [[TMP77:%.*]] = xor i32 [[TMP75]], [[TMP76]]
2978 ; CHECK-NEXT: [[TMP78:%.*]] = ashr i32 [[TMP77]], 30
2979 ; CHECK-NEXT: [[TMP79:%.*]] = or i32 [[TMP78]], 1
2980 ; CHECK-NEXT: [[TMP80:%.*]] = sitofp i32 [[TMP75]] to float
2981 ; CHECK-NEXT: [[TMP81:%.*]] = sitofp i32 [[TMP76]] to float
2982 ; CHECK-NEXT: [[TMP82:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP81]])
2983 ; CHECK-NEXT: [[TMP83:%.*]] = fmul fast float [[TMP80]], [[TMP82]]
2984 ; CHECK-NEXT: [[TMP84:%.*]] = call fast float @llvm.trunc.f32(float [[TMP83]])
2985 ; CHECK-NEXT: [[TMP85:%.*]] = fneg fast float [[TMP84]]
2986 ; CHECK-NEXT: [[TMP86:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP85]], float [[TMP81]], float [[TMP80]])
2987 ; CHECK-NEXT: [[TMP87:%.*]] = fptosi float [[TMP84]] to i32
2988 ; CHECK-NEXT: [[TMP88:%.*]] = call fast float @llvm.fabs.f32(float [[TMP86]])
2989 ; CHECK-NEXT: [[TMP89:%.*]] = call fast float @llvm.fabs.f32(float [[TMP81]])
2990 ; CHECK-NEXT: [[TMP90:%.*]] = fcmp fast oge float [[TMP88]], [[TMP89]]
2991 ; CHECK-NEXT: [[TMP91:%.*]] = select i1 [[TMP90]], i32 [[TMP79]], i32 0
2992 ; CHECK-NEXT: [[TMP92:%.*]] = add i32 [[TMP87]], [[TMP91]]
2993 ; CHECK-NEXT: [[TMP93:%.*]] = shl i32 [[TMP92]], 16
2994 ; CHECK-NEXT: [[TMP94:%.*]] = ashr i32 [[TMP93]], 16
2995 ; CHECK-NEXT: [[TMP95:%.*]] = trunc i32 [[TMP94]] to i16
2996 ; CHECK-NEXT: [[TMP96:%.*]] = insertelement <4 x i16> [[TMP72]], i16 [[TMP95]], i64 3
2997 ; CHECK-NEXT: store <4 x i16> [[TMP96]], ptr addrspace(1) [[OUT:%.*]], align 8
2998 ; CHECK-NEXT: ret void
3000 ; GFX6-LABEL: sdiv_v4i16:
3002 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
3003 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3004 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3005 ; GFX6-NEXT: s_mov_b32 s2, -1
3006 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3007 ; GFX6-NEXT: s_sext_i32_i16 s8, s6
3008 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s8
3009 ; GFX6-NEXT: s_sext_i32_i16 s9, s4
3010 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s9
3011 ; GFX6-NEXT: s_xor_b32 s8, s9, s8
3012 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
3013 ; GFX6-NEXT: s_ashr_i32 s8, s8, 30
3014 ; GFX6-NEXT: s_or_b32 s10, s8, 1
3015 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
3016 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
3017 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
3018 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
3019 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3020 ; GFX6-NEXT: s_cselect_b32 s8, s10, 0
3021 ; GFX6-NEXT: s_ashr_i32 s6, s6, 16
3022 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s6
3023 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
3024 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s4
3025 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
3026 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
3027 ; GFX6-NEXT: s_xor_b32 s4, s4, s6
3028 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3029 ; GFX6-NEXT: s_sext_i32_i16 s6, s7
3030 ; GFX6-NEXT: v_mul_f32_e32 v3, v1, v3
3031 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
3032 ; GFX6-NEXT: v_mad_f32 v1, -v3, v0, v1
3033 ; GFX6-NEXT: v_cvt_i32_f32_e32 v3, v3
3034 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s8, v2
3035 ; GFX6-NEXT: s_or_b32 s4, s4, 1
3036 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
3037 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s6
3038 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3039 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
3040 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, s4, v3
3041 ; GFX6-NEXT: s_sext_i32_i16 s4, s5
3042 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s4
3043 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v0
3044 ; GFX6-NEXT: s_xor_b32 s4, s4, s6
3045 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3046 ; GFX6-NEXT: s_or_b32 s4, s4, 1
3047 ; GFX6-NEXT: v_mul_f32_e32 v4, v1, v4
3048 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
3049 ; GFX6-NEXT: v_mad_f32 v1, -v4, v0, v1
3050 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
3051 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3052 ; GFX6-NEXT: v_cvt_i32_f32_e32 v4, v4
3053 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
3054 ; GFX6-NEXT: s_ashr_i32 s6, s7, 16
3055 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s6
3056 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s4, v4
3057 ; GFX6-NEXT: s_ashr_i32 s4, s5, 16
3058 ; GFX6-NEXT: v_cvt_f32_i32_e32 v4, s4
3059 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v0
3060 ; GFX6-NEXT: s_xor_b32 s4, s4, s6
3061 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3062 ; GFX6-NEXT: s_or_b32 s6, s4, 1
3063 ; GFX6-NEXT: v_mul_f32_e32 v5, v4, v5
3064 ; GFX6-NEXT: v_trunc_f32_e32 v5, v5
3065 ; GFX6-NEXT: v_mad_f32 v4, -v5, v0, v4
3066 ; GFX6-NEXT: v_cvt_i32_f32_e32 v5, v5
3067 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[4:5], |v4|, |v0|
3068 ; GFX6-NEXT: s_and_b64 s[4:5], s[4:5], exec
3069 ; GFX6-NEXT: s_cselect_b32 s4, s6, 0
3070 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v5
3071 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
3072 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
3073 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v0
3074 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v3
3075 ; GFX6-NEXT: v_and_b32_e32 v2, 0xffff, v2
3076 ; GFX6-NEXT: v_or_b32_e32 v0, v2, v0
3077 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
3078 ; GFX6-NEXT: s_endpgm
3080 ; GFX9-LABEL: sdiv_v4i16:
3082 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
3083 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3084 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
3085 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3086 ; GFX9-NEXT: s_sext_i32_i16 s2, s6
3087 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
3088 ; GFX9-NEXT: s_sext_i32_i16 s3, s4
3089 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s3
3090 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
3091 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
3092 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3093 ; GFX9-NEXT: s_or_b32 s8, s2, 1
3094 ; GFX9-NEXT: v_mul_f32_e32 v3, v1, v3
3095 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
3096 ; GFX9-NEXT: v_mad_f32 v1, -v3, v0, v1
3097 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
3098 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3099 ; GFX9-NEXT: s_cselect_b32 s2, s8, 0
3100 ; GFX9-NEXT: s_ashr_i32 s3, s6, 16
3101 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s3
3102 ; GFX9-NEXT: s_ashr_i32 s4, s4, 16
3103 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s4
3104 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
3105 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
3106 ; GFX9-NEXT: v_add_u32_e32 v3, s2, v3
3107 ; GFX9-NEXT: v_mul_f32_e32 v4, v1, v4
3108 ; GFX9-NEXT: s_xor_b32 s2, s4, s3
3109 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
3110 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3111 ; GFX9-NEXT: v_mad_f32 v1, -v4, v0, v1
3112 ; GFX9-NEXT: s_or_b32 s4, s2, 1
3113 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
3114 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3115 ; GFX9-NEXT: v_cvt_i32_f32_e32 v4, v4
3116 ; GFX9-NEXT: s_sext_i32_i16 s3, s7
3117 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s3
3118 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
3119 ; GFX9-NEXT: v_add_u32_e32 v4, s2, v4
3120 ; GFX9-NEXT: s_sext_i32_i16 s2, s5
3121 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s2
3122 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v0
3123 ; GFX9-NEXT: s_xor_b32 s2, s2, s3
3124 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3125 ; GFX9-NEXT: s_or_b32 s4, s2, 1
3126 ; GFX9-NEXT: v_mul_f32_e32 v5, v1, v5
3127 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
3128 ; GFX9-NEXT: v_mad_f32 v1, -v5, v0, v1
3129 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
3130 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3131 ; GFX9-NEXT: v_cvt_i32_f32_e32 v5, v5
3132 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
3133 ; GFX9-NEXT: s_ashr_i32 s3, s7, 16
3134 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s3
3135 ; GFX9-NEXT: v_add_u32_e32 v1, s2, v5
3136 ; GFX9-NEXT: s_ashr_i32 s2, s5, 16
3137 ; GFX9-NEXT: v_cvt_f32_i32_e32 v5, s2
3138 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v6, v0
3139 ; GFX9-NEXT: s_xor_b32 s2, s2, s3
3140 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3141 ; GFX9-NEXT: s_or_b32 s4, s2, 1
3142 ; GFX9-NEXT: v_mul_f32_e32 v6, v5, v6
3143 ; GFX9-NEXT: v_trunc_f32_e32 v6, v6
3144 ; GFX9-NEXT: v_mad_f32 v5, -v6, v0, v5
3145 ; GFX9-NEXT: v_cvt_i32_f32_e32 v6, v6
3146 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v5|, |v0|
3147 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3148 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
3149 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v6
3150 ; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1
3151 ; GFX9-NEXT: v_lshl_or_b32 v1, v0, 16, v1
3152 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v3
3153 ; GFX9-NEXT: v_lshl_or_b32 v0, v4, 16, v0
3154 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
3155 ; GFX9-NEXT: s_endpgm
3156 %r = sdiv <4 x i16> %x, %y
3157 store <4 x i16> %r, ptr addrspace(1) %out
3161 define amdgpu_kernel void @srem_v4i16(ptr addrspace(1) %out, <4 x i16> %x, <4 x i16> %y) {
3162 ; CHECK-LABEL: @srem_v4i16(
3163 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i16> [[X:%.*]], i64 0
3164 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i16> [[Y:%.*]], i64 0
3165 ; CHECK-NEXT: [[TMP3:%.*]] = sext i16 [[TMP1]] to i32
3166 ; CHECK-NEXT: [[TMP4:%.*]] = sext i16 [[TMP2]] to i32
3167 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
3168 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
3169 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
3170 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
3171 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
3172 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
3173 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
3174 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
3175 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
3176 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
3177 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
3178 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
3179 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
3180 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
3181 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
3182 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
3183 ; CHECK-NEXT: [[TMP21:%.*]] = mul i32 [[TMP20]], [[TMP4]]
3184 ; CHECK-NEXT: [[TMP22:%.*]] = sub i32 [[TMP3]], [[TMP21]]
3185 ; CHECK-NEXT: [[TMP23:%.*]] = shl i32 [[TMP22]], 16
3186 ; CHECK-NEXT: [[TMP24:%.*]] = ashr i32 [[TMP23]], 16
3187 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i32 [[TMP24]] to i16
3188 ; CHECK-NEXT: [[TMP26:%.*]] = insertelement <4 x i16> poison, i16 [[TMP25]], i64 0
3189 ; CHECK-NEXT: [[TMP27:%.*]] = extractelement <4 x i16> [[X]], i64 1
3190 ; CHECK-NEXT: [[TMP28:%.*]] = extractelement <4 x i16> [[Y]], i64 1
3191 ; CHECK-NEXT: [[TMP29:%.*]] = sext i16 [[TMP27]] to i32
3192 ; CHECK-NEXT: [[TMP30:%.*]] = sext i16 [[TMP28]] to i32
3193 ; CHECK-NEXT: [[TMP31:%.*]] = xor i32 [[TMP29]], [[TMP30]]
3194 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i32 [[TMP31]], 30
3195 ; CHECK-NEXT: [[TMP33:%.*]] = or i32 [[TMP32]], 1
3196 ; CHECK-NEXT: [[TMP34:%.*]] = sitofp i32 [[TMP29]] to float
3197 ; CHECK-NEXT: [[TMP35:%.*]] = sitofp i32 [[TMP30]] to float
3198 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP35]])
3199 ; CHECK-NEXT: [[TMP37:%.*]] = fmul fast float [[TMP34]], [[TMP36]]
3200 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.trunc.f32(float [[TMP37]])
3201 ; CHECK-NEXT: [[TMP39:%.*]] = fneg fast float [[TMP38]]
3202 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP39]], float [[TMP35]], float [[TMP34]])
3203 ; CHECK-NEXT: [[TMP41:%.*]] = fptosi float [[TMP38]] to i32
3204 ; CHECK-NEXT: [[TMP42:%.*]] = call fast float @llvm.fabs.f32(float [[TMP40]])
3205 ; CHECK-NEXT: [[TMP43:%.*]] = call fast float @llvm.fabs.f32(float [[TMP35]])
3206 ; CHECK-NEXT: [[TMP44:%.*]] = fcmp fast oge float [[TMP42]], [[TMP43]]
3207 ; CHECK-NEXT: [[TMP45:%.*]] = select i1 [[TMP44]], i32 [[TMP33]], i32 0
3208 ; CHECK-NEXT: [[TMP46:%.*]] = add i32 [[TMP41]], [[TMP45]]
3209 ; CHECK-NEXT: [[TMP47:%.*]] = mul i32 [[TMP46]], [[TMP30]]
3210 ; CHECK-NEXT: [[TMP48:%.*]] = sub i32 [[TMP29]], [[TMP47]]
3211 ; CHECK-NEXT: [[TMP49:%.*]] = shl i32 [[TMP48]], 16
3212 ; CHECK-NEXT: [[TMP50:%.*]] = ashr i32 [[TMP49]], 16
3213 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i32 [[TMP50]] to i16
3214 ; CHECK-NEXT: [[TMP52:%.*]] = insertelement <4 x i16> [[TMP26]], i16 [[TMP51]], i64 1
3215 ; CHECK-NEXT: [[TMP53:%.*]] = extractelement <4 x i16> [[X]], i64 2
3216 ; CHECK-NEXT: [[TMP54:%.*]] = extractelement <4 x i16> [[Y]], i64 2
3217 ; CHECK-NEXT: [[TMP55:%.*]] = sext i16 [[TMP53]] to i32
3218 ; CHECK-NEXT: [[TMP56:%.*]] = sext i16 [[TMP54]] to i32
3219 ; CHECK-NEXT: [[TMP57:%.*]] = xor i32 [[TMP55]], [[TMP56]]
3220 ; CHECK-NEXT: [[TMP58:%.*]] = ashr i32 [[TMP57]], 30
3221 ; CHECK-NEXT: [[TMP59:%.*]] = or i32 [[TMP58]], 1
3222 ; CHECK-NEXT: [[TMP60:%.*]] = sitofp i32 [[TMP55]] to float
3223 ; CHECK-NEXT: [[TMP61:%.*]] = sitofp i32 [[TMP56]] to float
3224 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP61]])
3225 ; CHECK-NEXT: [[TMP63:%.*]] = fmul fast float [[TMP60]], [[TMP62]]
3226 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.trunc.f32(float [[TMP63]])
3227 ; CHECK-NEXT: [[TMP65:%.*]] = fneg fast float [[TMP64]]
3228 ; CHECK-NEXT: [[TMP66:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP65]], float [[TMP61]], float [[TMP60]])
3229 ; CHECK-NEXT: [[TMP67:%.*]] = fptosi float [[TMP64]] to i32
3230 ; CHECK-NEXT: [[TMP68:%.*]] = call fast float @llvm.fabs.f32(float [[TMP66]])
3231 ; CHECK-NEXT: [[TMP69:%.*]] = call fast float @llvm.fabs.f32(float [[TMP61]])
3232 ; CHECK-NEXT: [[TMP70:%.*]] = fcmp fast oge float [[TMP68]], [[TMP69]]
3233 ; CHECK-NEXT: [[TMP71:%.*]] = select i1 [[TMP70]], i32 [[TMP59]], i32 0
3234 ; CHECK-NEXT: [[TMP72:%.*]] = add i32 [[TMP67]], [[TMP71]]
3235 ; CHECK-NEXT: [[TMP73:%.*]] = mul i32 [[TMP72]], [[TMP56]]
3236 ; CHECK-NEXT: [[TMP74:%.*]] = sub i32 [[TMP55]], [[TMP73]]
3237 ; CHECK-NEXT: [[TMP75:%.*]] = shl i32 [[TMP74]], 16
3238 ; CHECK-NEXT: [[TMP76:%.*]] = ashr i32 [[TMP75]], 16
3239 ; CHECK-NEXT: [[TMP77:%.*]] = trunc i32 [[TMP76]] to i16
3240 ; CHECK-NEXT: [[TMP78:%.*]] = insertelement <4 x i16> [[TMP52]], i16 [[TMP77]], i64 2
3241 ; CHECK-NEXT: [[TMP79:%.*]] = extractelement <4 x i16> [[X]], i64 3
3242 ; CHECK-NEXT: [[TMP80:%.*]] = extractelement <4 x i16> [[Y]], i64 3
3243 ; CHECK-NEXT: [[TMP81:%.*]] = sext i16 [[TMP79]] to i32
3244 ; CHECK-NEXT: [[TMP82:%.*]] = sext i16 [[TMP80]] to i32
3245 ; CHECK-NEXT: [[TMP83:%.*]] = xor i32 [[TMP81]], [[TMP82]]
3246 ; CHECK-NEXT: [[TMP84:%.*]] = ashr i32 [[TMP83]], 30
3247 ; CHECK-NEXT: [[TMP85:%.*]] = or i32 [[TMP84]], 1
3248 ; CHECK-NEXT: [[TMP86:%.*]] = sitofp i32 [[TMP81]] to float
3249 ; CHECK-NEXT: [[TMP87:%.*]] = sitofp i32 [[TMP82]] to float
3250 ; CHECK-NEXT: [[TMP88:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP87]])
3251 ; CHECK-NEXT: [[TMP89:%.*]] = fmul fast float [[TMP86]], [[TMP88]]
3252 ; CHECK-NEXT: [[TMP90:%.*]] = call fast float @llvm.trunc.f32(float [[TMP89]])
3253 ; CHECK-NEXT: [[TMP91:%.*]] = fneg fast float [[TMP90]]
3254 ; CHECK-NEXT: [[TMP92:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP91]], float [[TMP87]], float [[TMP86]])
3255 ; CHECK-NEXT: [[TMP93:%.*]] = fptosi float [[TMP90]] to i32
3256 ; CHECK-NEXT: [[TMP94:%.*]] = call fast float @llvm.fabs.f32(float [[TMP92]])
3257 ; CHECK-NEXT: [[TMP95:%.*]] = call fast float @llvm.fabs.f32(float [[TMP87]])
3258 ; CHECK-NEXT: [[TMP96:%.*]] = fcmp fast oge float [[TMP94]], [[TMP95]]
3259 ; CHECK-NEXT: [[TMP97:%.*]] = select i1 [[TMP96]], i32 [[TMP85]], i32 0
3260 ; CHECK-NEXT: [[TMP98:%.*]] = add i32 [[TMP93]], [[TMP97]]
3261 ; CHECK-NEXT: [[TMP99:%.*]] = mul i32 [[TMP98]], [[TMP82]]
3262 ; CHECK-NEXT: [[TMP100:%.*]] = sub i32 [[TMP81]], [[TMP99]]
3263 ; CHECK-NEXT: [[TMP101:%.*]] = shl i32 [[TMP100]], 16
3264 ; CHECK-NEXT: [[TMP102:%.*]] = ashr i32 [[TMP101]], 16
3265 ; CHECK-NEXT: [[TMP103:%.*]] = trunc i32 [[TMP102]] to i16
3266 ; CHECK-NEXT: [[TMP104:%.*]] = insertelement <4 x i16> [[TMP78]], i16 [[TMP103]], i64 3
3267 ; CHECK-NEXT: store <4 x i16> [[TMP104]], ptr addrspace(1) [[OUT:%.*]], align 8
3268 ; CHECK-NEXT: ret void
3270 ; GFX6-LABEL: srem_v4i16:
3272 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
3273 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3274 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3275 ; GFX6-NEXT: s_mov_b32 s2, -1
3276 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3277 ; GFX6-NEXT: s_sext_i32_i16 s8, s6
3278 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s8
3279 ; GFX6-NEXT: s_sext_i32_i16 s9, s4
3280 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s9
3281 ; GFX6-NEXT: s_xor_b32 s8, s9, s8
3282 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
3283 ; GFX6-NEXT: s_ashr_i32 s8, s8, 30
3284 ; GFX6-NEXT: s_or_b32 s10, s8, 1
3285 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
3286 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
3287 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
3288 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
3289 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
3290 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3291 ; GFX6-NEXT: s_cselect_b32 s8, s10, 0
3292 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s8, v2
3293 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s6
3294 ; GFX6-NEXT: s_ashr_i32 s8, s6, 16
3295 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s8
3296 ; GFX6-NEXT: s_lshr_b32 s10, s4, 16
3297 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
3298 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
3299 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s4
3300 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v1
3301 ; GFX6-NEXT: s_xor_b32 s4, s4, s8
3302 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3303 ; GFX6-NEXT: s_lshr_b32 s6, s6, 16
3304 ; GFX6-NEXT: v_mul_f32_e32 v3, v2, v3
3305 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
3306 ; GFX6-NEXT: v_mad_f32 v2, -v3, v1, v2
3307 ; GFX6-NEXT: v_cvt_i32_f32_e32 v3, v3
3308 ; GFX6-NEXT: s_or_b32 s4, s4, 1
3309 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v2|, |v1|
3310 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3311 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
3312 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s4, v3
3313 ; GFX6-NEXT: s_sext_i32_i16 s4, s7
3314 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s6
3315 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s4
3316 ; GFX6-NEXT: s_sext_i32_i16 s6, s5
3317 ; GFX6-NEXT: s_xor_b32 s4, s6, s4
3318 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s10, v1
3319 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s6
3320 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v2
3321 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3322 ; GFX6-NEXT: s_or_b32 s4, s4, 1
3323 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
3324 ; GFX6-NEXT: v_mul_f32_e32 v4, v1, v4
3325 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
3326 ; GFX6-NEXT: v_mad_f32 v1, -v4, v2, v1
3327 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v2|
3328 ; GFX6-NEXT: v_cvt_i32_f32_e32 v4, v4
3329 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
3330 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
3331 ; GFX6-NEXT: s_ashr_i32 s6, s7, 16
3332 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s6
3333 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s4, v4
3334 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s7
3335 ; GFX6-NEXT: s_lshr_b32 s8, s7, 16
3336 ; GFX6-NEXT: s_ashr_i32 s7, s5, 16
3337 ; GFX6-NEXT: v_cvt_f32_i32_e32 v4, s7
3338 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
3339 ; GFX6-NEXT: s_xor_b32 s6, s7, s6
3340 ; GFX6-NEXT: s_ashr_i32 s6, s6, 30
3341 ; GFX6-NEXT: s_lshr_b32 s4, s5, 16
3342 ; GFX6-NEXT: v_mul_f32_e32 v5, v4, v5
3343 ; GFX6-NEXT: v_trunc_f32_e32 v5, v5
3344 ; GFX6-NEXT: v_mad_f32 v4, -v5, v2, v4
3345 ; GFX6-NEXT: v_cvt_i32_f32_e32 v5, v5
3346 ; GFX6-NEXT: s_or_b32 s9, s6, 1
3347 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[6:7], |v4|, |v2|
3348 ; GFX6-NEXT: s_and_b64 s[6:7], s[6:7], exec
3349 ; GFX6-NEXT: s_cselect_b32 s6, s9, 0
3350 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s6, v5
3351 ; GFX6-NEXT: v_mul_lo_u32 v2, v2, s8
3352 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s5, v1
3353 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
3354 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s4, v2
3355 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3356 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
3357 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v3
3358 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v2
3359 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
3360 ; GFX6-NEXT: s_endpgm
3362 ; GFX9-LABEL: srem_v4i16:
3364 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
3365 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3366 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
3367 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3368 ; GFX9-NEXT: s_sext_i32_i16 s8, s6
3369 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s8
3370 ; GFX9-NEXT: s_sext_i32_i16 s9, s4
3371 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s9
3372 ; GFX9-NEXT: s_xor_b32 s2, s9, s8
3373 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
3374 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3375 ; GFX9-NEXT: s_or_b32 s10, s2, 1
3376 ; GFX9-NEXT: v_mul_f32_e32 v3, v1, v3
3377 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
3378 ; GFX9-NEXT: v_mad_f32 v1, -v3, v0, v1
3379 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
3380 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3381 ; GFX9-NEXT: s_cselect_b32 s2, s10, 0
3382 ; GFX9-NEXT: s_ashr_i32 s6, s6, 16
3383 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
3384 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s6
3385 ; GFX9-NEXT: s_ashr_i32 s4, s4, 16
3386 ; GFX9-NEXT: v_add_u32_e32 v1, s2, v3
3387 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s4
3388 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
3389 ; GFX9-NEXT: s_xor_b32 s2, s4, s6
3390 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3391 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, s8
3392 ; GFX9-NEXT: v_mul_f32_e32 v4, v3, v4
3393 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
3394 ; GFX9-NEXT: v_mad_f32 v3, -v4, v0, v3
3395 ; GFX9-NEXT: s_or_b32 s8, s2, 1
3396 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v3|, |v0|
3397 ; GFX9-NEXT: v_cvt_i32_f32_e32 v4, v4
3398 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3399 ; GFX9-NEXT: s_cselect_b32 s2, s8, 0
3400 ; GFX9-NEXT: s_sext_i32_i16 s8, s7
3401 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s8
3402 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v4
3403 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s6
3404 ; GFX9-NEXT: s_sext_i32_i16 s6, s5
3405 ; GFX9-NEXT: v_cvt_f32_i32_e32 v4, s6
3406 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v3
3407 ; GFX9-NEXT: s_xor_b32 s2, s6, s8
3408 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3409 ; GFX9-NEXT: s_or_b32 s10, s2, 1
3410 ; GFX9-NEXT: v_mul_f32_e32 v5, v4, v5
3411 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
3412 ; GFX9-NEXT: v_mad_f32 v4, -v5, v3, v4
3413 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v4|, |v3|
3414 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3415 ; GFX9-NEXT: s_cselect_b32 s2, s10, 0
3416 ; GFX9-NEXT: s_ashr_i32 s7, s7, 16
3417 ; GFX9-NEXT: v_cvt_i32_f32_e32 v5, v5
3418 ; GFX9-NEXT: v_cvt_f32_i32_e32 v4, s7
3419 ; GFX9-NEXT: s_ashr_i32 s5, s5, 16
3420 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
3421 ; GFX9-NEXT: v_add_u32_e32 v3, s2, v5
3422 ; GFX9-NEXT: v_cvt_f32_i32_e32 v5, s5
3423 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v6, v4
3424 ; GFX9-NEXT: s_xor_b32 s2, s5, s7
3425 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3426 ; GFX9-NEXT: v_mul_lo_u32 v3, v3, s8
3427 ; GFX9-NEXT: v_mul_f32_e32 v6, v5, v6
3428 ; GFX9-NEXT: v_trunc_f32_e32 v6, v6
3429 ; GFX9-NEXT: v_mad_f32 v5, -v6, v4, v5
3430 ; GFX9-NEXT: v_cvt_i32_f32_e32 v6, v6
3431 ; GFX9-NEXT: s_or_b32 s8, s2, 1
3432 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v5|, |v4|
3433 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3434 ; GFX9-NEXT: s_cselect_b32 s2, s8, 0
3435 ; GFX9-NEXT: v_add_u32_e32 v4, s2, v6
3436 ; GFX9-NEXT: v_mul_lo_u32 v4, v4, s7
3437 ; GFX9-NEXT: v_sub_u32_e32 v5, s9, v1
3438 ; GFX9-NEXT: v_sub_u32_e32 v1, s6, v3
3439 ; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1
3440 ; GFX9-NEXT: v_sub_u32_e32 v3, s5, v4
3441 ; GFX9-NEXT: v_lshl_or_b32 v1, v3, 16, v1
3442 ; GFX9-NEXT: v_and_b32_e32 v3, 0xffff, v5
3443 ; GFX9-NEXT: v_lshl_or_b32 v0, v0, 16, v3
3444 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
3445 ; GFX9-NEXT: s_endpgm
3446 %r = srem <4 x i16> %x, %y
3447 store <4 x i16> %r, ptr addrspace(1) %out
3451 define amdgpu_kernel void @udiv_i3(ptr addrspace(1) %out, i3 %x, i3 %y) {
3452 ; CHECK-LABEL: @udiv_i3(
3453 ; CHECK-NEXT: [[TMP1:%.*]] = zext i3 [[X:%.*]] to i32
3454 ; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[Y:%.*]] to i32
3455 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
3456 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
3457 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
3458 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
3459 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
3460 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
3461 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
3462 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
3463 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
3464 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
3465 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
3466 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
3467 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
3468 ; CHECK-NEXT: [[TMP16:%.*]] = and i32 [[TMP15]], 7
3469 ; CHECK-NEXT: [[TMP17:%.*]] = trunc i32 [[TMP16]] to i3
3470 ; CHECK-NEXT: store i3 [[TMP17]], ptr addrspace(1) [[OUT:%.*]], align 1
3471 ; CHECK-NEXT: ret void
3473 ; GFX6-LABEL: udiv_i3:
3475 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
3476 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3477 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3478 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3479 ; GFX6-NEXT: s_bfe_u32 s2, s4, 0x30008
3480 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v0, s2
3481 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v1, v0
3482 ; GFX6-NEXT: s_and_b32 s4, s4, 7
3483 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v2, s4
3484 ; GFX6-NEXT: s_mov_b32 s2, -1
3485 ; GFX6-NEXT: v_mul_f32_e32 v1, v2, v1
3486 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
3487 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v1
3488 ; GFX6-NEXT: v_mad_f32 v1, -v1, v0, v2
3489 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
3490 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
3491 ; GFX6-NEXT: v_and_b32_e32 v0, 7, v0
3492 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
3493 ; GFX6-NEXT: s_endpgm
3495 ; GFX9-LABEL: udiv_i3:
3497 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
3498 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3499 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
3500 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3501 ; GFX9-NEXT: s_bfe_u32 s2, s4, 0x30008
3502 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v0, s2
3503 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v0
3504 ; GFX9-NEXT: s_and_b32 s2, s4, 7
3505 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v3, s2
3506 ; GFX9-NEXT: v_mul_f32_e32 v1, v3, v1
3507 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
3508 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v1
3509 ; GFX9-NEXT: v_mad_f32 v1, -v1, v0, v3
3510 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
3511 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v4, vcc
3512 ; GFX9-NEXT: v_and_b32_e32 v0, 7, v0
3513 ; GFX9-NEXT: global_store_byte v2, v0, s[0:1]
3514 ; GFX9-NEXT: s_endpgm
3516 store i3 %r, ptr addrspace(1) %out
3520 define amdgpu_kernel void @urem_i3(ptr addrspace(1) %out, i3 %x, i3 %y) {
3521 ; CHECK-LABEL: @urem_i3(
3522 ; CHECK-NEXT: [[TMP1:%.*]] = zext i3 [[X:%.*]] to i32
3523 ; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[Y:%.*]] to i32
3524 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP1]] to float
3525 ; CHECK-NEXT: [[TMP4:%.*]] = uitofp i32 [[TMP2]] to float
3526 ; CHECK-NEXT: [[TMP5:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP4]])
3527 ; CHECK-NEXT: [[TMP6:%.*]] = fmul fast float [[TMP3]], [[TMP5]]
3528 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.trunc.f32(float [[TMP6]])
3529 ; CHECK-NEXT: [[TMP8:%.*]] = fneg fast float [[TMP7]]
3530 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP8]], float [[TMP4]], float [[TMP3]])
3531 ; CHECK-NEXT: [[TMP10:%.*]] = fptoui float [[TMP7]] to i32
3532 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
3533 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.fabs.f32(float [[TMP4]])
3534 ; CHECK-NEXT: [[TMP13:%.*]] = fcmp fast oge float [[TMP11]], [[TMP12]]
3535 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i32 1, i32 0
3536 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP10]], [[TMP14]]
3537 ; CHECK-NEXT: [[TMP16:%.*]] = mul i32 [[TMP15]], [[TMP2]]
3538 ; CHECK-NEXT: [[TMP17:%.*]] = sub i32 [[TMP1]], [[TMP16]]
3539 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 7
3540 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i3
3541 ; CHECK-NEXT: store i3 [[TMP19]], ptr addrspace(1) [[OUT:%.*]], align 1
3542 ; CHECK-NEXT: ret void
3544 ; GFX6-LABEL: urem_i3:
3546 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
3547 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3548 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3549 ; GFX6-NEXT: s_bfe_u32 s2, s4, 0x30008
3550 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v0, s2
3551 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v1, v0
3552 ; GFX6-NEXT: s_and_b32 s3, s4, 7
3553 ; GFX6-NEXT: v_cvt_f32_ubyte0_e32 v2, s3
3554 ; GFX6-NEXT: s_lshr_b32 s2, s4, 8
3555 ; GFX6-NEXT: v_mul_f32_e32 v1, v2, v1
3556 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
3557 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v1
3558 ; GFX6-NEXT: v_mad_f32 v1, -v1, v0, v2
3559 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
3560 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3561 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
3562 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s2
3563 ; GFX6-NEXT: s_mov_b32 s2, -1
3564 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
3565 ; GFX6-NEXT: v_and_b32_e32 v0, 7, v0
3566 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
3567 ; GFX6-NEXT: s_endpgm
3569 ; GFX9-LABEL: urem_i3:
3571 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
3572 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3573 ; GFX9-NEXT: s_bfe_u32 s0, s4, 0x30008
3574 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v0, s0
3575 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v0
3576 ; GFX9-NEXT: s_and_b32 s1, s4, 7
3577 ; GFX9-NEXT: v_cvt_f32_ubyte0_e32 v2, s1
3578 ; GFX9-NEXT: s_lshr_b32 s0, s4, 8
3579 ; GFX9-NEXT: v_mul_f32_e32 v1, v2, v1
3580 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
3581 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v1
3582 ; GFX9-NEXT: v_mad_f32 v1, -v1, v0, v2
3583 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
3584 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
3585 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v3, vcc
3586 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s0
3587 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3588 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
3589 ; GFX9-NEXT: v_and_b32_e32 v0, 7, v0
3590 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3591 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
3592 ; GFX9-NEXT: s_endpgm
3594 store i3 %r, ptr addrspace(1) %out
3598 define amdgpu_kernel void @sdiv_i3(ptr addrspace(1) %out, i3 %x, i3 %y) {
3599 ; CHECK-LABEL: @sdiv_i3(
3600 ; CHECK-NEXT: [[TMP1:%.*]] = sext i3 [[X:%.*]] to i32
3601 ; CHECK-NEXT: [[TMP2:%.*]] = sext i3 [[Y:%.*]] to i32
3602 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
3603 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
3604 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
3605 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
3606 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
3607 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
3608 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
3609 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
3610 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
3611 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
3612 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
3613 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
3614 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
3615 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
3616 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
3617 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
3618 ; CHECK-NEXT: [[TMP19:%.*]] = shl i32 [[TMP18]], 29
3619 ; CHECK-NEXT: [[TMP20:%.*]] = ashr i32 [[TMP19]], 29
3620 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i3
3621 ; CHECK-NEXT: store i3 [[TMP21]], ptr addrspace(1) [[OUT:%.*]], align 1
3622 ; CHECK-NEXT: ret void
3624 ; GFX6-LABEL: sdiv_i3:
3626 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
3627 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3628 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3629 ; GFX6-NEXT: s_mov_b32 s2, -1
3630 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3631 ; GFX6-NEXT: s_bfe_i32 s5, s4, 0x30008
3632 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s5
3633 ; GFX6-NEXT: s_bfe_i32 s4, s4, 0x30000
3634 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s4
3635 ; GFX6-NEXT: s_xor_b32 s4, s4, s5
3636 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
3637 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
3638 ; GFX6-NEXT: s_or_b32 s6, s4, 1
3639 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
3640 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
3641 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
3642 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
3643 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[4:5], |v1|, |v0|
3644 ; GFX6-NEXT: s_and_b64 s[4:5], s[4:5], exec
3645 ; GFX6-NEXT: s_cselect_b32 s4, s6, 0
3646 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v2
3647 ; GFX6-NEXT: v_and_b32_e32 v0, 7, v0
3648 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
3649 ; GFX6-NEXT: s_endpgm
3651 ; GFX9-LABEL: sdiv_i3:
3653 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
3654 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3655 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
3656 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3657 ; GFX9-NEXT: s_bfe_i32 s2, s4, 0x30008
3658 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
3659 ; GFX9-NEXT: s_bfe_i32 s3, s4, 0x30000
3660 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s3
3661 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
3662 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
3663 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
3664 ; GFX9-NEXT: s_or_b32 s4, s2, 1
3665 ; GFX9-NEXT: v_mul_f32_e32 v3, v2, v3
3666 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
3667 ; GFX9-NEXT: v_mad_f32 v2, -v3, v0, v2
3668 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
3669 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v2|, |v0|
3670 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
3671 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
3672 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v3
3673 ; GFX9-NEXT: v_and_b32_e32 v0, 7, v0
3674 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
3675 ; GFX9-NEXT: s_endpgm
3677 store i3 %r, ptr addrspace(1) %out
3681 define amdgpu_kernel void @srem_i3(ptr addrspace(1) %out, i3 %x, i3 %y) {
3682 ; CHECK-LABEL: @srem_i3(
3683 ; CHECK-NEXT: [[TMP1:%.*]] = sext i3 [[X:%.*]] to i32
3684 ; CHECK-NEXT: [[TMP2:%.*]] = sext i3 [[Y:%.*]] to i32
3685 ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP1]], [[TMP2]]
3686 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP3]], 30
3687 ; CHECK-NEXT: [[TMP5:%.*]] = or i32 [[TMP4]], 1
3688 ; CHECK-NEXT: [[TMP6:%.*]] = sitofp i32 [[TMP1]] to float
3689 ; CHECK-NEXT: [[TMP7:%.*]] = sitofp i32 [[TMP2]] to float
3690 ; CHECK-NEXT: [[TMP8:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP7]])
3691 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], [[TMP8]]
3692 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.trunc.f32(float [[TMP9]])
3693 ; CHECK-NEXT: [[TMP11:%.*]] = fneg fast float [[TMP10]]
3694 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP11]], float [[TMP7]], float [[TMP6]])
3695 ; CHECK-NEXT: [[TMP13:%.*]] = fptosi float [[TMP10]] to i32
3696 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP12]])
3697 ; CHECK-NEXT: [[TMP15:%.*]] = call fast float @llvm.fabs.f32(float [[TMP7]])
3698 ; CHECK-NEXT: [[TMP16:%.*]] = fcmp fast oge float [[TMP14]], [[TMP15]]
3699 ; CHECK-NEXT: [[TMP17:%.*]] = select i1 [[TMP16]], i32 [[TMP5]], i32 0
3700 ; CHECK-NEXT: [[TMP18:%.*]] = add i32 [[TMP13]], [[TMP17]]
3701 ; CHECK-NEXT: [[TMP19:%.*]] = mul i32 [[TMP18]], [[TMP2]]
3702 ; CHECK-NEXT: [[TMP20:%.*]] = sub i32 [[TMP1]], [[TMP19]]
3703 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 29
3704 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 29
3705 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i3
3706 ; CHECK-NEXT: store i3 [[TMP23]], ptr addrspace(1) [[OUT:%.*]], align 1
3707 ; CHECK-NEXT: ret void
3709 ; GFX6-LABEL: srem_i3:
3711 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
3712 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3713 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3714 ; GFX6-NEXT: s_bfe_i32 s2, s4, 0x30008
3715 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s2
3716 ; GFX6-NEXT: s_bfe_i32 s3, s4, 0x30000
3717 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s3
3718 ; GFX6-NEXT: s_xor_b32 s2, s3, s2
3719 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
3720 ; GFX6-NEXT: s_ashr_i32 s2, s2, 30
3721 ; GFX6-NEXT: s_lshr_b32 s5, s4, 8
3722 ; GFX6-NEXT: s_or_b32 s6, s2, 1
3723 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
3724 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
3725 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
3726 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
3727 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
3728 ; GFX6-NEXT: s_and_b64 s[2:3], s[2:3], exec
3729 ; GFX6-NEXT: s_cselect_b32 s2, s6, 0
3730 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s2, v2
3731 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s5
3732 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3733 ; GFX6-NEXT: s_mov_b32 s2, -1
3734 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
3735 ; GFX6-NEXT: v_and_b32_e32 v0, 7, v0
3736 ; GFX6-NEXT: buffer_store_byte v0, off, s[0:3], 0
3737 ; GFX6-NEXT: s_endpgm
3739 ; GFX9-LABEL: srem_i3:
3741 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
3742 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3743 ; GFX9-NEXT: s_bfe_i32 s0, s4, 0x30008
3744 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s0
3745 ; GFX9-NEXT: s_bfe_i32 s1, s4, 0x30000
3746 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s1
3747 ; GFX9-NEXT: s_xor_b32 s0, s1, s0
3748 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
3749 ; GFX9-NEXT: s_ashr_i32 s0, s0, 30
3750 ; GFX9-NEXT: s_lshr_b32 s5, s4, 8
3751 ; GFX9-NEXT: s_or_b32 s6, s0, 1
3752 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
3753 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
3754 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
3755 ; GFX9-NEXT: v_cvt_i32_f32_e32 v2, v2
3756 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[0:1], |v1|, |v0|
3757 ; GFX9-NEXT: s_and_b64 s[0:1], s[0:1], exec
3758 ; GFX9-NEXT: s_cselect_b32 s0, s6, 0
3759 ; GFX9-NEXT: v_add_u32_e32 v0, s0, v2
3760 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s5
3761 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3762 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
3763 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
3764 ; GFX9-NEXT: v_and_b32_e32 v0, 7, v0
3765 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3766 ; GFX9-NEXT: global_store_byte v1, v0, s[0:1]
3767 ; GFX9-NEXT: s_endpgm
3769 store i3 %r, ptr addrspace(1) %out
3773 define amdgpu_kernel void @udiv_v3i16(ptr addrspace(1) %out, <3 x i16> %x, <3 x i16> %y) {
3774 ; CHECK-LABEL: @udiv_v3i16(
3775 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i16> [[X:%.*]], i64 0
3776 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i16> [[Y:%.*]], i64 0
3777 ; CHECK-NEXT: [[TMP3:%.*]] = zext i16 [[TMP1]] to i32
3778 ; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP2]] to i32
3779 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
3780 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
3781 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
3782 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
3783 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
3784 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
3785 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
3786 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
3787 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
3788 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
3789 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
3790 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
3791 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
3792 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 65535
3793 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i16
3794 ; CHECK-NEXT: [[TMP20:%.*]] = insertelement <3 x i16> poison, i16 [[TMP19]], i64 0
3795 ; CHECK-NEXT: [[TMP21:%.*]] = extractelement <3 x i16> [[X]], i64 1
3796 ; CHECK-NEXT: [[TMP22:%.*]] = extractelement <3 x i16> [[Y]], i64 1
3797 ; CHECK-NEXT: [[TMP23:%.*]] = zext i16 [[TMP21]] to i32
3798 ; CHECK-NEXT: [[TMP24:%.*]] = zext i16 [[TMP22]] to i32
3799 ; CHECK-NEXT: [[TMP25:%.*]] = uitofp i32 [[TMP23]] to float
3800 ; CHECK-NEXT: [[TMP26:%.*]] = uitofp i32 [[TMP24]] to float
3801 ; CHECK-NEXT: [[TMP27:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP26]])
3802 ; CHECK-NEXT: [[TMP28:%.*]] = fmul fast float [[TMP25]], [[TMP27]]
3803 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.trunc.f32(float [[TMP28]])
3804 ; CHECK-NEXT: [[TMP30:%.*]] = fneg fast float [[TMP29]]
3805 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP30]], float [[TMP26]], float [[TMP25]])
3806 ; CHECK-NEXT: [[TMP32:%.*]] = fptoui float [[TMP29]] to i32
3807 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.fabs.f32(float [[TMP31]])
3808 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.fabs.f32(float [[TMP26]])
3809 ; CHECK-NEXT: [[TMP35:%.*]] = fcmp fast oge float [[TMP33]], [[TMP34]]
3810 ; CHECK-NEXT: [[TMP36:%.*]] = select i1 [[TMP35]], i32 1, i32 0
3811 ; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP32]], [[TMP36]]
3812 ; CHECK-NEXT: [[TMP38:%.*]] = and i32 [[TMP37]], 65535
3813 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i32 [[TMP38]] to i16
3814 ; CHECK-NEXT: [[TMP40:%.*]] = insertelement <3 x i16> [[TMP20]], i16 [[TMP39]], i64 1
3815 ; CHECK-NEXT: [[TMP41:%.*]] = extractelement <3 x i16> [[X]], i64 2
3816 ; CHECK-NEXT: [[TMP42:%.*]] = extractelement <3 x i16> [[Y]], i64 2
3817 ; CHECK-NEXT: [[TMP43:%.*]] = zext i16 [[TMP41]] to i32
3818 ; CHECK-NEXT: [[TMP44:%.*]] = zext i16 [[TMP42]] to i32
3819 ; CHECK-NEXT: [[TMP45:%.*]] = uitofp i32 [[TMP43]] to float
3820 ; CHECK-NEXT: [[TMP46:%.*]] = uitofp i32 [[TMP44]] to float
3821 ; CHECK-NEXT: [[TMP47:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP46]])
3822 ; CHECK-NEXT: [[TMP48:%.*]] = fmul fast float [[TMP45]], [[TMP47]]
3823 ; CHECK-NEXT: [[TMP49:%.*]] = call fast float @llvm.trunc.f32(float [[TMP48]])
3824 ; CHECK-NEXT: [[TMP50:%.*]] = fneg fast float [[TMP49]]
3825 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP50]], float [[TMP46]], float [[TMP45]])
3826 ; CHECK-NEXT: [[TMP52:%.*]] = fptoui float [[TMP49]] to i32
3827 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.fabs.f32(float [[TMP51]])
3828 ; CHECK-NEXT: [[TMP54:%.*]] = call fast float @llvm.fabs.f32(float [[TMP46]])
3829 ; CHECK-NEXT: [[TMP55:%.*]] = fcmp fast oge float [[TMP53]], [[TMP54]]
3830 ; CHECK-NEXT: [[TMP56:%.*]] = select i1 [[TMP55]], i32 1, i32 0
3831 ; CHECK-NEXT: [[TMP57:%.*]] = add i32 [[TMP52]], [[TMP56]]
3832 ; CHECK-NEXT: [[TMP58:%.*]] = and i32 [[TMP57]], 65535
3833 ; CHECK-NEXT: [[TMP59:%.*]] = trunc i32 [[TMP58]] to i16
3834 ; CHECK-NEXT: [[TMP60:%.*]] = insertelement <3 x i16> [[TMP40]], i16 [[TMP59]], i64 2
3835 ; CHECK-NEXT: store <3 x i16> [[TMP60]], ptr addrspace(1) [[OUT:%.*]], align 8
3836 ; CHECK-NEXT: ret void
3838 ; GFX6-LABEL: udiv_v3i16:
3840 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
3841 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
3842 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
3843 ; GFX6-NEXT: s_mov_b32 s2, -1
3844 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3845 ; GFX6-NEXT: s_and_b32 s9, s6, 0xffff
3846 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s9
3847 ; GFX6-NEXT: s_lshr_b32 s6, s6, 16
3848 ; GFX6-NEXT: s_and_b32 s8, s4, 0xffff
3849 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
3850 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s8
3851 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
3852 ; GFX6-NEXT: s_lshr_b32 s4, s4, 16
3853 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
3854 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
3855 ; GFX6-NEXT: v_mul_f32_e32 v3, v1, v3
3856 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
3857 ; GFX6-NEXT: v_mad_f32 v1, -v3, v0, v1
3858 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
3859 ; GFX6-NEXT: v_mul_f32_e32 v1, v4, v5
3860 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
3861 ; GFX6-NEXT: s_and_b32 s4, s7, 0xffff
3862 ; GFX6-NEXT: v_cvt_u32_f32_e32 v6, v3
3863 ; GFX6-NEXT: v_mad_f32 v3, -v1, v2, v4
3864 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
3865 ; GFX6-NEXT: s_and_b32 s4, s5, 0xffff
3866 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v6, vcc
3867 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s4
3868 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v4
3869 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
3870 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v2
3871 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
3872 ; GFX6-NEXT: v_mul_f32_e32 v2, v5, v6
3873 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
3874 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v2
3875 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
3876 ; GFX6-NEXT: v_mad_f32 v2, -v2, v4, v5
3877 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v4
3878 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
3879 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3880 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
3881 ; GFX6-NEXT: buffer_store_short v2, off, s[0:3], 0 offset:4
3882 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3883 ; GFX6-NEXT: s_endpgm
3885 ; GFX9-LABEL: udiv_v3i16:
3887 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
3888 ; GFX9-NEXT: v_mov_b32_e32 v6, 0
3889 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3890 ; GFX9-NEXT: s_and_b32 s1, s6, 0xffff
3891 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
3892 ; GFX9-NEXT: s_and_b32 s0, s4, 0xffff
3893 ; GFX9-NEXT: s_lshr_b32 s6, s6, 16
3894 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s6
3895 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s0
3896 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
3897 ; GFX9-NEXT: s_lshr_b32 s4, s4, 16
3898 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s4
3899 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
3900 ; GFX9-NEXT: v_mul_f32_e32 v4, v2, v4
3901 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
3902 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
3903 ; GFX9-NEXT: s_and_b32 s2, s7, 0xffff
3904 ; GFX9-NEXT: v_cvt_u32_f32_e32 v7, v4
3905 ; GFX9-NEXT: v_mad_f32 v2, -v4, v0, v2
3906 ; GFX9-NEXT: v_cvt_f32_u32_e32 v4, s2
3907 ; GFX9-NEXT: v_mul_f32_e32 v5, v3, v5
3908 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v0
3909 ; GFX9-NEXT: v_trunc_f32_e32 v2, v5
3910 ; GFX9-NEXT: s_and_b32 s2, s5, 0xffff
3911 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v7, vcc
3912 ; GFX9-NEXT: v_mad_f32 v3, -v2, v1, v3
3913 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
3914 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s2
3915 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v4
3916 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v1
3917 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v2, vcc
3918 ; GFX9-NEXT: v_mul_f32_e32 v2, v5, v7
3919 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
3920 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v2
3921 ; GFX9-NEXT: v_mad_f32 v2, -v2, v4, v5
3922 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v4
3923 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0
3924 ; GFX9-NEXT: v_addc_co_u32_e32 v2, vcc, 0, v3, vcc
3925 ; GFX9-NEXT: v_lshl_or_b32 v0, v1, 16, v0
3926 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
3927 ; GFX9-NEXT: global_store_short v6, v2, s[0:1] offset:4
3928 ; GFX9-NEXT: global_store_dword v6, v0, s[0:1]
3929 ; GFX9-NEXT: s_endpgm
3930 %r = udiv <3 x i16> %x, %y
3931 store <3 x i16> %r, ptr addrspace(1) %out
3935 define amdgpu_kernel void @urem_v3i16(ptr addrspace(1) %out, <3 x i16> %x, <3 x i16> %y) {
3936 ; CHECK-LABEL: @urem_v3i16(
3937 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i16> [[X:%.*]], i64 0
3938 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i16> [[Y:%.*]], i64 0
3939 ; CHECK-NEXT: [[TMP3:%.*]] = zext i16 [[TMP1]] to i32
3940 ; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP2]] to i32
3941 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
3942 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
3943 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
3944 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
3945 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
3946 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
3947 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
3948 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
3949 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
3950 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
3951 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
3952 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
3953 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
3954 ; CHECK-NEXT: [[TMP18:%.*]] = mul i32 [[TMP17]], [[TMP4]]
3955 ; CHECK-NEXT: [[TMP19:%.*]] = sub i32 [[TMP3]], [[TMP18]]
3956 ; CHECK-NEXT: [[TMP20:%.*]] = and i32 [[TMP19]], 65535
3957 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i16
3958 ; CHECK-NEXT: [[TMP22:%.*]] = insertelement <3 x i16> poison, i16 [[TMP21]], i64 0
3959 ; CHECK-NEXT: [[TMP23:%.*]] = extractelement <3 x i16> [[X]], i64 1
3960 ; CHECK-NEXT: [[TMP24:%.*]] = extractelement <3 x i16> [[Y]], i64 1
3961 ; CHECK-NEXT: [[TMP25:%.*]] = zext i16 [[TMP23]] to i32
3962 ; CHECK-NEXT: [[TMP26:%.*]] = zext i16 [[TMP24]] to i32
3963 ; CHECK-NEXT: [[TMP27:%.*]] = uitofp i32 [[TMP25]] to float
3964 ; CHECK-NEXT: [[TMP28:%.*]] = uitofp i32 [[TMP26]] to float
3965 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP28]])
3966 ; CHECK-NEXT: [[TMP30:%.*]] = fmul fast float [[TMP27]], [[TMP29]]
3967 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.trunc.f32(float [[TMP30]])
3968 ; CHECK-NEXT: [[TMP32:%.*]] = fneg fast float [[TMP31]]
3969 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP32]], float [[TMP28]], float [[TMP27]])
3970 ; CHECK-NEXT: [[TMP34:%.*]] = fptoui float [[TMP31]] to i32
3971 ; CHECK-NEXT: [[TMP35:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
3972 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.fabs.f32(float [[TMP28]])
3973 ; CHECK-NEXT: [[TMP37:%.*]] = fcmp fast oge float [[TMP35]], [[TMP36]]
3974 ; CHECK-NEXT: [[TMP38:%.*]] = select i1 [[TMP37]], i32 1, i32 0
3975 ; CHECK-NEXT: [[TMP39:%.*]] = add i32 [[TMP34]], [[TMP38]]
3976 ; CHECK-NEXT: [[TMP40:%.*]] = mul i32 [[TMP39]], [[TMP26]]
3977 ; CHECK-NEXT: [[TMP41:%.*]] = sub i32 [[TMP25]], [[TMP40]]
3978 ; CHECK-NEXT: [[TMP42:%.*]] = and i32 [[TMP41]], 65535
3979 ; CHECK-NEXT: [[TMP43:%.*]] = trunc i32 [[TMP42]] to i16
3980 ; CHECK-NEXT: [[TMP44:%.*]] = insertelement <3 x i16> [[TMP22]], i16 [[TMP43]], i64 1
3981 ; CHECK-NEXT: [[TMP45:%.*]] = extractelement <3 x i16> [[X]], i64 2
3982 ; CHECK-NEXT: [[TMP46:%.*]] = extractelement <3 x i16> [[Y]], i64 2
3983 ; CHECK-NEXT: [[TMP47:%.*]] = zext i16 [[TMP45]] to i32
3984 ; CHECK-NEXT: [[TMP48:%.*]] = zext i16 [[TMP46]] to i32
3985 ; CHECK-NEXT: [[TMP49:%.*]] = uitofp i32 [[TMP47]] to float
3986 ; CHECK-NEXT: [[TMP50:%.*]] = uitofp i32 [[TMP48]] to float
3987 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP50]])
3988 ; CHECK-NEXT: [[TMP52:%.*]] = fmul fast float [[TMP49]], [[TMP51]]
3989 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.trunc.f32(float [[TMP52]])
3990 ; CHECK-NEXT: [[TMP54:%.*]] = fneg fast float [[TMP53]]
3991 ; CHECK-NEXT: [[TMP55:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP54]], float [[TMP50]], float [[TMP49]])
3992 ; CHECK-NEXT: [[TMP56:%.*]] = fptoui float [[TMP53]] to i32
3993 ; CHECK-NEXT: [[TMP57:%.*]] = call fast float @llvm.fabs.f32(float [[TMP55]])
3994 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.fabs.f32(float [[TMP50]])
3995 ; CHECK-NEXT: [[TMP59:%.*]] = fcmp fast oge float [[TMP57]], [[TMP58]]
3996 ; CHECK-NEXT: [[TMP60:%.*]] = select i1 [[TMP59]], i32 1, i32 0
3997 ; CHECK-NEXT: [[TMP61:%.*]] = add i32 [[TMP56]], [[TMP60]]
3998 ; CHECK-NEXT: [[TMP62:%.*]] = mul i32 [[TMP61]], [[TMP48]]
3999 ; CHECK-NEXT: [[TMP63:%.*]] = sub i32 [[TMP47]], [[TMP62]]
4000 ; CHECK-NEXT: [[TMP64:%.*]] = and i32 [[TMP63]], 65535
4001 ; CHECK-NEXT: [[TMP65:%.*]] = trunc i32 [[TMP64]] to i16
4002 ; CHECK-NEXT: [[TMP66:%.*]] = insertelement <3 x i16> [[TMP44]], i16 [[TMP65]], i64 2
4003 ; CHECK-NEXT: store <3 x i16> [[TMP66]], ptr addrspace(1) [[OUT:%.*]], align 8
4004 ; CHECK-NEXT: ret void
4006 ; GFX6-LABEL: urem_v3i16:
4008 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
4009 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
4010 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
4011 ; GFX6-NEXT: s_mov_b32 s2, -1
4012 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4013 ; GFX6-NEXT: s_and_b32 s9, s6, 0xffff
4014 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s9
4015 ; GFX6-NEXT: s_and_b32 s8, s4, 0xffff
4016 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s8
4017 ; GFX6-NEXT: s_lshr_b32 s9, s6, 16
4018 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
4019 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s9
4020 ; GFX6-NEXT: s_lshr_b32 s8, s4, 16
4021 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s8
4022 ; GFX6-NEXT: v_mul_f32_e32 v3, v1, v3
4023 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
4024 ; GFX6-NEXT: v_cvt_u32_f32_e32 v6, v3
4025 ; GFX6-NEXT: v_mad_f32 v1, -v3, v0, v1
4026 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
4027 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
4028 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v6, vcc
4029 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s6
4030 ; GFX6-NEXT: v_mul_f32_e32 v1, v4, v5
4031 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
4032 ; GFX6-NEXT: v_mad_f32 v3, -v1, v2, v4
4033 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
4034 ; GFX6-NEXT: s_and_b32 s4, s7, 0xffff
4035 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
4036 ; GFX6-NEXT: s_and_b32 s4, s5, 0xffff
4037 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s4
4038 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
4039 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v4
4040 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v2
4041 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
4042 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
4043 ; GFX6-NEXT: v_mul_f32_e32 v2, v5, v6
4044 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
4045 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v2
4046 ; GFX6-NEXT: v_mad_f32 v2, -v2, v4, v5
4047 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v4
4048 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s9
4049 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
4050 ; GFX6-NEXT: v_mul_lo_u32 v2, v2, s7
4051 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s8, v1
4052 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
4053 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s5, v2
4054 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
4055 ; GFX6-NEXT: buffer_store_short v2, off, s[0:3], 0 offset:4
4056 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4057 ; GFX6-NEXT: s_endpgm
4059 ; GFX9-LABEL: urem_v3i16:
4061 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
4062 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
4063 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
4064 ; GFX9-NEXT: s_and_b32 s9, s6, 0xffff
4065 ; GFX9-NEXT: s_lshr_b32 s6, s6, 16
4066 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s9
4067 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s6
4068 ; GFX9-NEXT: s_and_b32 s8, s4, 0xffff
4069 ; GFX9-NEXT: s_lshr_b32 s4, s4, 16
4070 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s8
4071 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
4072 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s4
4073 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
4074 ; GFX9-NEXT: s_and_b32 s2, s7, 0xffff
4075 ; GFX9-NEXT: v_mul_f32_e32 v4, v2, v4
4076 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
4077 ; GFX9-NEXT: v_mul_f32_e32 v5, v3, v5
4078 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
4079 ; GFX9-NEXT: v_mad_f32 v2, -v4, v0, v2
4080 ; GFX9-NEXT: v_cvt_u32_f32_e32 v6, v4
4081 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v0
4082 ; GFX9-NEXT: v_mad_f32 v2, -v5, v1, v3
4083 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s2
4084 ; GFX9-NEXT: s_and_b32 s3, s5, 0xffff
4085 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v6, vcc
4086 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v5
4087 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, s3
4088 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v6, v3
4089 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v1
4090 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v4, vcc
4091 ; GFX9-NEXT: v_mul_f32_e32 v2, v5, v6
4092 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
4093 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v2
4094 ; GFX9-NEXT: v_mad_f32 v2, -v2, v3, v5
4095 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v3
4096 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s9
4097 ; GFX9-NEXT: v_addc_co_u32_e32 v2, vcc, 0, v4, vcc
4098 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, s6
4099 ; GFX9-NEXT: v_mul_lo_u32 v2, v2, s2
4100 ; GFX9-NEXT: v_sub_u32_e32 v0, s8, v0
4101 ; GFX9-NEXT: v_mov_b32_e32 v3, 0
4102 ; GFX9-NEXT: v_sub_u32_e32 v1, s4, v1
4103 ; GFX9-NEXT: v_sub_u32_e32 v2, s3, v2
4104 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0
4105 ; GFX9-NEXT: v_lshl_or_b32 v0, v1, 16, v0
4106 ; GFX9-NEXT: global_store_short v3, v2, s[0:1] offset:4
4107 ; GFX9-NEXT: global_store_dword v3, v0, s[0:1]
4108 ; GFX9-NEXT: s_endpgm
4109 %r = urem <3 x i16> %x, %y
4110 store <3 x i16> %r, ptr addrspace(1) %out
4114 define amdgpu_kernel void @sdiv_v3i16(ptr addrspace(1) %out, <3 x i16> %x, <3 x i16> %y) {
4115 ; CHECK-LABEL: @sdiv_v3i16(
4116 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i16> [[X:%.*]], i64 0
4117 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i16> [[Y:%.*]], i64 0
4118 ; CHECK-NEXT: [[TMP3:%.*]] = sext i16 [[TMP1]] to i32
4119 ; CHECK-NEXT: [[TMP4:%.*]] = sext i16 [[TMP2]] to i32
4120 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
4121 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
4122 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
4123 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
4124 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
4125 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
4126 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
4127 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
4128 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
4129 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
4130 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
4131 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
4132 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
4133 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
4134 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
4135 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
4136 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 16
4137 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 16
4138 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i16
4139 ; CHECK-NEXT: [[TMP24:%.*]] = insertelement <3 x i16> poison, i16 [[TMP23]], i64 0
4140 ; CHECK-NEXT: [[TMP25:%.*]] = extractelement <3 x i16> [[X]], i64 1
4141 ; CHECK-NEXT: [[TMP26:%.*]] = extractelement <3 x i16> [[Y]], i64 1
4142 ; CHECK-NEXT: [[TMP27:%.*]] = sext i16 [[TMP25]] to i32
4143 ; CHECK-NEXT: [[TMP28:%.*]] = sext i16 [[TMP26]] to i32
4144 ; CHECK-NEXT: [[TMP29:%.*]] = xor i32 [[TMP27]], [[TMP28]]
4145 ; CHECK-NEXT: [[TMP30:%.*]] = ashr i32 [[TMP29]], 30
4146 ; CHECK-NEXT: [[TMP31:%.*]] = or i32 [[TMP30]], 1
4147 ; CHECK-NEXT: [[TMP32:%.*]] = sitofp i32 [[TMP27]] to float
4148 ; CHECK-NEXT: [[TMP33:%.*]] = sitofp i32 [[TMP28]] to float
4149 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP33]])
4150 ; CHECK-NEXT: [[TMP35:%.*]] = fmul fast float [[TMP32]], [[TMP34]]
4151 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.trunc.f32(float [[TMP35]])
4152 ; CHECK-NEXT: [[TMP37:%.*]] = fneg fast float [[TMP36]]
4153 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP37]], float [[TMP33]], float [[TMP32]])
4154 ; CHECK-NEXT: [[TMP39:%.*]] = fptosi float [[TMP36]] to i32
4155 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.fabs.f32(float [[TMP38]])
4156 ; CHECK-NEXT: [[TMP41:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
4157 ; CHECK-NEXT: [[TMP42:%.*]] = fcmp fast oge float [[TMP40]], [[TMP41]]
4158 ; CHECK-NEXT: [[TMP43:%.*]] = select i1 [[TMP42]], i32 [[TMP31]], i32 0
4159 ; CHECK-NEXT: [[TMP44:%.*]] = add i32 [[TMP39]], [[TMP43]]
4160 ; CHECK-NEXT: [[TMP45:%.*]] = shl i32 [[TMP44]], 16
4161 ; CHECK-NEXT: [[TMP46:%.*]] = ashr i32 [[TMP45]], 16
4162 ; CHECK-NEXT: [[TMP47:%.*]] = trunc i32 [[TMP46]] to i16
4163 ; CHECK-NEXT: [[TMP48:%.*]] = insertelement <3 x i16> [[TMP24]], i16 [[TMP47]], i64 1
4164 ; CHECK-NEXT: [[TMP49:%.*]] = extractelement <3 x i16> [[X]], i64 2
4165 ; CHECK-NEXT: [[TMP50:%.*]] = extractelement <3 x i16> [[Y]], i64 2
4166 ; CHECK-NEXT: [[TMP51:%.*]] = sext i16 [[TMP49]] to i32
4167 ; CHECK-NEXT: [[TMP52:%.*]] = sext i16 [[TMP50]] to i32
4168 ; CHECK-NEXT: [[TMP53:%.*]] = xor i32 [[TMP51]], [[TMP52]]
4169 ; CHECK-NEXT: [[TMP54:%.*]] = ashr i32 [[TMP53]], 30
4170 ; CHECK-NEXT: [[TMP55:%.*]] = or i32 [[TMP54]], 1
4171 ; CHECK-NEXT: [[TMP56:%.*]] = sitofp i32 [[TMP51]] to float
4172 ; CHECK-NEXT: [[TMP57:%.*]] = sitofp i32 [[TMP52]] to float
4173 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP57]])
4174 ; CHECK-NEXT: [[TMP59:%.*]] = fmul fast float [[TMP56]], [[TMP58]]
4175 ; CHECK-NEXT: [[TMP60:%.*]] = call fast float @llvm.trunc.f32(float [[TMP59]])
4176 ; CHECK-NEXT: [[TMP61:%.*]] = fneg fast float [[TMP60]]
4177 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP61]], float [[TMP57]], float [[TMP56]])
4178 ; CHECK-NEXT: [[TMP63:%.*]] = fptosi float [[TMP60]] to i32
4179 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.fabs.f32(float [[TMP62]])
4180 ; CHECK-NEXT: [[TMP65:%.*]] = call fast float @llvm.fabs.f32(float [[TMP57]])
4181 ; CHECK-NEXT: [[TMP66:%.*]] = fcmp fast oge float [[TMP64]], [[TMP65]]
4182 ; CHECK-NEXT: [[TMP67:%.*]] = select i1 [[TMP66]], i32 [[TMP55]], i32 0
4183 ; CHECK-NEXT: [[TMP68:%.*]] = add i32 [[TMP63]], [[TMP67]]
4184 ; CHECK-NEXT: [[TMP69:%.*]] = shl i32 [[TMP68]], 16
4185 ; CHECK-NEXT: [[TMP70:%.*]] = ashr i32 [[TMP69]], 16
4186 ; CHECK-NEXT: [[TMP71:%.*]] = trunc i32 [[TMP70]] to i16
4187 ; CHECK-NEXT: [[TMP72:%.*]] = insertelement <3 x i16> [[TMP48]], i16 [[TMP71]], i64 2
4188 ; CHECK-NEXT: store <3 x i16> [[TMP72]], ptr addrspace(1) [[OUT:%.*]], align 8
4189 ; CHECK-NEXT: ret void
4191 ; GFX6-LABEL: sdiv_v3i16:
4193 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
4194 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
4195 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
4196 ; GFX6-NEXT: s_mov_b32 s2, -1
4197 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4198 ; GFX6-NEXT: s_sext_i32_i16 s8, s6
4199 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s8
4200 ; GFX6-NEXT: s_sext_i32_i16 s9, s4
4201 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s9
4202 ; GFX6-NEXT: s_xor_b32 s8, s9, s8
4203 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
4204 ; GFX6-NEXT: s_ashr_i32 s8, s8, 30
4205 ; GFX6-NEXT: s_or_b32 s10, s8, 1
4206 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
4207 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
4208 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
4209 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
4210 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
4211 ; GFX6-NEXT: s_cselect_b32 s8, s10, 0
4212 ; GFX6-NEXT: s_ashr_i32 s6, s6, 16
4213 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
4214 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s6
4215 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
4216 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s8, v2
4217 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s4
4218 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v0
4219 ; GFX6-NEXT: s_xor_b32 s4, s4, s6
4220 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
4221 ; GFX6-NEXT: s_sext_i32_i16 s6, s7
4222 ; GFX6-NEXT: v_mul_f32_e32 v3, v2, v3
4223 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
4224 ; GFX6-NEXT: v_mad_f32 v2, -v3, v0, v2
4225 ; GFX6-NEXT: v_cvt_i32_f32_e32 v3, v3
4226 ; GFX6-NEXT: s_or_b32 s4, s4, 1
4227 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v2|, |v0|
4228 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s6
4229 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
4230 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
4231 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s4, v3
4232 ; GFX6-NEXT: s_sext_i32_i16 s4, s5
4233 ; GFX6-NEXT: v_cvt_f32_i32_e32 v3, s4
4234 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v0
4235 ; GFX6-NEXT: s_xor_b32 s4, s4, s6
4236 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
4237 ; GFX6-NEXT: s_or_b32 s6, s4, 1
4238 ; GFX6-NEXT: v_mul_f32_e32 v4, v3, v4
4239 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
4240 ; GFX6-NEXT: v_mad_f32 v3, -v4, v0, v3
4241 ; GFX6-NEXT: v_cvt_i32_f32_e32 v4, v4
4242 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[4:5], |v3|, |v0|
4243 ; GFX6-NEXT: s_and_b64 s[4:5], s[4:5], exec
4244 ; GFX6-NEXT: s_cselect_b32 s4, s6, 0
4245 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v4
4246 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
4247 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
4248 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
4249 ; GFX6-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:4
4250 ; GFX6-NEXT: buffer_store_dword v1, off, s[0:3], 0
4251 ; GFX6-NEXT: s_endpgm
4253 ; GFX9-LABEL: sdiv_v3i16:
4255 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
4256 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
4257 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
4258 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
4259 ; GFX9-NEXT: s_sext_i32_i16 s2, s6
4260 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s2
4261 ; GFX9-NEXT: s_sext_i32_i16 s3, s4
4262 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s3
4263 ; GFX9-NEXT: s_xor_b32 s2, s3, s2
4264 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
4265 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4266 ; GFX9-NEXT: s_or_b32 s8, s2, 1
4267 ; GFX9-NEXT: v_mul_f32_e32 v3, v2, v3
4268 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
4269 ; GFX9-NEXT: v_mad_f32 v2, -v3, v0, v2
4270 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v2|, |v0|
4271 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4272 ; GFX9-NEXT: s_cselect_b32 s2, s8, 0
4273 ; GFX9-NEXT: s_ashr_i32 s3, s6, 16
4274 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
4275 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s3
4276 ; GFX9-NEXT: s_ashr_i32 s4, s4, 16
4277 ; GFX9-NEXT: v_add_u32_e32 v2, s2, v3
4278 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s4
4279 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v0
4280 ; GFX9-NEXT: s_xor_b32 s2, s4, s3
4281 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4282 ; GFX9-NEXT: s_or_b32 s4, s2, 1
4283 ; GFX9-NEXT: v_mul_f32_e32 v4, v3, v4
4284 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
4285 ; GFX9-NEXT: v_mad_f32 v3, -v4, v0, v3
4286 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v3|, |v0|
4287 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4288 ; GFX9-NEXT: v_cvt_i32_f32_e32 v4, v4
4289 ; GFX9-NEXT: s_sext_i32_i16 s3, s7
4290 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s3
4291 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
4292 ; GFX9-NEXT: v_add_u32_e32 v3, s2, v4
4293 ; GFX9-NEXT: s_sext_i32_i16 s2, s5
4294 ; GFX9-NEXT: v_cvt_f32_i32_e32 v4, s2
4295 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v0
4296 ; GFX9-NEXT: s_xor_b32 s2, s2, s3
4297 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4298 ; GFX9-NEXT: s_or_b32 s4, s2, 1
4299 ; GFX9-NEXT: v_mul_f32_e32 v5, v4, v5
4300 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
4301 ; GFX9-NEXT: v_mad_f32 v4, -v5, v0, v4
4302 ; GFX9-NEXT: v_cvt_i32_f32_e32 v5, v5
4303 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v4|, |v0|
4304 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4305 ; GFX9-NEXT: s_cselect_b32 s2, s4, 0
4306 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v5
4307 ; GFX9-NEXT: v_and_b32_e32 v2, 0xffff, v2
4308 ; GFX9-NEXT: v_lshl_or_b32 v2, v3, 16, v2
4309 ; GFX9-NEXT: global_store_short v1, v0, s[0:1] offset:4
4310 ; GFX9-NEXT: global_store_dword v1, v2, s[0:1]
4311 ; GFX9-NEXT: s_endpgm
4312 %r = sdiv <3 x i16> %x, %y
4313 store <3 x i16> %r, ptr addrspace(1) %out
4317 define amdgpu_kernel void @srem_v3i16(ptr addrspace(1) %out, <3 x i16> %x, <3 x i16> %y) {
4318 ; CHECK-LABEL: @srem_v3i16(
4319 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i16> [[X:%.*]], i64 0
4320 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i16> [[Y:%.*]], i64 0
4321 ; CHECK-NEXT: [[TMP3:%.*]] = sext i16 [[TMP1]] to i32
4322 ; CHECK-NEXT: [[TMP4:%.*]] = sext i16 [[TMP2]] to i32
4323 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
4324 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
4325 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
4326 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
4327 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
4328 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
4329 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
4330 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
4331 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
4332 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
4333 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
4334 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
4335 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
4336 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
4337 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
4338 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
4339 ; CHECK-NEXT: [[TMP21:%.*]] = mul i32 [[TMP20]], [[TMP4]]
4340 ; CHECK-NEXT: [[TMP22:%.*]] = sub i32 [[TMP3]], [[TMP21]]
4341 ; CHECK-NEXT: [[TMP23:%.*]] = shl i32 [[TMP22]], 16
4342 ; CHECK-NEXT: [[TMP24:%.*]] = ashr i32 [[TMP23]], 16
4343 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i32 [[TMP24]] to i16
4344 ; CHECK-NEXT: [[TMP26:%.*]] = insertelement <3 x i16> poison, i16 [[TMP25]], i64 0
4345 ; CHECK-NEXT: [[TMP27:%.*]] = extractelement <3 x i16> [[X]], i64 1
4346 ; CHECK-NEXT: [[TMP28:%.*]] = extractelement <3 x i16> [[Y]], i64 1
4347 ; CHECK-NEXT: [[TMP29:%.*]] = sext i16 [[TMP27]] to i32
4348 ; CHECK-NEXT: [[TMP30:%.*]] = sext i16 [[TMP28]] to i32
4349 ; CHECK-NEXT: [[TMP31:%.*]] = xor i32 [[TMP29]], [[TMP30]]
4350 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i32 [[TMP31]], 30
4351 ; CHECK-NEXT: [[TMP33:%.*]] = or i32 [[TMP32]], 1
4352 ; CHECK-NEXT: [[TMP34:%.*]] = sitofp i32 [[TMP29]] to float
4353 ; CHECK-NEXT: [[TMP35:%.*]] = sitofp i32 [[TMP30]] to float
4354 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP35]])
4355 ; CHECK-NEXT: [[TMP37:%.*]] = fmul fast float [[TMP34]], [[TMP36]]
4356 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.trunc.f32(float [[TMP37]])
4357 ; CHECK-NEXT: [[TMP39:%.*]] = fneg fast float [[TMP38]]
4358 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP39]], float [[TMP35]], float [[TMP34]])
4359 ; CHECK-NEXT: [[TMP41:%.*]] = fptosi float [[TMP38]] to i32
4360 ; CHECK-NEXT: [[TMP42:%.*]] = call fast float @llvm.fabs.f32(float [[TMP40]])
4361 ; CHECK-NEXT: [[TMP43:%.*]] = call fast float @llvm.fabs.f32(float [[TMP35]])
4362 ; CHECK-NEXT: [[TMP44:%.*]] = fcmp fast oge float [[TMP42]], [[TMP43]]
4363 ; CHECK-NEXT: [[TMP45:%.*]] = select i1 [[TMP44]], i32 [[TMP33]], i32 0
4364 ; CHECK-NEXT: [[TMP46:%.*]] = add i32 [[TMP41]], [[TMP45]]
4365 ; CHECK-NEXT: [[TMP47:%.*]] = mul i32 [[TMP46]], [[TMP30]]
4366 ; CHECK-NEXT: [[TMP48:%.*]] = sub i32 [[TMP29]], [[TMP47]]
4367 ; CHECK-NEXT: [[TMP49:%.*]] = shl i32 [[TMP48]], 16
4368 ; CHECK-NEXT: [[TMP50:%.*]] = ashr i32 [[TMP49]], 16
4369 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i32 [[TMP50]] to i16
4370 ; CHECK-NEXT: [[TMP52:%.*]] = insertelement <3 x i16> [[TMP26]], i16 [[TMP51]], i64 1
4371 ; CHECK-NEXT: [[TMP53:%.*]] = extractelement <3 x i16> [[X]], i64 2
4372 ; CHECK-NEXT: [[TMP54:%.*]] = extractelement <3 x i16> [[Y]], i64 2
4373 ; CHECK-NEXT: [[TMP55:%.*]] = sext i16 [[TMP53]] to i32
4374 ; CHECK-NEXT: [[TMP56:%.*]] = sext i16 [[TMP54]] to i32
4375 ; CHECK-NEXT: [[TMP57:%.*]] = xor i32 [[TMP55]], [[TMP56]]
4376 ; CHECK-NEXT: [[TMP58:%.*]] = ashr i32 [[TMP57]], 30
4377 ; CHECK-NEXT: [[TMP59:%.*]] = or i32 [[TMP58]], 1
4378 ; CHECK-NEXT: [[TMP60:%.*]] = sitofp i32 [[TMP55]] to float
4379 ; CHECK-NEXT: [[TMP61:%.*]] = sitofp i32 [[TMP56]] to float
4380 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP61]])
4381 ; CHECK-NEXT: [[TMP63:%.*]] = fmul fast float [[TMP60]], [[TMP62]]
4382 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.trunc.f32(float [[TMP63]])
4383 ; CHECK-NEXT: [[TMP65:%.*]] = fneg fast float [[TMP64]]
4384 ; CHECK-NEXT: [[TMP66:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP65]], float [[TMP61]], float [[TMP60]])
4385 ; CHECK-NEXT: [[TMP67:%.*]] = fptosi float [[TMP64]] to i32
4386 ; CHECK-NEXT: [[TMP68:%.*]] = call fast float @llvm.fabs.f32(float [[TMP66]])
4387 ; CHECK-NEXT: [[TMP69:%.*]] = call fast float @llvm.fabs.f32(float [[TMP61]])
4388 ; CHECK-NEXT: [[TMP70:%.*]] = fcmp fast oge float [[TMP68]], [[TMP69]]
4389 ; CHECK-NEXT: [[TMP71:%.*]] = select i1 [[TMP70]], i32 [[TMP59]], i32 0
4390 ; CHECK-NEXT: [[TMP72:%.*]] = add i32 [[TMP67]], [[TMP71]]
4391 ; CHECK-NEXT: [[TMP73:%.*]] = mul i32 [[TMP72]], [[TMP56]]
4392 ; CHECK-NEXT: [[TMP74:%.*]] = sub i32 [[TMP55]], [[TMP73]]
4393 ; CHECK-NEXT: [[TMP75:%.*]] = shl i32 [[TMP74]], 16
4394 ; CHECK-NEXT: [[TMP76:%.*]] = ashr i32 [[TMP75]], 16
4395 ; CHECK-NEXT: [[TMP77:%.*]] = trunc i32 [[TMP76]] to i16
4396 ; CHECK-NEXT: [[TMP78:%.*]] = insertelement <3 x i16> [[TMP52]], i16 [[TMP77]], i64 2
4397 ; CHECK-NEXT: store <3 x i16> [[TMP78]], ptr addrspace(1) [[OUT:%.*]], align 8
4398 ; CHECK-NEXT: ret void
4400 ; GFX6-LABEL: srem_v3i16:
4402 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
4403 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
4404 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
4405 ; GFX6-NEXT: s_mov_b32 s2, -1
4406 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4407 ; GFX6-NEXT: s_sext_i32_i16 s8, s6
4408 ; GFX6-NEXT: v_cvt_f32_i32_e32 v0, s8
4409 ; GFX6-NEXT: s_sext_i32_i16 s9, s4
4410 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s9
4411 ; GFX6-NEXT: s_xor_b32 s8, s9, s8
4412 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v0
4413 ; GFX6-NEXT: s_ashr_i32 s8, s8, 30
4414 ; GFX6-NEXT: s_or_b32 s10, s8, 1
4415 ; GFX6-NEXT: v_mul_f32_e32 v2, v1, v2
4416 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
4417 ; GFX6-NEXT: v_mad_f32 v1, -v2, v0, v1
4418 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
4419 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v1|, |v0|
4420 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
4421 ; GFX6-NEXT: s_cselect_b32 s8, s10, 0
4422 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s8, v2
4423 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s6
4424 ; GFX6-NEXT: s_ashr_i32 s8, s6, 16
4425 ; GFX6-NEXT: v_cvt_f32_i32_e32 v1, s8
4426 ; GFX6-NEXT: s_lshr_b32 s10, s4, 16
4427 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
4428 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
4429 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s4
4430 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v3, v1
4431 ; GFX6-NEXT: s_xor_b32 s4, s4, s8
4432 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
4433 ; GFX6-NEXT: s_lshr_b32 s6, s6, 16
4434 ; GFX6-NEXT: v_mul_f32_e32 v3, v2, v3
4435 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
4436 ; GFX6-NEXT: v_mad_f32 v2, -v3, v1, v2
4437 ; GFX6-NEXT: v_cvt_i32_f32_e32 v3, v3
4438 ; GFX6-NEXT: s_or_b32 s4, s4, 1
4439 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v2|, |v1|
4440 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
4441 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
4442 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s4, v3
4443 ; GFX6-NEXT: s_sext_i32_i16 s4, s7
4444 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s4
4445 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s6
4446 ; GFX6-NEXT: s_sext_i32_i16 s6, s5
4447 ; GFX6-NEXT: v_cvt_f32_i32_e32 v3, s6
4448 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v2
4449 ; GFX6-NEXT: s_xor_b32 s4, s6, s4
4450 ; GFX6-NEXT: s_ashr_i32 s4, s4, 30
4451 ; GFX6-NEXT: s_or_b32 s4, s4, 1
4452 ; GFX6-NEXT: v_mul_f32_e32 v4, v3, v4
4453 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
4454 ; GFX6-NEXT: v_mad_f32 v3, -v4, v2, v3
4455 ; GFX6-NEXT: v_cvt_i32_f32_e32 v4, v4
4456 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[8:9], |v3|, |v2|
4457 ; GFX6-NEXT: s_and_b64 s[8:9], s[8:9], exec
4458 ; GFX6-NEXT: s_cselect_b32 s4, s4, 0
4459 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s4, v4
4460 ; GFX6-NEXT: v_mul_lo_u32 v2, v2, s7
4461 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s10, v1
4462 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
4463 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s5, v2
4464 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
4465 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
4466 ; GFX6-NEXT: buffer_store_short v2, off, s[0:3], 0 offset:4
4467 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4468 ; GFX6-NEXT: s_endpgm
4470 ; GFX9-LABEL: srem_v3i16:
4472 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
4473 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
4474 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
4475 ; GFX9-NEXT: s_sext_i32_i16 s8, s6
4476 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s8
4477 ; GFX9-NEXT: s_sext_i32_i16 s9, s4
4478 ; GFX9-NEXT: v_cvt_f32_i32_e32 v1, s9
4479 ; GFX9-NEXT: s_xor_b32 s2, s9, s8
4480 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v2, v0
4481 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4482 ; GFX9-NEXT: s_or_b32 s10, s2, 1
4483 ; GFX9-NEXT: s_sext_i32_i16 s7, s7
4484 ; GFX9-NEXT: v_mul_f32_e32 v2, v1, v2
4485 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
4486 ; GFX9-NEXT: v_mad_f32 v1, -v2, v0, v1
4487 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v1|, |v0|
4488 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4489 ; GFX9-NEXT: s_cselect_b32 s2, s10, 0
4490 ; GFX9-NEXT: s_ashr_i32 s6, s6, 16
4491 ; GFX9-NEXT: v_cvt_i32_f32_e32 v2, v2
4492 ; GFX9-NEXT: v_cvt_f32_i32_e32 v0, s6
4493 ; GFX9-NEXT: s_ashr_i32 s4, s4, 16
4494 ; GFX9-NEXT: s_sext_i32_i16 s5, s5
4495 ; GFX9-NEXT: v_add_u32_e32 v1, s2, v2
4496 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s4
4497 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v3, v0
4498 ; GFX9-NEXT: s_xor_b32 s2, s4, s6
4499 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4500 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, s8
4501 ; GFX9-NEXT: v_mul_f32_e32 v3, v2, v3
4502 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
4503 ; GFX9-NEXT: v_mad_f32 v2, -v3, v0, v2
4504 ; GFX9-NEXT: s_or_b32 s8, s2, 1
4505 ; GFX9-NEXT: v_cvt_i32_f32_e32 v3, v3
4506 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v2|, |v0|
4507 ; GFX9-NEXT: v_cvt_f32_i32_e32 v2, s7
4508 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4509 ; GFX9-NEXT: s_cselect_b32 s2, s8, 0
4510 ; GFX9-NEXT: v_add_u32_e32 v0, s2, v3
4511 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s5
4512 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v4, v2
4513 ; GFX9-NEXT: s_xor_b32 s2, s5, s7
4514 ; GFX9-NEXT: s_ashr_i32 s2, s2, 30
4515 ; GFX9-NEXT: v_mul_lo_u32 v0, v0, s6
4516 ; GFX9-NEXT: v_mul_f32_e32 v4, v3, v4
4517 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
4518 ; GFX9-NEXT: v_mad_f32 v3, -v4, v2, v3
4519 ; GFX9-NEXT: v_cvt_i32_f32_e32 v4, v4
4520 ; GFX9-NEXT: s_or_b32 s6, s2, 1
4521 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v3|, |v2|
4522 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
4523 ; GFX9-NEXT: s_cselect_b32 s2, s6, 0
4524 ; GFX9-NEXT: v_add_u32_e32 v2, s2, v4
4525 ; GFX9-NEXT: v_mul_lo_u32 v2, v2, s7
4526 ; GFX9-NEXT: v_sub_u32_e32 v1, s9, v1
4527 ; GFX9-NEXT: v_mov_b32_e32 v3, 0
4528 ; GFX9-NEXT: v_sub_u32_e32 v0, s4, v0
4529 ; GFX9-NEXT: v_sub_u32_e32 v2, s5, v2
4530 ; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1
4531 ; GFX9-NEXT: v_lshl_or_b32 v0, v0, 16, v1
4532 ; GFX9-NEXT: global_store_short v3, v2, s[0:1] offset:4
4533 ; GFX9-NEXT: global_store_dword v3, v0, s[0:1]
4534 ; GFX9-NEXT: s_endpgm
4535 %r = srem <3 x i16> %x, %y
4536 store <3 x i16> %r, ptr addrspace(1) %out
4540 define amdgpu_kernel void @udiv_v3i15(ptr addrspace(1) %out, <3 x i15> %x, <3 x i15> %y) {
4541 ; CHECK-LABEL: @udiv_v3i15(
4542 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i15> [[X:%.*]], i64 0
4543 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i15> [[Y:%.*]], i64 0
4544 ; CHECK-NEXT: [[TMP3:%.*]] = zext i15 [[TMP1]] to i32
4545 ; CHECK-NEXT: [[TMP4:%.*]] = zext i15 [[TMP2]] to i32
4546 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
4547 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
4548 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
4549 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
4550 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
4551 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
4552 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
4553 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
4554 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
4555 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
4556 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
4557 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
4558 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
4559 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[TMP17]], 32767
4560 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i32 [[TMP18]] to i15
4561 ; CHECK-NEXT: [[TMP20:%.*]] = insertelement <3 x i15> poison, i15 [[TMP19]], i64 0
4562 ; CHECK-NEXT: [[TMP21:%.*]] = extractelement <3 x i15> [[X]], i64 1
4563 ; CHECK-NEXT: [[TMP22:%.*]] = extractelement <3 x i15> [[Y]], i64 1
4564 ; CHECK-NEXT: [[TMP23:%.*]] = zext i15 [[TMP21]] to i32
4565 ; CHECK-NEXT: [[TMP24:%.*]] = zext i15 [[TMP22]] to i32
4566 ; CHECK-NEXT: [[TMP25:%.*]] = uitofp i32 [[TMP23]] to float
4567 ; CHECK-NEXT: [[TMP26:%.*]] = uitofp i32 [[TMP24]] to float
4568 ; CHECK-NEXT: [[TMP27:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP26]])
4569 ; CHECK-NEXT: [[TMP28:%.*]] = fmul fast float [[TMP25]], [[TMP27]]
4570 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.trunc.f32(float [[TMP28]])
4571 ; CHECK-NEXT: [[TMP30:%.*]] = fneg fast float [[TMP29]]
4572 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP30]], float [[TMP26]], float [[TMP25]])
4573 ; CHECK-NEXT: [[TMP32:%.*]] = fptoui float [[TMP29]] to i32
4574 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.fabs.f32(float [[TMP31]])
4575 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.fabs.f32(float [[TMP26]])
4576 ; CHECK-NEXT: [[TMP35:%.*]] = fcmp fast oge float [[TMP33]], [[TMP34]]
4577 ; CHECK-NEXT: [[TMP36:%.*]] = select i1 [[TMP35]], i32 1, i32 0
4578 ; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP32]], [[TMP36]]
4579 ; CHECK-NEXT: [[TMP38:%.*]] = and i32 [[TMP37]], 32767
4580 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i32 [[TMP38]] to i15
4581 ; CHECK-NEXT: [[TMP40:%.*]] = insertelement <3 x i15> [[TMP20]], i15 [[TMP39]], i64 1
4582 ; CHECK-NEXT: [[TMP41:%.*]] = extractelement <3 x i15> [[X]], i64 2
4583 ; CHECK-NEXT: [[TMP42:%.*]] = extractelement <3 x i15> [[Y]], i64 2
4584 ; CHECK-NEXT: [[TMP43:%.*]] = zext i15 [[TMP41]] to i32
4585 ; CHECK-NEXT: [[TMP44:%.*]] = zext i15 [[TMP42]] to i32
4586 ; CHECK-NEXT: [[TMP45:%.*]] = uitofp i32 [[TMP43]] to float
4587 ; CHECK-NEXT: [[TMP46:%.*]] = uitofp i32 [[TMP44]] to float
4588 ; CHECK-NEXT: [[TMP47:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP46]])
4589 ; CHECK-NEXT: [[TMP48:%.*]] = fmul fast float [[TMP45]], [[TMP47]]
4590 ; CHECK-NEXT: [[TMP49:%.*]] = call fast float @llvm.trunc.f32(float [[TMP48]])
4591 ; CHECK-NEXT: [[TMP50:%.*]] = fneg fast float [[TMP49]]
4592 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP50]], float [[TMP46]], float [[TMP45]])
4593 ; CHECK-NEXT: [[TMP52:%.*]] = fptoui float [[TMP49]] to i32
4594 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.fabs.f32(float [[TMP51]])
4595 ; CHECK-NEXT: [[TMP54:%.*]] = call fast float @llvm.fabs.f32(float [[TMP46]])
4596 ; CHECK-NEXT: [[TMP55:%.*]] = fcmp fast oge float [[TMP53]], [[TMP54]]
4597 ; CHECK-NEXT: [[TMP56:%.*]] = select i1 [[TMP55]], i32 1, i32 0
4598 ; CHECK-NEXT: [[TMP57:%.*]] = add i32 [[TMP52]], [[TMP56]]
4599 ; CHECK-NEXT: [[TMP58:%.*]] = and i32 [[TMP57]], 32767
4600 ; CHECK-NEXT: [[TMP59:%.*]] = trunc i32 [[TMP58]] to i15
4601 ; CHECK-NEXT: [[TMP60:%.*]] = insertelement <3 x i15> [[TMP40]], i15 [[TMP59]], i64 2
4602 ; CHECK-NEXT: store <3 x i15> [[TMP60]], ptr addrspace(1) [[OUT:%.*]], align 8
4603 ; CHECK-NEXT: ret void
4605 ; GFX6-LABEL: udiv_v3i15:
4607 ; GFX6-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
4608 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0xd
4609 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
4610 ; GFX6-NEXT: s_mov_b32 s6, -1
4611 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4612 ; GFX6-NEXT: s_and_b32 s2, s10, 0x7fff
4613 ; GFX6-NEXT: s_and_b32 s3, s0, 0x7fff
4614 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s3
4615 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
4616 ; GFX6-NEXT: s_bfe_u32 s0, s0, 0xf000f
4617 ; GFX6-NEXT: v_cvt_f32_u32_e32 v3, s2
4618 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v1
4619 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s0
4620 ; GFX6-NEXT: s_bfe_u32 s3, s10, 0xf000f
4621 ; GFX6-NEXT: v_alignbit_b32 v2, s1, v2, 30
4622 ; GFX6-NEXT: v_mul_f32_e32 v4, v3, v4
4623 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s3
4624 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v7, v5
4625 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v2
4626 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
4627 ; GFX6-NEXT: v_mad_f32 v3, -v4, v1, v3
4628 ; GFX6-NEXT: v_cvt_u32_f32_e32 v4, v4
4629 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, v2
4630 ; GFX6-NEXT: v_mov_b32_e32 v0, s10
4631 ; GFX6-NEXT: v_alignbit_b32 v0, s11, v0, 30
4632 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v1
4633 ; GFX6-NEXT: v_mul_f32_e32 v1, v6, v7
4634 ; GFX6-NEXT: v_and_b32_e32 v0, 0x7fff, v0
4635 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
4636 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
4637 ; GFX6-NEXT: v_mad_f32 v4, -v1, v5, v6
4638 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
4639 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, v0
4640 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v2
4641 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v4|, v5
4642 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v1, vcc
4643 ; GFX6-NEXT: v_mul_f32_e32 v1, v0, v6
4644 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
4645 ; GFX6-NEXT: v_cvt_u32_f32_e32 v5, v1
4646 ; GFX6-NEXT: v_mad_f32 v0, -v1, v2, v0
4647 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, v2
4648 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v3
4649 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, 0, v5, vcc
4650 ; GFX6-NEXT: v_and_b32_e32 v3, 0x7fff, v4
4651 ; GFX6-NEXT: v_lshl_b64 v[0:1], v[0:1], 30
4652 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 15, v3
4653 ; GFX6-NEXT: v_or_b32_e32 v2, v3, v2
4654 ; GFX6-NEXT: s_mov_b32 s4, s8
4655 ; GFX6-NEXT: s_mov_b32 s5, s9
4656 ; GFX6-NEXT: v_or_b32_e32 v0, v2, v0
4657 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4658 ; GFX6-NEXT: s_waitcnt expcnt(0)
4659 ; GFX6-NEXT: v_and_b32_e32 v0, 0x1fff, v1
4660 ; GFX6-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:4
4661 ; GFX6-NEXT: s_endpgm
4663 ; GFX9-LABEL: udiv_v3i15:
4665 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
4666 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x34
4667 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
4668 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
4669 ; GFX9-NEXT: s_and_b32 s2, s6, 0x7fff
4670 ; GFX9-NEXT: s_and_b32 s3, s0, 0x7fff
4671 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s3
4672 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
4673 ; GFX9-NEXT: s_bfe_u32 s0, s0, 0xf000f
4674 ; GFX9-NEXT: v_cvt_f32_u32_e32 v4, s2
4675 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
4676 ; GFX9-NEXT: v_cvt_f32_u32_e32 v6, s0
4677 ; GFX9-NEXT: s_bfe_u32 s3, s6, 0xf000f
4678 ; GFX9-NEXT: v_alignbit_b32 v3, s1, v3, 30
4679 ; GFX9-NEXT: v_mul_f32_e32 v5, v4, v5
4680 ; GFX9-NEXT: v_cvt_f32_u32_e32 v7, s3
4681 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v8, v6
4682 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v3
4683 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
4684 ; GFX9-NEXT: v_mad_f32 v4, -v5, v1, v4
4685 ; GFX9-NEXT: v_cvt_u32_f32_e32 v5, v5
4686 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, v3
4687 ; GFX9-NEXT: v_mov_b32_e32 v0, s6
4688 ; GFX9-NEXT: v_alignbit_b32 v0, s7, v0, 30
4689 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v4|, v1
4690 ; GFX9-NEXT: v_mul_f32_e32 v1, v7, v8
4691 ; GFX9-NEXT: v_and_b32_e32 v0, 0x7fff, v0
4692 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
4693 ; GFX9-NEXT: v_addc_co_u32_e32 v4, vcc, 0, v5, vcc
4694 ; GFX9-NEXT: v_mad_f32 v5, -v1, v6, v7
4695 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
4696 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, v0
4697 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v3
4698 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v5|, v6
4699 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, 0, v1, vcc
4700 ; GFX9-NEXT: v_mul_f32_e32 v1, v0, v7
4701 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
4702 ; GFX9-NEXT: v_cvt_u32_f32_e32 v6, v1
4703 ; GFX9-NEXT: v_mad_f32 v0, -v1, v3, v0
4704 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, v3
4705 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v4
4706 ; GFX9-NEXT: v_addc_co_u32_e32 v0, vcc, 0, v6, vcc
4707 ; GFX9-NEXT: v_and_b32_e32 v4, 0x7fff, v5
4708 ; GFX9-NEXT: v_lshlrev_b64 v[0:1], 30, v[0:1]
4709 ; GFX9-NEXT: v_lshlrev_b32_e32 v4, 15, v4
4710 ; GFX9-NEXT: v_or_b32_e32 v3, v3, v4
4711 ; GFX9-NEXT: v_or_b32_e32 v0, v3, v0
4712 ; GFX9-NEXT: global_store_dword v2, v0, s[4:5]
4713 ; GFX9-NEXT: v_and_b32_e32 v0, 0x1fff, v1
4714 ; GFX9-NEXT: global_store_short v2, v0, s[4:5] offset:4
4715 ; GFX9-NEXT: s_endpgm
4716 %r = udiv <3 x i15> %x, %y
4717 store <3 x i15> %r, ptr addrspace(1) %out
4721 define amdgpu_kernel void @urem_v3i15(ptr addrspace(1) %out, <3 x i15> %x, <3 x i15> %y) {
4722 ; CHECK-LABEL: @urem_v3i15(
4723 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i15> [[X:%.*]], i64 0
4724 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i15> [[Y:%.*]], i64 0
4725 ; CHECK-NEXT: [[TMP3:%.*]] = zext i15 [[TMP1]] to i32
4726 ; CHECK-NEXT: [[TMP4:%.*]] = zext i15 [[TMP2]] to i32
4727 ; CHECK-NEXT: [[TMP5:%.*]] = uitofp i32 [[TMP3]] to float
4728 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp i32 [[TMP4]] to float
4729 ; CHECK-NEXT: [[TMP7:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP6]])
4730 ; CHECK-NEXT: [[TMP8:%.*]] = fmul fast float [[TMP5]], [[TMP7]]
4731 ; CHECK-NEXT: [[TMP9:%.*]] = call fast float @llvm.trunc.f32(float [[TMP8]])
4732 ; CHECK-NEXT: [[TMP10:%.*]] = fneg fast float [[TMP9]]
4733 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP10]], float [[TMP6]], float [[TMP5]])
4734 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP9]] to i32
4735 ; CHECK-NEXT: [[TMP13:%.*]] = call fast float @llvm.fabs.f32(float [[TMP11]])
4736 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.fabs.f32(float [[TMP6]])
4737 ; CHECK-NEXT: [[TMP15:%.*]] = fcmp fast oge float [[TMP13]], [[TMP14]]
4738 ; CHECK-NEXT: [[TMP16:%.*]] = select i1 [[TMP15]], i32 1, i32 0
4739 ; CHECK-NEXT: [[TMP17:%.*]] = add i32 [[TMP12]], [[TMP16]]
4740 ; CHECK-NEXT: [[TMP18:%.*]] = mul i32 [[TMP17]], [[TMP4]]
4741 ; CHECK-NEXT: [[TMP19:%.*]] = sub i32 [[TMP3]], [[TMP18]]
4742 ; CHECK-NEXT: [[TMP20:%.*]] = and i32 [[TMP19]], 32767
4743 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i32 [[TMP20]] to i15
4744 ; CHECK-NEXT: [[TMP22:%.*]] = insertelement <3 x i15> poison, i15 [[TMP21]], i64 0
4745 ; CHECK-NEXT: [[TMP23:%.*]] = extractelement <3 x i15> [[X]], i64 1
4746 ; CHECK-NEXT: [[TMP24:%.*]] = extractelement <3 x i15> [[Y]], i64 1
4747 ; CHECK-NEXT: [[TMP25:%.*]] = zext i15 [[TMP23]] to i32
4748 ; CHECK-NEXT: [[TMP26:%.*]] = zext i15 [[TMP24]] to i32
4749 ; CHECK-NEXT: [[TMP27:%.*]] = uitofp i32 [[TMP25]] to float
4750 ; CHECK-NEXT: [[TMP28:%.*]] = uitofp i32 [[TMP26]] to float
4751 ; CHECK-NEXT: [[TMP29:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP28]])
4752 ; CHECK-NEXT: [[TMP30:%.*]] = fmul fast float [[TMP27]], [[TMP29]]
4753 ; CHECK-NEXT: [[TMP31:%.*]] = call fast float @llvm.trunc.f32(float [[TMP30]])
4754 ; CHECK-NEXT: [[TMP32:%.*]] = fneg fast float [[TMP31]]
4755 ; CHECK-NEXT: [[TMP33:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP32]], float [[TMP28]], float [[TMP27]])
4756 ; CHECK-NEXT: [[TMP34:%.*]] = fptoui float [[TMP31]] to i32
4757 ; CHECK-NEXT: [[TMP35:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
4758 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.fabs.f32(float [[TMP28]])
4759 ; CHECK-NEXT: [[TMP37:%.*]] = fcmp fast oge float [[TMP35]], [[TMP36]]
4760 ; CHECK-NEXT: [[TMP38:%.*]] = select i1 [[TMP37]], i32 1, i32 0
4761 ; CHECK-NEXT: [[TMP39:%.*]] = add i32 [[TMP34]], [[TMP38]]
4762 ; CHECK-NEXT: [[TMP40:%.*]] = mul i32 [[TMP39]], [[TMP26]]
4763 ; CHECK-NEXT: [[TMP41:%.*]] = sub i32 [[TMP25]], [[TMP40]]
4764 ; CHECK-NEXT: [[TMP42:%.*]] = and i32 [[TMP41]], 32767
4765 ; CHECK-NEXT: [[TMP43:%.*]] = trunc i32 [[TMP42]] to i15
4766 ; CHECK-NEXT: [[TMP44:%.*]] = insertelement <3 x i15> [[TMP22]], i15 [[TMP43]], i64 1
4767 ; CHECK-NEXT: [[TMP45:%.*]] = extractelement <3 x i15> [[X]], i64 2
4768 ; CHECK-NEXT: [[TMP46:%.*]] = extractelement <3 x i15> [[Y]], i64 2
4769 ; CHECK-NEXT: [[TMP47:%.*]] = zext i15 [[TMP45]] to i32
4770 ; CHECK-NEXT: [[TMP48:%.*]] = zext i15 [[TMP46]] to i32
4771 ; CHECK-NEXT: [[TMP49:%.*]] = uitofp i32 [[TMP47]] to float
4772 ; CHECK-NEXT: [[TMP50:%.*]] = uitofp i32 [[TMP48]] to float
4773 ; CHECK-NEXT: [[TMP51:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP50]])
4774 ; CHECK-NEXT: [[TMP52:%.*]] = fmul fast float [[TMP49]], [[TMP51]]
4775 ; CHECK-NEXT: [[TMP53:%.*]] = call fast float @llvm.trunc.f32(float [[TMP52]])
4776 ; CHECK-NEXT: [[TMP54:%.*]] = fneg fast float [[TMP53]]
4777 ; CHECK-NEXT: [[TMP55:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP54]], float [[TMP50]], float [[TMP49]])
4778 ; CHECK-NEXT: [[TMP56:%.*]] = fptoui float [[TMP53]] to i32
4779 ; CHECK-NEXT: [[TMP57:%.*]] = call fast float @llvm.fabs.f32(float [[TMP55]])
4780 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.fabs.f32(float [[TMP50]])
4781 ; CHECK-NEXT: [[TMP59:%.*]] = fcmp fast oge float [[TMP57]], [[TMP58]]
4782 ; CHECK-NEXT: [[TMP60:%.*]] = select i1 [[TMP59]], i32 1, i32 0
4783 ; CHECK-NEXT: [[TMP61:%.*]] = add i32 [[TMP56]], [[TMP60]]
4784 ; CHECK-NEXT: [[TMP62:%.*]] = mul i32 [[TMP61]], [[TMP48]]
4785 ; CHECK-NEXT: [[TMP63:%.*]] = sub i32 [[TMP47]], [[TMP62]]
4786 ; CHECK-NEXT: [[TMP64:%.*]] = and i32 [[TMP63]], 32767
4787 ; CHECK-NEXT: [[TMP65:%.*]] = trunc i32 [[TMP64]] to i15
4788 ; CHECK-NEXT: [[TMP66:%.*]] = insertelement <3 x i15> [[TMP44]], i15 [[TMP65]], i64 2
4789 ; CHECK-NEXT: store <3 x i15> [[TMP66]], ptr addrspace(1) [[OUT:%.*]], align 8
4790 ; CHECK-NEXT: ret void
4792 ; GFX6-LABEL: urem_v3i15:
4794 ; GFX6-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
4795 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0xd
4796 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
4797 ; GFX6-NEXT: s_mov_b32 s6, -1
4798 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4799 ; GFX6-NEXT: s_mov_b32 s4, s8
4800 ; GFX6-NEXT: s_and_b32 s8, s0, 0x7fff
4801 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s8
4802 ; GFX6-NEXT: s_and_b32 s3, s10, 0x7fff
4803 ; GFX6-NEXT: v_cvt_f32_u32_e32 v3, s3
4804 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
4805 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v1
4806 ; GFX6-NEXT: v_alignbit_b32 v2, s1, v2, 30
4807 ; GFX6-NEXT: s_bfe_u32 s1, s0, 0xf000f
4808 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s1
4809 ; GFX6-NEXT: v_mul_f32_e32 v4, v3, v4
4810 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
4811 ; GFX6-NEXT: v_mad_f32 v3, -v4, v1, v3
4812 ; GFX6-NEXT: v_cvt_u32_f32_e32 v4, v4
4813 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v1
4814 ; GFX6-NEXT: s_bfe_u32 s8, s10, 0xf000f
4815 ; GFX6-NEXT: v_cvt_f32_u32_e32 v3, s8
4816 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v4, vcc
4817 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s0
4818 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v5
4819 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v2
4820 ; GFX6-NEXT: v_mov_b32_e32 v0, s10
4821 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s10, v1
4822 ; GFX6-NEXT: v_mul_f32_e32 v1, v3, v4
4823 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, v2
4824 ; GFX6-NEXT: v_alignbit_b32 v0, s11, v0, 30
4825 ; GFX6-NEXT: v_and_b32_e32 v0, 0x7fff, v0
4826 ; GFX6-NEXT: v_cvt_f32_u32_e32 v7, v0
4827 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v8, v4
4828 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
4829 ; GFX6-NEXT: v_mad_f32 v3, -v1, v5, v3
4830 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
4831 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v5
4832 ; GFX6-NEXT: v_mul_f32_e32 v3, v7, v8
4833 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
4834 ; GFX6-NEXT: v_cvt_u32_f32_e32 v5, v3
4835 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
4836 ; GFX6-NEXT: v_mad_f32 v3, -v3, v4, v7
4837 ; GFX6-NEXT: s_lshr_b32 s0, s0, 15
4838 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v3|, v4
4839 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s0
4840 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc
4841 ; GFX6-NEXT: v_mul_lo_u32 v2, v3, v2
4842 ; GFX6-NEXT: s_lshr_b32 s2, s10, 15
4843 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s2, v1
4844 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
4845 ; GFX6-NEXT: v_and_b32_e32 v3, 0x7fff, v3
4846 ; GFX6-NEXT: v_lshl_b64 v[0:1], v[0:1], 30
4847 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v6
4848 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 15, v3
4849 ; GFX6-NEXT: v_or_b32_e32 v2, v3, v2
4850 ; GFX6-NEXT: s_mov_b32 s5, s9
4851 ; GFX6-NEXT: v_or_b32_e32 v0, v2, v0
4852 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4853 ; GFX6-NEXT: s_waitcnt expcnt(0)
4854 ; GFX6-NEXT: v_and_b32_e32 v0, 0x1fff, v1
4855 ; GFX6-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:4
4856 ; GFX6-NEXT: s_endpgm
4858 ; GFX9-LABEL: urem_v3i15:
4860 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
4861 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x34
4862 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
4863 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
4864 ; GFX9-NEXT: v_mov_b32_e32 v0, s6
4865 ; GFX9-NEXT: v_alignbit_b32 v0, s7, v0, 30
4866 ; GFX9-NEXT: s_and_b32 s7, s0, 0x7fff
4867 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s7
4868 ; GFX9-NEXT: s_and_b32 s2, s6, 0x7fff
4869 ; GFX9-NEXT: v_cvt_f32_u32_e32 v4, s2
4870 ; GFX9-NEXT: s_bfe_u32 s2, s0, 0xf000f
4871 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v1
4872 ; GFX9-NEXT: v_cvt_f32_u32_e32 v6, s2
4873 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
4874 ; GFX9-NEXT: v_alignbit_b32 v3, s1, v3, 30
4875 ; GFX9-NEXT: v_mul_f32_e32 v5, v4, v5
4876 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
4877 ; GFX9-NEXT: v_mad_f32 v4, -v5, v1, v4
4878 ; GFX9-NEXT: v_cvt_u32_f32_e32 v5, v5
4879 ; GFX9-NEXT: s_bfe_u32 s3, s6, 0xf000f
4880 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v3
4881 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v4|, v1
4882 ; GFX9-NEXT: v_cvt_f32_u32_e32 v7, s3
4883 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v8, v6
4884 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v5, vcc
4885 ; GFX9-NEXT: v_cvt_f32_u32_e32 v5, v3
4886 ; GFX9-NEXT: v_and_b32_e32 v0, 0x7fff, v0
4887 ; GFX9-NEXT: v_mul_f32_e32 v4, v7, v8
4888 ; GFX9-NEXT: v_cvt_f32_u32_e32 v8, v0
4889 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v9, v5
4890 ; GFX9-NEXT: v_trunc_f32_e32 v4, v4
4891 ; GFX9-NEXT: v_mad_f32 v7, -v4, v6, v7
4892 ; GFX9-NEXT: v_cvt_u32_f32_e32 v4, v4
4893 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v7|, v6
4894 ; GFX9-NEXT: v_mul_f32_e32 v6, v8, v9
4895 ; GFX9-NEXT: v_trunc_f32_e32 v6, v6
4896 ; GFX9-NEXT: v_cvt_u32_f32_e32 v7, v6
4897 ; GFX9-NEXT: v_addc_co_u32_e32 v4, vcc, 0, v4, vcc
4898 ; GFX9-NEXT: v_mad_f32 v6, -v6, v5, v8
4899 ; GFX9-NEXT: s_lshr_b32 s1, s0, 15
4900 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v6|, v5
4901 ; GFX9-NEXT: v_mul_lo_u32 v4, v4, s1
4902 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, 0, v7, vcc
4903 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, s0
4904 ; GFX9-NEXT: v_mul_lo_u32 v3, v5, v3
4905 ; GFX9-NEXT: s_lshr_b32 s0, s6, 15
4906 ; GFX9-NEXT: v_sub_u32_e32 v4, s0, v4
4907 ; GFX9-NEXT: v_sub_u32_e32 v5, s6, v1
4908 ; GFX9-NEXT: v_sub_u32_e32 v0, v0, v3
4909 ; GFX9-NEXT: v_and_b32_e32 v4, 0x7fff, v4
4910 ; GFX9-NEXT: v_lshlrev_b64 v[0:1], 30, v[0:1]
4911 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v5
4912 ; GFX9-NEXT: v_lshlrev_b32_e32 v4, 15, v4
4913 ; GFX9-NEXT: v_or_b32_e32 v3, v3, v4
4914 ; GFX9-NEXT: v_or_b32_e32 v0, v3, v0
4915 ; GFX9-NEXT: global_store_dword v2, v0, s[4:5]
4916 ; GFX9-NEXT: v_and_b32_e32 v0, 0x1fff, v1
4917 ; GFX9-NEXT: global_store_short v2, v0, s[4:5] offset:4
4918 ; GFX9-NEXT: s_endpgm
4919 %r = urem <3 x i15> %x, %y
4920 store <3 x i15> %r, ptr addrspace(1) %out
4924 define amdgpu_kernel void @sdiv_v3i15(ptr addrspace(1) %out, <3 x i15> %x, <3 x i15> %y) {
4925 ; CHECK-LABEL: @sdiv_v3i15(
4926 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i15> [[X:%.*]], i64 0
4927 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i15> [[Y:%.*]], i64 0
4928 ; CHECK-NEXT: [[TMP3:%.*]] = sext i15 [[TMP1]] to i32
4929 ; CHECK-NEXT: [[TMP4:%.*]] = sext i15 [[TMP2]] to i32
4930 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
4931 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
4932 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
4933 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
4934 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
4935 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
4936 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
4937 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
4938 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
4939 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
4940 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
4941 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
4942 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
4943 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
4944 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
4945 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
4946 ; CHECK-NEXT: [[TMP21:%.*]] = shl i32 [[TMP20]], 17
4947 ; CHECK-NEXT: [[TMP22:%.*]] = ashr i32 [[TMP21]], 17
4948 ; CHECK-NEXT: [[TMP23:%.*]] = trunc i32 [[TMP22]] to i15
4949 ; CHECK-NEXT: [[TMP24:%.*]] = insertelement <3 x i15> poison, i15 [[TMP23]], i64 0
4950 ; CHECK-NEXT: [[TMP25:%.*]] = extractelement <3 x i15> [[X]], i64 1
4951 ; CHECK-NEXT: [[TMP26:%.*]] = extractelement <3 x i15> [[Y]], i64 1
4952 ; CHECK-NEXT: [[TMP27:%.*]] = sext i15 [[TMP25]] to i32
4953 ; CHECK-NEXT: [[TMP28:%.*]] = sext i15 [[TMP26]] to i32
4954 ; CHECK-NEXT: [[TMP29:%.*]] = xor i32 [[TMP27]], [[TMP28]]
4955 ; CHECK-NEXT: [[TMP30:%.*]] = ashr i32 [[TMP29]], 30
4956 ; CHECK-NEXT: [[TMP31:%.*]] = or i32 [[TMP30]], 1
4957 ; CHECK-NEXT: [[TMP32:%.*]] = sitofp i32 [[TMP27]] to float
4958 ; CHECK-NEXT: [[TMP33:%.*]] = sitofp i32 [[TMP28]] to float
4959 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP33]])
4960 ; CHECK-NEXT: [[TMP35:%.*]] = fmul fast float [[TMP32]], [[TMP34]]
4961 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.trunc.f32(float [[TMP35]])
4962 ; CHECK-NEXT: [[TMP37:%.*]] = fneg fast float [[TMP36]]
4963 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP37]], float [[TMP33]], float [[TMP32]])
4964 ; CHECK-NEXT: [[TMP39:%.*]] = fptosi float [[TMP36]] to i32
4965 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.fabs.f32(float [[TMP38]])
4966 ; CHECK-NEXT: [[TMP41:%.*]] = call fast float @llvm.fabs.f32(float [[TMP33]])
4967 ; CHECK-NEXT: [[TMP42:%.*]] = fcmp fast oge float [[TMP40]], [[TMP41]]
4968 ; CHECK-NEXT: [[TMP43:%.*]] = select i1 [[TMP42]], i32 [[TMP31]], i32 0
4969 ; CHECK-NEXT: [[TMP44:%.*]] = add i32 [[TMP39]], [[TMP43]]
4970 ; CHECK-NEXT: [[TMP45:%.*]] = shl i32 [[TMP44]], 17
4971 ; CHECK-NEXT: [[TMP46:%.*]] = ashr i32 [[TMP45]], 17
4972 ; CHECK-NEXT: [[TMP47:%.*]] = trunc i32 [[TMP46]] to i15
4973 ; CHECK-NEXT: [[TMP48:%.*]] = insertelement <3 x i15> [[TMP24]], i15 [[TMP47]], i64 1
4974 ; CHECK-NEXT: [[TMP49:%.*]] = extractelement <3 x i15> [[X]], i64 2
4975 ; CHECK-NEXT: [[TMP50:%.*]] = extractelement <3 x i15> [[Y]], i64 2
4976 ; CHECK-NEXT: [[TMP51:%.*]] = sext i15 [[TMP49]] to i32
4977 ; CHECK-NEXT: [[TMP52:%.*]] = sext i15 [[TMP50]] to i32
4978 ; CHECK-NEXT: [[TMP53:%.*]] = xor i32 [[TMP51]], [[TMP52]]
4979 ; CHECK-NEXT: [[TMP54:%.*]] = ashr i32 [[TMP53]], 30
4980 ; CHECK-NEXT: [[TMP55:%.*]] = or i32 [[TMP54]], 1
4981 ; CHECK-NEXT: [[TMP56:%.*]] = sitofp i32 [[TMP51]] to float
4982 ; CHECK-NEXT: [[TMP57:%.*]] = sitofp i32 [[TMP52]] to float
4983 ; CHECK-NEXT: [[TMP58:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP57]])
4984 ; CHECK-NEXT: [[TMP59:%.*]] = fmul fast float [[TMP56]], [[TMP58]]
4985 ; CHECK-NEXT: [[TMP60:%.*]] = call fast float @llvm.trunc.f32(float [[TMP59]])
4986 ; CHECK-NEXT: [[TMP61:%.*]] = fneg fast float [[TMP60]]
4987 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP61]], float [[TMP57]], float [[TMP56]])
4988 ; CHECK-NEXT: [[TMP63:%.*]] = fptosi float [[TMP60]] to i32
4989 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.fabs.f32(float [[TMP62]])
4990 ; CHECK-NEXT: [[TMP65:%.*]] = call fast float @llvm.fabs.f32(float [[TMP57]])
4991 ; CHECK-NEXT: [[TMP66:%.*]] = fcmp fast oge float [[TMP64]], [[TMP65]]
4992 ; CHECK-NEXT: [[TMP67:%.*]] = select i1 [[TMP66]], i32 [[TMP55]], i32 0
4993 ; CHECK-NEXT: [[TMP68:%.*]] = add i32 [[TMP63]], [[TMP67]]
4994 ; CHECK-NEXT: [[TMP69:%.*]] = shl i32 [[TMP68]], 17
4995 ; CHECK-NEXT: [[TMP70:%.*]] = ashr i32 [[TMP69]], 17
4996 ; CHECK-NEXT: [[TMP71:%.*]] = trunc i32 [[TMP70]] to i15
4997 ; CHECK-NEXT: [[TMP72:%.*]] = insertelement <3 x i15> [[TMP48]], i15 [[TMP71]], i64 2
4998 ; CHECK-NEXT: store <3 x i15> [[TMP72]], ptr addrspace(1) [[OUT:%.*]], align 8
4999 ; CHECK-NEXT: ret void
5001 ; GFX6-LABEL: sdiv_v3i15:
5003 ; GFX6-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
5004 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0xd
5005 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5006 ; GFX6-NEXT: s_mov_b32 s6, -1
5007 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5008 ; GFX6-NEXT: v_mov_b32_e32 v0, s10
5009 ; GFX6-NEXT: s_bfe_i32 s2, s0, 0xf0000
5010 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s2
5011 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
5012 ; GFX6-NEXT: v_alignbit_b32 v1, s1, v1, 30
5013 ; GFX6-NEXT: s_bfe_i32 s1, s10, 0xf0000
5014 ; GFX6-NEXT: v_cvt_f32_i32_e32 v3, s1
5015 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v4, v2
5016 ; GFX6-NEXT: s_xor_b32 s1, s1, s2
5017 ; GFX6-NEXT: s_ashr_i32 s1, s1, 30
5018 ; GFX6-NEXT: s_or_b32 s1, s1, 1
5019 ; GFX6-NEXT: v_mul_f32_e32 v4, v3, v4
5020 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
5021 ; GFX6-NEXT: v_mad_f32 v3, -v4, v2, v3
5022 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[2:3], |v3|, |v2|
5023 ; GFX6-NEXT: s_and_b64 s[2:3], s[2:3], exec
5024 ; GFX6-NEXT: v_cvt_i32_f32_e32 v4, v4
5025 ; GFX6-NEXT: s_cselect_b32 s1, s1, 0
5026 ; GFX6-NEXT: s_bfe_i32 s0, s0, 0xf000f
5027 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, s0
5028 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, s1, v4
5029 ; GFX6-NEXT: s_bfe_i32 s1, s10, 0xf000f
5030 ; GFX6-NEXT: v_cvt_f32_i32_e32 v4, s1
5031 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v5, v2
5032 ; GFX6-NEXT: s_xor_b32 s0, s1, s0
5033 ; GFX6-NEXT: s_ashr_i32 s0, s0, 30
5034 ; GFX6-NEXT: v_bfe_i32 v1, v1, 0, 15
5035 ; GFX6-NEXT: v_mul_f32_e32 v5, v4, v5
5036 ; GFX6-NEXT: v_trunc_f32_e32 v5, v5
5037 ; GFX6-NEXT: v_mad_f32 v4, -v5, v2, v4
5038 ; GFX6-NEXT: s_or_b32 s2, s0, 1
5039 ; GFX6-NEXT: v_cvt_i32_f32_e32 v5, v5
5040 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[0:1], |v4|, |v2|
5041 ; GFX6-NEXT: v_cvt_f32_i32_e32 v2, v1
5042 ; GFX6-NEXT: v_alignbit_b32 v0, s11, v0, 30
5043 ; GFX6-NEXT: s_and_b64 s[0:1], s[0:1], exec
5044 ; GFX6-NEXT: s_cselect_b32 s0, s2, 0
5045 ; GFX6-NEXT: v_bfe_i32 v0, v0, 0, 15
5046 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, s0, v5
5047 ; GFX6-NEXT: v_cvt_f32_i32_e32 v5, v0
5048 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v2
5049 ; GFX6-NEXT: v_xor_b32_e32 v0, v0, v1
5050 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 30, v0
5051 ; GFX6-NEXT: v_or_b32_e32 v0, 1, v0
5052 ; GFX6-NEXT: v_mul_f32_e32 v1, v5, v6
5053 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
5054 ; GFX6-NEXT: v_mad_f32 v5, -v1, v2, v5
5055 ; GFX6-NEXT: v_cvt_i32_f32_e32 v1, v1
5056 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v5|, |v2|
5057 ; GFX6-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
5058 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v3
5059 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
5060 ; GFX6-NEXT: v_and_b32_e32 v3, 0x7fff, v4
5061 ; GFX6-NEXT: v_lshl_b64 v[0:1], v[0:1], 30
5062 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 15, v3
5063 ; GFX6-NEXT: v_or_b32_e32 v2, v3, v2
5064 ; GFX6-NEXT: s_mov_b32 s4, s8
5065 ; GFX6-NEXT: s_mov_b32 s5, s9
5066 ; GFX6-NEXT: v_or_b32_e32 v0, v2, v0
5067 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5068 ; GFX6-NEXT: s_waitcnt expcnt(0)
5069 ; GFX6-NEXT: v_and_b32_e32 v0, 0x1fff, v1
5070 ; GFX6-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:4
5071 ; GFX6-NEXT: s_endpgm
5073 ; GFX9-LABEL: sdiv_v3i15:
5075 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5076 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x34
5077 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5078 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5079 ; GFX9-NEXT: v_mov_b32_e32 v0, s6
5080 ; GFX9-NEXT: s_bfe_i32 s2, s0, 0xf0000
5081 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s2
5082 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
5083 ; GFX9-NEXT: v_alignbit_b32 v1, s1, v1, 30
5084 ; GFX9-NEXT: s_bfe_i32 s1, s6, 0xf0000
5085 ; GFX9-NEXT: v_cvt_f32_i32_e32 v4, s1
5086 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v5, v3
5087 ; GFX9-NEXT: s_xor_b32 s1, s1, s2
5088 ; GFX9-NEXT: s_ashr_i32 s1, s1, 30
5089 ; GFX9-NEXT: s_or_b32 s1, s1, 1
5090 ; GFX9-NEXT: v_mul_f32_e32 v5, v4, v5
5091 ; GFX9-NEXT: v_trunc_f32_e32 v5, v5
5092 ; GFX9-NEXT: v_mad_f32 v4, -v5, v3, v4
5093 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v4|, |v3|
5094 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
5095 ; GFX9-NEXT: v_cvt_i32_f32_e32 v5, v5
5096 ; GFX9-NEXT: s_cselect_b32 s1, s1, 0
5097 ; GFX9-NEXT: s_bfe_i32 s0, s0, 0xf000f
5098 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, s0
5099 ; GFX9-NEXT: v_add_u32_e32 v4, s1, v5
5100 ; GFX9-NEXT: s_bfe_i32 s1, s6, 0xf000f
5101 ; GFX9-NEXT: v_cvt_f32_i32_e32 v5, s1
5102 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v6, v3
5103 ; GFX9-NEXT: s_xor_b32 s0, s1, s0
5104 ; GFX9-NEXT: s_ashr_i32 s0, s0, 30
5105 ; GFX9-NEXT: v_bfe_i32 v1, v1, 0, 15
5106 ; GFX9-NEXT: v_mul_f32_e32 v6, v5, v6
5107 ; GFX9-NEXT: v_trunc_f32_e32 v6, v6
5108 ; GFX9-NEXT: v_mad_f32 v5, -v6, v3, v5
5109 ; GFX9-NEXT: s_or_b32 s2, s0, 1
5110 ; GFX9-NEXT: v_cvt_i32_f32_e32 v6, v6
5111 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[0:1], |v5|, |v3|
5112 ; GFX9-NEXT: v_cvt_f32_i32_e32 v3, v1
5113 ; GFX9-NEXT: v_alignbit_b32 v0, s7, v0, 30
5114 ; GFX9-NEXT: s_and_b64 s[0:1], s[0:1], exec
5115 ; GFX9-NEXT: s_cselect_b32 s0, s2, 0
5116 ; GFX9-NEXT: v_bfe_i32 v0, v0, 0, 15
5117 ; GFX9-NEXT: v_add_u32_e32 v5, s0, v6
5118 ; GFX9-NEXT: v_cvt_f32_i32_e32 v6, v0
5119 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v3
5120 ; GFX9-NEXT: v_xor_b32_e32 v0, v0, v1
5121 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 30, v0
5122 ; GFX9-NEXT: v_or_b32_e32 v0, 1, v0
5123 ; GFX9-NEXT: v_mul_f32_e32 v1, v6, v7
5124 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
5125 ; GFX9-NEXT: v_cvt_i32_f32_e32 v7, v1
5126 ; GFX9-NEXT: v_mad_f32 v1, -v1, v3, v6
5127 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, |v3|
5128 ; GFX9-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
5129 ; GFX9-NEXT: v_add_u32_e32 v0, v7, v0
5130 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v4
5131 ; GFX9-NEXT: v_and_b32_e32 v4, 0x7fff, v5
5132 ; GFX9-NEXT: v_lshlrev_b64 v[0:1], 30, v[0:1]
5133 ; GFX9-NEXT: v_lshlrev_b32_e32 v4, 15, v4
5134 ; GFX9-NEXT: v_or_b32_e32 v3, v3, v4
5135 ; GFX9-NEXT: v_or_b32_e32 v0, v3, v0
5136 ; GFX9-NEXT: global_store_dword v2, v0, s[4:5]
5137 ; GFX9-NEXT: v_and_b32_e32 v0, 0x1fff, v1
5138 ; GFX9-NEXT: global_store_short v2, v0, s[4:5] offset:4
5139 ; GFX9-NEXT: s_endpgm
5140 %r = sdiv <3 x i15> %x, %y
5141 store <3 x i15> %r, ptr addrspace(1) %out
5145 define amdgpu_kernel void @srem_v3i15(ptr addrspace(1) %out, <3 x i15> %x, <3 x i15> %y) {
5146 ; CHECK-LABEL: @srem_v3i15(
5147 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <3 x i15> [[X:%.*]], i64 0
5148 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <3 x i15> [[Y:%.*]], i64 0
5149 ; CHECK-NEXT: [[TMP3:%.*]] = sext i15 [[TMP1]] to i32
5150 ; CHECK-NEXT: [[TMP4:%.*]] = sext i15 [[TMP2]] to i32
5151 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
5152 ; CHECK-NEXT: [[TMP6:%.*]] = ashr i32 [[TMP5]], 30
5153 ; CHECK-NEXT: [[TMP7:%.*]] = or i32 [[TMP6]], 1
5154 ; CHECK-NEXT: [[TMP8:%.*]] = sitofp i32 [[TMP3]] to float
5155 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp i32 [[TMP4]] to float
5156 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
5157 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP8]], [[TMP10]]
5158 ; CHECK-NEXT: [[TMP12:%.*]] = call fast float @llvm.trunc.f32(float [[TMP11]])
5159 ; CHECK-NEXT: [[TMP13:%.*]] = fneg fast float [[TMP12]]
5160 ; CHECK-NEXT: [[TMP14:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP13]], float [[TMP9]], float [[TMP8]])
5161 ; CHECK-NEXT: [[TMP15:%.*]] = fptosi float [[TMP12]] to i32
5162 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.fabs.f32(float [[TMP14]])
5163 ; CHECK-NEXT: [[TMP17:%.*]] = call fast float @llvm.fabs.f32(float [[TMP9]])
5164 ; CHECK-NEXT: [[TMP18:%.*]] = fcmp fast oge float [[TMP16]], [[TMP17]]
5165 ; CHECK-NEXT: [[TMP19:%.*]] = select i1 [[TMP18]], i32 [[TMP7]], i32 0
5166 ; CHECK-NEXT: [[TMP20:%.*]] = add i32 [[TMP15]], [[TMP19]]
5167 ; CHECK-NEXT: [[TMP21:%.*]] = mul i32 [[TMP20]], [[TMP4]]
5168 ; CHECK-NEXT: [[TMP22:%.*]] = sub i32 [[TMP3]], [[TMP21]]
5169 ; CHECK-NEXT: [[TMP23:%.*]] = shl i32 [[TMP22]], 17
5170 ; CHECK-NEXT: [[TMP24:%.*]] = ashr i32 [[TMP23]], 17
5171 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i32 [[TMP24]] to i15
5172 ; CHECK-NEXT: [[TMP26:%.*]] = insertelement <3 x i15> poison, i15 [[TMP25]], i64 0
5173 ; CHECK-NEXT: [[TMP27:%.*]] = extractelement <3 x i15> [[X]], i64 1
5174 ; CHECK-NEXT: [[TMP28:%.*]] = extractelement <3 x i15> [[Y]], i64 1
5175 ; CHECK-NEXT: [[TMP29:%.*]] = sext i15 [[TMP27]] to i32
5176 ; CHECK-NEXT: [[TMP30:%.*]] = sext i15 [[TMP28]] to i32
5177 ; CHECK-NEXT: [[TMP31:%.*]] = xor i32 [[TMP29]], [[TMP30]]
5178 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i32 [[TMP31]], 30
5179 ; CHECK-NEXT: [[TMP33:%.*]] = or i32 [[TMP32]], 1
5180 ; CHECK-NEXT: [[TMP34:%.*]] = sitofp i32 [[TMP29]] to float
5181 ; CHECK-NEXT: [[TMP35:%.*]] = sitofp i32 [[TMP30]] to float
5182 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP35]])
5183 ; CHECK-NEXT: [[TMP37:%.*]] = fmul fast float [[TMP34]], [[TMP36]]
5184 ; CHECK-NEXT: [[TMP38:%.*]] = call fast float @llvm.trunc.f32(float [[TMP37]])
5185 ; CHECK-NEXT: [[TMP39:%.*]] = fneg fast float [[TMP38]]
5186 ; CHECK-NEXT: [[TMP40:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP39]], float [[TMP35]], float [[TMP34]])
5187 ; CHECK-NEXT: [[TMP41:%.*]] = fptosi float [[TMP38]] to i32
5188 ; CHECK-NEXT: [[TMP42:%.*]] = call fast float @llvm.fabs.f32(float [[TMP40]])
5189 ; CHECK-NEXT: [[TMP43:%.*]] = call fast float @llvm.fabs.f32(float [[TMP35]])
5190 ; CHECK-NEXT: [[TMP44:%.*]] = fcmp fast oge float [[TMP42]], [[TMP43]]
5191 ; CHECK-NEXT: [[TMP45:%.*]] = select i1 [[TMP44]], i32 [[TMP33]], i32 0
5192 ; CHECK-NEXT: [[TMP46:%.*]] = add i32 [[TMP41]], [[TMP45]]
5193 ; CHECK-NEXT: [[TMP47:%.*]] = mul i32 [[TMP46]], [[TMP30]]
5194 ; CHECK-NEXT: [[TMP48:%.*]] = sub i32 [[TMP29]], [[TMP47]]
5195 ; CHECK-NEXT: [[TMP49:%.*]] = shl i32 [[TMP48]], 17
5196 ; CHECK-NEXT: [[TMP50:%.*]] = ashr i32 [[TMP49]], 17
5197 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i32 [[TMP50]] to i15
5198 ; CHECK-NEXT: [[TMP52:%.*]] = insertelement <3 x i15> [[TMP26]], i15 [[TMP51]], i64 1
5199 ; CHECK-NEXT: [[TMP53:%.*]] = extractelement <3 x i15> [[X]], i64 2
5200 ; CHECK-NEXT: [[TMP54:%.*]] = extractelement <3 x i15> [[Y]], i64 2
5201 ; CHECK-NEXT: [[TMP55:%.*]] = sext i15 [[TMP53]] to i32
5202 ; CHECK-NEXT: [[TMP56:%.*]] = sext i15 [[TMP54]] to i32
5203 ; CHECK-NEXT: [[TMP57:%.*]] = xor i32 [[TMP55]], [[TMP56]]
5204 ; CHECK-NEXT: [[TMP58:%.*]] = ashr i32 [[TMP57]], 30
5205 ; CHECK-NEXT: [[TMP59:%.*]] = or i32 [[TMP58]], 1
5206 ; CHECK-NEXT: [[TMP60:%.*]] = sitofp i32 [[TMP55]] to float
5207 ; CHECK-NEXT: [[TMP61:%.*]] = sitofp i32 [[TMP56]] to float
5208 ; CHECK-NEXT: [[TMP62:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP61]])
5209 ; CHECK-NEXT: [[TMP63:%.*]] = fmul fast float [[TMP60]], [[TMP62]]
5210 ; CHECK-NEXT: [[TMP64:%.*]] = call fast float @llvm.trunc.f32(float [[TMP63]])
5211 ; CHECK-NEXT: [[TMP65:%.*]] = fneg fast float [[TMP64]]
5212 ; CHECK-NEXT: [[TMP66:%.*]] = call fast float @llvm.amdgcn.fmad.ftz.f32(float [[TMP65]], float [[TMP61]], float [[TMP60]])
5213 ; CHECK-NEXT: [[TMP67:%.*]] = fptosi float [[TMP64]] to i32
5214 ; CHECK-NEXT: [[TMP68:%.*]] = call fast float @llvm.fabs.f32(float [[TMP66]])
5215 ; CHECK-NEXT: [[TMP69:%.*]] = call fast float @llvm.fabs.f32(float [[TMP61]])
5216 ; CHECK-NEXT: [[TMP70:%.*]] = fcmp fast oge float [[TMP68]], [[TMP69]]
5217 ; CHECK-NEXT: [[TMP71:%.*]] = select i1 [[TMP70]], i32 [[TMP59]], i32 0
5218 ; CHECK-NEXT: [[TMP72:%.*]] = add i32 [[TMP67]], [[TMP71]]
5219 ; CHECK-NEXT: [[TMP73:%.*]] = mul i32 [[TMP72]], [[TMP56]]
5220 ; CHECK-NEXT: [[TMP74:%.*]] = sub i32 [[TMP55]], [[TMP73]]
5221 ; CHECK-NEXT: [[TMP75:%.*]] = shl i32 [[TMP74]], 17
5222 ; CHECK-NEXT: [[TMP76:%.*]] = ashr i32 [[TMP75]], 17
5223 ; CHECK-NEXT: [[TMP77:%.*]] = trunc i32 [[TMP76]] to i15
5224 ; CHECK-NEXT: [[TMP78:%.*]] = insertelement <3 x i15> [[TMP52]], i15 [[TMP77]], i64 2
5225 ; CHECK-NEXT: store <3 x i15> [[TMP78]], ptr addrspace(1) [[OUT:%.*]], align 8
5226 ; CHECK-NEXT: ret void
5228 ; GFX6-LABEL: srem_v3i15:
5230 ; GFX6-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
5231 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0xd
5232 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5233 ; GFX6-NEXT: s_mov_b32 s6, -1
5234 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5235 ; GFX6-NEXT: s_bfe_i32 s2, s10, 0xf0000
5236 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
5237 ; GFX6-NEXT: v_alignbit_b32 v2, s1, v2, 30
5238 ; GFX6-NEXT: s_bfe_i32 s1, s0, 0xf0000
5239 ; GFX6-NEXT: v_cvt_f32_i32_e32 v4, s1
5240 ; GFX6-NEXT: v_cvt_f32_i32_e32 v5, s2
5241 ; GFX6-NEXT: s_xor_b32 s1, s2, s1
5242 ; GFX6-NEXT: s_ashr_i32 s1, s1, 30
5243 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v6, v4
5244 ; GFX6-NEXT: s_mov_b32 s4, s8
5245 ; GFX6-NEXT: s_mov_b32 s5, s9
5246 ; GFX6-NEXT: s_lshr_b32 s8, s10, 15
5247 ; GFX6-NEXT: v_mul_f32_e32 v6, v5, v6
5248 ; GFX6-NEXT: v_trunc_f32_e32 v6, v6
5249 ; GFX6-NEXT: v_mad_f32 v5, -v6, v4, v5
5250 ; GFX6-NEXT: v_cvt_i32_f32_e32 v6, v6
5251 ; GFX6-NEXT: s_lshr_b32 s9, s0, 15
5252 ; GFX6-NEXT: s_or_b32 s1, s1, 1
5253 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[2:3], |v5|, |v4|
5254 ; GFX6-NEXT: s_and_b64 s[2:3], s[2:3], exec
5255 ; GFX6-NEXT: s_cselect_b32 s1, s1, 0
5256 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, s1, v6
5257 ; GFX6-NEXT: v_mul_lo_u32 v4, v4, s0
5258 ; GFX6-NEXT: s_bfe_i32 s0, s0, 0xf000f
5259 ; GFX6-NEXT: v_cvt_f32_i32_e32 v5, s0
5260 ; GFX6-NEXT: s_bfe_i32 s1, s10, 0xf000f
5261 ; GFX6-NEXT: v_cvt_f32_i32_e32 v6, s1
5262 ; GFX6-NEXT: s_xor_b32 s0, s1, s0
5263 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v7, v5
5264 ; GFX6-NEXT: v_and_b32_e32 v3, 0x7fff, v2
5265 ; GFX6-NEXT: s_ashr_i32 s0, s0, 30
5266 ; GFX6-NEXT: v_bfe_i32 v2, v2, 0, 15
5267 ; GFX6-NEXT: v_mul_f32_e32 v7, v6, v7
5268 ; GFX6-NEXT: v_trunc_f32_e32 v7, v7
5269 ; GFX6-NEXT: v_mad_f32 v6, -v7, v5, v6
5270 ; GFX6-NEXT: s_or_b32 s2, s0, 1
5271 ; GFX6-NEXT: v_cvt_i32_f32_e32 v7, v7
5272 ; GFX6-NEXT: v_cmp_ge_f32_e64 s[0:1], |v6|, |v5|
5273 ; GFX6-NEXT: v_cvt_f32_i32_e32 v6, v2
5274 ; GFX6-NEXT: v_mov_b32_e32 v0, s10
5275 ; GFX6-NEXT: v_alignbit_b32 v0, s11, v0, 30
5276 ; GFX6-NEXT: s_and_b64 s[0:1], s[0:1], exec
5277 ; GFX6-NEXT: v_and_b32_e32 v1, 0x7fff, v0
5278 ; GFX6-NEXT: s_cselect_b32 s0, s2, 0
5279 ; GFX6-NEXT: v_bfe_i32 v0, v0, 0, 15
5280 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, s0, v7
5281 ; GFX6-NEXT: v_cvt_f32_i32_e32 v7, v0
5282 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v8, v6
5283 ; GFX6-NEXT: v_xor_b32_e32 v0, v0, v2
5284 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s10, v4
5285 ; GFX6-NEXT: v_mul_f32_e32 v2, v7, v8
5286 ; GFX6-NEXT: v_trunc_f32_e32 v2, v2
5287 ; GFX6-NEXT: v_mad_f32 v7, -v2, v6, v7
5288 ; GFX6-NEXT: v_cvt_i32_f32_e32 v2, v2
5289 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 30, v0
5290 ; GFX6-NEXT: v_or_b32_e32 v0, 1, v0
5291 ; GFX6-NEXT: v_cmp_ge_f32_e64 vcc, |v7|, |v6|
5292 ; GFX6-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc
5293 ; GFX6-NEXT: v_mul_lo_u32 v5, v5, s9
5294 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
5295 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, v3
5296 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s8, v5
5297 ; GFX6-NEXT: v_and_b32_e32 v2, 0x7fff, v2
5298 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v1, v0
5299 ; GFX6-NEXT: v_lshl_b64 v[0:1], v[0:1], 30
5300 ; GFX6-NEXT: v_and_b32_e32 v3, 0x7fff, v4
5301 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 15, v2
5302 ; GFX6-NEXT: v_or_b32_e32 v2, v2, v3
5303 ; GFX6-NEXT: v_or_b32_e32 v0, v2, v0
5304 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5305 ; GFX6-NEXT: s_waitcnt expcnt(0)
5306 ; GFX6-NEXT: v_and_b32_e32 v0, 0x1fff, v1
5307 ; GFX6-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:4
5308 ; GFX6-NEXT: s_endpgm
5310 ; GFX9-LABEL: srem_v3i15:
5312 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5313 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x34
5314 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5315 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5316 ; GFX9-NEXT: s_bfe_i32 s2, s6, 0xf0000
5317 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
5318 ; GFX9-NEXT: v_alignbit_b32 v1, s1, v1, 30
5319 ; GFX9-NEXT: s_bfe_i32 s1, s0, 0xf0000
5320 ; GFX9-NEXT: v_cvt_f32_i32_e32 v4, s1
5321 ; GFX9-NEXT: v_cvt_f32_i32_e32 v5, s2
5322 ; GFX9-NEXT: s_xor_b32 s1, s2, s1
5323 ; GFX9-NEXT: v_mov_b32_e32 v0, s6
5324 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v6, v4
5325 ; GFX9-NEXT: s_ashr_i32 s1, s1, 30
5326 ; GFX9-NEXT: s_lshr_b32 s8, s6, 15
5327 ; GFX9-NEXT: v_alignbit_b32 v0, s7, v0, 30
5328 ; GFX9-NEXT: v_mul_f32_e32 v6, v5, v6
5329 ; GFX9-NEXT: v_trunc_f32_e32 v6, v6
5330 ; GFX9-NEXT: v_mad_f32 v5, -v6, v4, v5
5331 ; GFX9-NEXT: v_cvt_i32_f32_e32 v6, v6
5332 ; GFX9-NEXT: s_lshr_b32 s7, s0, 15
5333 ; GFX9-NEXT: s_or_b32 s1, s1, 1
5334 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[2:3], |v5|, |v4|
5335 ; GFX9-NEXT: s_and_b64 s[2:3], s[2:3], exec
5336 ; GFX9-NEXT: s_cselect_b32 s1, s1, 0
5337 ; GFX9-NEXT: v_add_u32_e32 v4, s1, v6
5338 ; GFX9-NEXT: s_bfe_i32 s1, s0, 0xf000f
5339 ; GFX9-NEXT: v_cvt_f32_i32_e32 v5, s1
5340 ; GFX9-NEXT: v_mul_lo_u32 v4, v4, s0
5341 ; GFX9-NEXT: s_bfe_i32 s0, s6, 0xf000f
5342 ; GFX9-NEXT: v_cvt_f32_i32_e32 v6, s0
5343 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v7, v5
5344 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
5345 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v1
5346 ; GFX9-NEXT: s_ashr_i32 s0, s0, 30
5347 ; GFX9-NEXT: v_mul_f32_e32 v7, v6, v7
5348 ; GFX9-NEXT: v_trunc_f32_e32 v7, v7
5349 ; GFX9-NEXT: v_mad_f32 v6, -v7, v5, v6
5350 ; GFX9-NEXT: v_cvt_i32_f32_e32 v7, v7
5351 ; GFX9-NEXT: v_bfe_i32 v1, v1, 0, 15
5352 ; GFX9-NEXT: s_or_b32 s2, s0, 1
5353 ; GFX9-NEXT: v_cmp_ge_f32_e64 s[0:1], |v6|, |v5|
5354 ; GFX9-NEXT: v_cvt_f32_i32_e32 v6, v1
5355 ; GFX9-NEXT: s_and_b64 s[0:1], s[0:1], exec
5356 ; GFX9-NEXT: s_cselect_b32 s0, s2, 0
5357 ; GFX9-NEXT: v_add_u32_e32 v5, s0, v7
5358 ; GFX9-NEXT: v_bfe_i32 v7, v0, 0, 15
5359 ; GFX9-NEXT: v_cvt_f32_i32_e32 v8, v7
5360 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v9, v6
5361 ; GFX9-NEXT: v_xor_b32_e32 v1, v7, v1
5362 ; GFX9-NEXT: v_ashrrev_i32_e32 v1, 30, v1
5363 ; GFX9-NEXT: v_or_b32_e32 v1, 1, v1
5364 ; GFX9-NEXT: v_mul_f32_e32 v7, v8, v9
5365 ; GFX9-NEXT: v_trunc_f32_e32 v7, v7
5366 ; GFX9-NEXT: v_cvt_i32_f32_e32 v9, v7
5367 ; GFX9-NEXT: v_mad_f32 v7, -v7, v6, v8
5368 ; GFX9-NEXT: v_cmp_ge_f32_e64 vcc, |v7|, |v6|
5369 ; GFX9-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
5370 ; GFX9-NEXT: v_mul_lo_u32 v5, v5, s7
5371 ; GFX9-NEXT: v_add_u32_e32 v1, v9, v1
5372 ; GFX9-NEXT: v_mul_lo_u32 v1, v1, v3
5373 ; GFX9-NEXT: v_and_b32_e32 v0, 0x7fff, v0
5374 ; GFX9-NEXT: v_sub_u32_e32 v3, s6, v4
5375 ; GFX9-NEXT: v_sub_u32_e32 v4, s8, v5
5376 ; GFX9-NEXT: v_sub_u32_e32 v0, v0, v1
5377 ; GFX9-NEXT: v_and_b32_e32 v4, 0x7fff, v4
5378 ; GFX9-NEXT: v_lshlrev_b64 v[0:1], 30, v[0:1]
5379 ; GFX9-NEXT: v_and_b32_e32 v3, 0x7fff, v3
5380 ; GFX9-NEXT: v_lshlrev_b32_e32 v4, 15, v4
5381 ; GFX9-NEXT: v_or_b32_e32 v3, v3, v4
5382 ; GFX9-NEXT: v_or_b32_e32 v0, v3, v0
5383 ; GFX9-NEXT: global_store_dword v2, v0, s[4:5]
5384 ; GFX9-NEXT: v_and_b32_e32 v0, 0x1fff, v1
5385 ; GFX9-NEXT: global_store_short v2, v0, s[4:5] offset:4
5386 ; GFX9-NEXT: s_endpgm
5387 %r = srem <3 x i15> %x, %y
5388 store <3 x i15> %r, ptr addrspace(1) %out
5392 define amdgpu_kernel void @udiv_i32_oddk_denom(ptr addrspace(1) %out, i32 %x) {
5393 ; CHECK-LABEL: @udiv_i32_oddk_denom(
5394 ; CHECK-NEXT: [[R:%.*]] = udiv i32 [[X:%.*]], 1235195
5395 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5396 ; CHECK-NEXT: ret void
5398 ; GFX6-LABEL: udiv_i32_oddk_denom:
5400 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
5401 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
5402 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xb2a50881
5403 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
5404 ; GFX6-NEXT: s_mov_b32 s2, -1
5405 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5406 ; GFX6-NEXT: v_mul_hi_u32 v0, s4, v0
5407 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s4, v0
5408 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 1, v1
5409 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
5410 ; GFX6-NEXT: v_lshrrev_b32_e32 v0, 20, v0
5411 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5412 ; GFX6-NEXT: s_endpgm
5414 ; GFX9-LABEL: udiv_i32_oddk_denom:
5416 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
5417 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
5418 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5419 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5420 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, 0xb2a50881
5421 ; GFX9-NEXT: s_sub_i32 s3, s4, s2
5422 ; GFX9-NEXT: s_lshr_b32 s3, s3, 1
5423 ; GFX9-NEXT: s_add_i32 s3, s3, s2
5424 ; GFX9-NEXT: s_lshr_b32 s2, s3, 20
5425 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
5426 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
5427 ; GFX9-NEXT: s_endpgm
5428 %r = udiv i32 %x, 1235195
5429 store i32 %r, ptr addrspace(1) %out
5433 define amdgpu_kernel void @udiv_i32_pow2k_denom(ptr addrspace(1) %out, i32 %x) {
5434 ; CHECK-LABEL: @udiv_i32_pow2k_denom(
5435 ; CHECK-NEXT: [[R:%.*]] = udiv i32 [[X:%.*]], 4096
5436 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5437 ; CHECK-NEXT: ret void
5439 ; GFX6-LABEL: udiv_i32_pow2k_denom:
5441 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
5442 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
5443 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
5444 ; GFX6-NEXT: s_mov_b32 s2, -1
5445 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5446 ; GFX6-NEXT: s_lshr_b32 s4, s4, 12
5447 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5448 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5449 ; GFX6-NEXT: s_endpgm
5451 ; GFX9-LABEL: udiv_i32_pow2k_denom:
5453 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
5454 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
5455 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5456 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5457 ; GFX9-NEXT: s_lshr_b32 s2, s4, 12
5458 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
5459 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
5460 ; GFX9-NEXT: s_endpgm
5461 %r = udiv i32 %x, 4096
5462 store i32 %r, ptr addrspace(1) %out
5466 define amdgpu_kernel void @udiv_i32_pow2_shl_denom(ptr addrspace(1) %out, i32 %x, i32 %y) {
5467 ; CHECK-LABEL: @udiv_i32_pow2_shl_denom(
5468 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 4096, [[Y:%.*]]
5469 ; CHECK-NEXT: [[R:%.*]] = udiv i32 [[X:%.*]], [[SHL_Y]]
5470 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5471 ; CHECK-NEXT: ret void
5473 ; GFX6-LABEL: udiv_i32_pow2_shl_denom:
5475 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
5476 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5477 ; GFX6-NEXT: s_mov_b32 s6, -1
5478 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5479 ; GFX6-NEXT: s_mov_b32 s4, s0
5480 ; GFX6-NEXT: s_add_i32 s0, s3, 12
5481 ; GFX6-NEXT: s_lshr_b32 s0, s2, s0
5482 ; GFX6-NEXT: s_mov_b32 s5, s1
5483 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
5484 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5485 ; GFX6-NEXT: s_endpgm
5487 ; GFX9-LABEL: udiv_i32_pow2_shl_denom:
5489 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5490 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5491 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5492 ; GFX9-NEXT: s_add_i32 s0, s7, 12
5493 ; GFX9-NEXT: s_lshr_b32 s0, s6, s0
5494 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
5495 ; GFX9-NEXT: global_store_dword v0, v1, s[4:5]
5496 ; GFX9-NEXT: s_endpgm
5497 %shl.y = shl i32 4096, %y
5498 %r = udiv i32 %x, %shl.y
5499 store i32 %r, ptr addrspace(1) %out
5503 define amdgpu_kernel void @udiv_v2i32_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
5504 ; CHECK-LABEL: @udiv_v2i32_pow2k_denom(
5505 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
5506 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i32 [[TMP1]], 4096
5507 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
5508 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
5509 ; CHECK-NEXT: [[TMP5:%.*]] = udiv i32 [[TMP4]], 4096
5510 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
5511 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
5512 ; CHECK-NEXT: ret void
5514 ; GFX6-LABEL: udiv_v2i32_pow2k_denom:
5516 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
5517 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5518 ; GFX6-NEXT: s_mov_b32 s6, -1
5519 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5520 ; GFX6-NEXT: s_mov_b32 s4, s0
5521 ; GFX6-NEXT: s_mov_b32 s5, s1
5522 ; GFX6-NEXT: s_lshr_b32 s0, s2, 12
5523 ; GFX6-NEXT: s_lshr_b32 s1, s3, 12
5524 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
5525 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
5526 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
5527 ; GFX6-NEXT: s_endpgm
5529 ; GFX9-LABEL: udiv_v2i32_pow2k_denom:
5531 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5532 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5533 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5534 ; GFX9-NEXT: s_lshr_b32 s0, s6, 12
5535 ; GFX9-NEXT: s_lshr_b32 s1, s7, 12
5536 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
5537 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
5538 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
5539 ; GFX9-NEXT: s_endpgm
5540 %r = udiv <2 x i32> %x, <i32 4096, i32 4096>
5541 store <2 x i32> %r, ptr addrspace(1) %out
5545 define amdgpu_kernel void @udiv_v2i32_mixed_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
5546 ; CHECK-LABEL: @udiv_v2i32_mixed_pow2k_denom(
5547 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
5548 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i32 [[TMP1]], 4096
5549 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
5550 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
5551 ; CHECK-NEXT: [[TMP5:%.*]] = udiv i32 [[TMP4]], 4095
5552 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
5553 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
5554 ; CHECK-NEXT: ret void
5556 ; GFX6-LABEL: udiv_v2i32_mixed_pow2k_denom:
5558 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
5559 ; GFX6-NEXT: v_mov_b32_e32 v0, 0x100101
5560 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5561 ; GFX6-NEXT: s_mov_b32 s6, -1
5562 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5563 ; GFX6-NEXT: v_mul_hi_u32 v0, s3, v0
5564 ; GFX6-NEXT: s_mov_b32 s4, s0
5565 ; GFX6-NEXT: s_lshr_b32 s0, s2, 12
5566 ; GFX6-NEXT: s_mov_b32 s5, s1
5567 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s3, v0
5568 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 1, v1
5569 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
5570 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 11, v0
5571 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
5572 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
5573 ; GFX6-NEXT: s_endpgm
5575 ; GFX9-LABEL: udiv_v2i32_mixed_pow2k_denom:
5577 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5578 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5579 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5580 ; GFX9-NEXT: s_mul_hi_u32 s1, s7, 0x100101
5581 ; GFX9-NEXT: s_sub_i32 s2, s7, s1
5582 ; GFX9-NEXT: s_lshr_b32 s2, s2, 1
5583 ; GFX9-NEXT: s_add_i32 s2, s2, s1
5584 ; GFX9-NEXT: s_lshr_b32 s0, s6, 12
5585 ; GFX9-NEXT: s_lshr_b32 s1, s2, 11
5586 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
5587 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
5588 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
5589 ; GFX9-NEXT: s_endpgm
5590 %r = udiv <2 x i32> %x, <i32 4096, i32 4095>
5591 store <2 x i32> %r, ptr addrspace(1) %out
5595 define amdgpu_kernel void @udiv_v2i32_pow2_shl_denom(ptr addrspace(1) %out, <2 x i32> %x, <2 x i32> %y) {
5596 ; CHECK-LABEL: @udiv_v2i32_pow2_shl_denom(
5597 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i32> <i32 4096, i32 4096>, [[Y:%.*]]
5598 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
5599 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 0
5600 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP2]] to float
5601 ; CHECK-NEXT: [[TMP4:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP3]])
5602 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast float [[TMP4]], 0x41EFFFFFC0000000
5603 ; CHECK-NEXT: [[TMP6:%.*]] = fptoui float [[TMP5]] to i32
5604 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 0, [[TMP2]]
5605 ; CHECK-NEXT: [[TMP8:%.*]] = mul i32 [[TMP7]], [[TMP6]]
5606 ; CHECK-NEXT: [[TMP9:%.*]] = zext i32 [[TMP6]] to i64
5607 ; CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP8]] to i64
5608 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP9]], [[TMP10]]
5609 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
5610 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i64 [[TMP11]], 32
5611 ; CHECK-NEXT: [[TMP14:%.*]] = trunc i64 [[TMP13]] to i32
5612 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP6]], [[TMP14]]
5613 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP1]] to i64
5614 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
5615 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
5616 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
5617 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
5618 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
5619 ; CHECK-NEXT: [[TMP22:%.*]] = mul i32 [[TMP21]], [[TMP2]]
5620 ; CHECK-NEXT: [[TMP23:%.*]] = sub i32 [[TMP1]], [[TMP22]]
5621 ; CHECK-NEXT: [[TMP24:%.*]] = icmp uge i32 [[TMP23]], [[TMP2]]
5622 ; CHECK-NEXT: [[TMP25:%.*]] = add i32 [[TMP21]], 1
5623 ; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP24]], i32 [[TMP25]], i32 [[TMP21]]
5624 ; CHECK-NEXT: [[TMP27:%.*]] = sub i32 [[TMP23]], [[TMP2]]
5625 ; CHECK-NEXT: [[TMP28:%.*]] = select i1 [[TMP24]], i32 [[TMP27]], i32 [[TMP23]]
5626 ; CHECK-NEXT: [[TMP29:%.*]] = icmp uge i32 [[TMP28]], [[TMP2]]
5627 ; CHECK-NEXT: [[TMP30:%.*]] = add i32 [[TMP26]], 1
5628 ; CHECK-NEXT: [[TMP31:%.*]] = select i1 [[TMP29]], i32 [[TMP30]], i32 [[TMP26]]
5629 ; CHECK-NEXT: [[TMP32:%.*]] = insertelement <2 x i32> poison, i32 [[TMP31]], i64 0
5630 ; CHECK-NEXT: [[TMP33:%.*]] = extractelement <2 x i32> [[X]], i64 1
5631 ; CHECK-NEXT: [[TMP34:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 1
5632 ; CHECK-NEXT: [[TMP35:%.*]] = uitofp i32 [[TMP34]] to float
5633 ; CHECK-NEXT: [[TMP36:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP35]])
5634 ; CHECK-NEXT: [[TMP37:%.*]] = fmul fast float [[TMP36]], 0x41EFFFFFC0000000
5635 ; CHECK-NEXT: [[TMP38:%.*]] = fptoui float [[TMP37]] to i32
5636 ; CHECK-NEXT: [[TMP39:%.*]] = sub i32 0, [[TMP34]]
5637 ; CHECK-NEXT: [[TMP40:%.*]] = mul i32 [[TMP39]], [[TMP38]]
5638 ; CHECK-NEXT: [[TMP41:%.*]] = zext i32 [[TMP38]] to i64
5639 ; CHECK-NEXT: [[TMP42:%.*]] = zext i32 [[TMP40]] to i64
5640 ; CHECK-NEXT: [[TMP43:%.*]] = mul i64 [[TMP41]], [[TMP42]]
5641 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i64 [[TMP43]] to i32
5642 ; CHECK-NEXT: [[TMP45:%.*]] = lshr i64 [[TMP43]], 32
5643 ; CHECK-NEXT: [[TMP46:%.*]] = trunc i64 [[TMP45]] to i32
5644 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP38]], [[TMP46]]
5645 ; CHECK-NEXT: [[TMP48:%.*]] = zext i32 [[TMP33]] to i64
5646 ; CHECK-NEXT: [[TMP49:%.*]] = zext i32 [[TMP47]] to i64
5647 ; CHECK-NEXT: [[TMP50:%.*]] = mul i64 [[TMP48]], [[TMP49]]
5648 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i64 [[TMP50]] to i32
5649 ; CHECK-NEXT: [[TMP52:%.*]] = lshr i64 [[TMP50]], 32
5650 ; CHECK-NEXT: [[TMP53:%.*]] = trunc i64 [[TMP52]] to i32
5651 ; CHECK-NEXT: [[TMP54:%.*]] = mul i32 [[TMP53]], [[TMP34]]
5652 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 [[TMP33]], [[TMP54]]
5653 ; CHECK-NEXT: [[TMP56:%.*]] = icmp uge i32 [[TMP55]], [[TMP34]]
5654 ; CHECK-NEXT: [[TMP57:%.*]] = add i32 [[TMP53]], 1
5655 ; CHECK-NEXT: [[TMP58:%.*]] = select i1 [[TMP56]], i32 [[TMP57]], i32 [[TMP53]]
5656 ; CHECK-NEXT: [[TMP59:%.*]] = sub i32 [[TMP55]], [[TMP34]]
5657 ; CHECK-NEXT: [[TMP60:%.*]] = select i1 [[TMP56]], i32 [[TMP59]], i32 [[TMP55]]
5658 ; CHECK-NEXT: [[TMP61:%.*]] = icmp uge i32 [[TMP60]], [[TMP34]]
5659 ; CHECK-NEXT: [[TMP62:%.*]] = add i32 [[TMP58]], 1
5660 ; CHECK-NEXT: [[TMP63:%.*]] = select i1 [[TMP61]], i32 [[TMP62]], i32 [[TMP58]]
5661 ; CHECK-NEXT: [[TMP64:%.*]] = insertelement <2 x i32> [[TMP32]], i32 [[TMP63]], i64 1
5662 ; CHECK-NEXT: store <2 x i32> [[TMP64]], ptr addrspace(1) [[OUT:%.*]], align 8
5663 ; CHECK-NEXT: ret void
5665 ; GFX6-LABEL: udiv_v2i32_pow2_shl_denom:
5667 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
5668 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x9
5669 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
5670 ; GFX6-NEXT: s_mov_b32 s10, -1
5671 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5672 ; GFX6-NEXT: s_lshl_b32 s0, 0x1000, s6
5673 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s0
5674 ; GFX6-NEXT: s_sub_i32 s1, 0, s0
5675 ; GFX6-NEXT: s_lshl_b32 s6, 0x1000, s7
5676 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
5677 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
5678 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
5679 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
5680 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
5681 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v0
5682 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
5683 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
5684 ; GFX6-NEXT: v_mul_hi_u32 v0, s4, v0
5685 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
5686 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
5687 ; GFX6-NEXT: v_readfirstlane_b32 s1, v0
5688 ; GFX6-NEXT: s_mul_i32 s1, s1, s0
5689 ; GFX6-NEXT: s_sub_i32 s1, s4, s1
5690 ; GFX6-NEXT: s_sub_i32 s4, s1, s0
5691 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
5692 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
5693 ; GFX6-NEXT: s_cselect_b32 s1, s4, s1
5694 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
5695 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
5696 ; GFX6-NEXT: s_cselect_b64 s[0:1], -1, 0
5697 ; GFX6-NEXT: s_sub_i32 s4, 0, s6
5698 ; GFX6-NEXT: v_mul_lo_u32 v3, s4, v1
5699 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
5700 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
5701 ; GFX6-NEXT: v_mul_hi_u32 v3, v1, v3
5702 ; GFX6-NEXT: v_cndmask_b32_e64 v0, v0, v2, s[0:1]
5703 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v3
5704 ; GFX6-NEXT: v_mul_hi_u32 v1, s5, v1
5705 ; GFX6-NEXT: v_readfirstlane_b32 s0, v1
5706 ; GFX6-NEXT: s_mul_i32 s0, s0, s6
5707 ; GFX6-NEXT: s_sub_i32 s0, s5, s0
5708 ; GFX6-NEXT: s_sub_i32 s1, s0, s6
5709 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v1
5710 ; GFX6-NEXT: s_cmp_ge_u32 s0, s6
5711 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
5712 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
5713 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
5714 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v1
5715 ; GFX6-NEXT: s_cmp_ge_u32 s0, s6
5716 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
5717 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
5718 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[8:11], 0
5719 ; GFX6-NEXT: s_endpgm
5721 ; GFX9-LABEL: udiv_v2i32_pow2_shl_denom:
5723 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
5724 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
5725 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5726 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5727 ; GFX9-NEXT: s_lshl_b32 s6, 0x1000, s6
5728 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s6
5729 ; GFX9-NEXT: s_lshl_b32 s7, 0x1000, s7
5730 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s7
5731 ; GFX9-NEXT: s_sub_i32 s2, 0, s6
5732 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
5733 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v1
5734 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
5735 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
5736 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v1
5737 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
5738 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
5739 ; GFX9-NEXT: s_mul_i32 s2, s2, s3
5740 ; GFX9-NEXT: s_mul_hi_u32 s2, s3, s2
5741 ; GFX9-NEXT: s_add_i32 s3, s3, s2
5742 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, s3
5743 ; GFX9-NEXT: s_mul_i32 s3, s2, s6
5744 ; GFX9-NEXT: s_sub_i32 s3, s4, s3
5745 ; GFX9-NEXT: s_add_i32 s9, s2, 1
5746 ; GFX9-NEXT: s_sub_i32 s4, s3, s6
5747 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
5748 ; GFX9-NEXT: s_cselect_b32 s2, s9, s2
5749 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
5750 ; GFX9-NEXT: s_add_i32 s4, s2, 1
5751 ; GFX9-NEXT: s_cmp_ge_u32 s3, s6
5752 ; GFX9-NEXT: v_readfirstlane_b32 s8, v1
5753 ; GFX9-NEXT: s_cselect_b32 s2, s4, s2
5754 ; GFX9-NEXT: s_sub_i32 s3, 0, s7
5755 ; GFX9-NEXT: s_mul_i32 s3, s3, s8
5756 ; GFX9-NEXT: s_mul_hi_u32 s3, s8, s3
5757 ; GFX9-NEXT: s_add_i32 s8, s8, s3
5758 ; GFX9-NEXT: s_mul_hi_u32 s3, s5, s8
5759 ; GFX9-NEXT: s_mul_i32 s4, s3, s7
5760 ; GFX9-NEXT: s_sub_i32 s4, s5, s4
5761 ; GFX9-NEXT: s_add_i32 s6, s3, 1
5762 ; GFX9-NEXT: s_sub_i32 s5, s4, s7
5763 ; GFX9-NEXT: s_cmp_ge_u32 s4, s7
5764 ; GFX9-NEXT: s_cselect_b32 s3, s6, s3
5765 ; GFX9-NEXT: s_cselect_b32 s4, s5, s4
5766 ; GFX9-NEXT: s_add_i32 s5, s3, 1
5767 ; GFX9-NEXT: s_cmp_ge_u32 s4, s7
5768 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
5769 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
5770 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
5771 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
5772 ; GFX9-NEXT: s_endpgm
5773 %shl.y = shl <2 x i32> <i32 4096, i32 4096>, %y
5774 %r = udiv <2 x i32> %x, %shl.y
5775 store <2 x i32> %r, ptr addrspace(1) %out
5779 define amdgpu_kernel void @urem_i32_oddk_denom(ptr addrspace(1) %out, i32 %x) {
5780 ; CHECK-LABEL: @urem_i32_oddk_denom(
5781 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[X:%.*]], 1235195
5782 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5783 ; CHECK-NEXT: ret void
5785 ; GFX6-LABEL: urem_i32_oddk_denom:
5787 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
5788 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
5789 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xb2a50881
5790 ; GFX6-NEXT: s_mov_b32 s2, 0x12d8fb
5791 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
5792 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5793 ; GFX6-NEXT: v_mul_hi_u32 v0, s4, v0
5794 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, s4, v0
5795 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 1, v1
5796 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
5797 ; GFX6-NEXT: v_lshrrev_b32_e32 v0, 20, v0
5798 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s2
5799 ; GFX6-NEXT: s_mov_b32 s2, -1
5800 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
5801 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5802 ; GFX6-NEXT: s_endpgm
5804 ; GFX9-LABEL: urem_i32_oddk_denom:
5806 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
5807 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
5808 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5809 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5810 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, 0xb2a50881
5811 ; GFX9-NEXT: s_sub_i32 s3, s4, s2
5812 ; GFX9-NEXT: s_lshr_b32 s3, s3, 1
5813 ; GFX9-NEXT: s_add_i32 s3, s3, s2
5814 ; GFX9-NEXT: s_lshr_b32 s2, s3, 20
5815 ; GFX9-NEXT: s_mul_i32 s2, s2, 0x12d8fb
5816 ; GFX9-NEXT: s_sub_i32 s2, s4, s2
5817 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
5818 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
5819 ; GFX9-NEXT: s_endpgm
5820 %r = urem i32 %x, 1235195
5821 store i32 %r, ptr addrspace(1) %out
5825 define amdgpu_kernel void @urem_i32_pow2k_denom(ptr addrspace(1) %out, i32 %x) {
5826 ; CHECK-LABEL: @urem_i32_pow2k_denom(
5827 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[X:%.*]], 4096
5828 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5829 ; CHECK-NEXT: ret void
5831 ; GFX6-LABEL: urem_i32_pow2k_denom:
5833 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
5834 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
5835 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
5836 ; GFX6-NEXT: s_mov_b32 s2, -1
5837 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5838 ; GFX6-NEXT: s_and_b32 s4, s4, 0xfff
5839 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5840 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5841 ; GFX6-NEXT: s_endpgm
5843 ; GFX9-LABEL: urem_i32_pow2k_denom:
5845 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
5846 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
5847 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5848 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5849 ; GFX9-NEXT: s_and_b32 s2, s4, 0xfff
5850 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
5851 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
5852 ; GFX9-NEXT: s_endpgm
5853 %r = urem i32 %x, 4096
5854 store i32 %r, ptr addrspace(1) %out
5858 define amdgpu_kernel void @urem_i32_pow2_shl_denom(ptr addrspace(1) %out, i32 %x, i32 %y) {
5859 ; CHECK-LABEL: @urem_i32_pow2_shl_denom(
5860 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 4096, [[Y:%.*]]
5861 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[X:%.*]], [[SHL_Y]]
5862 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
5863 ; CHECK-NEXT: ret void
5865 ; GFX6-LABEL: urem_i32_pow2_shl_denom:
5867 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
5868 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5869 ; GFX6-NEXT: s_mov_b32 s6, -1
5870 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5871 ; GFX6-NEXT: s_mov_b32 s4, s0
5872 ; GFX6-NEXT: s_lshl_b32 s0, 0x1000, s3
5873 ; GFX6-NEXT: s_add_i32 s0, s0, -1
5874 ; GFX6-NEXT: s_and_b32 s0, s2, s0
5875 ; GFX6-NEXT: s_mov_b32 s5, s1
5876 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
5877 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5878 ; GFX6-NEXT: s_endpgm
5880 ; GFX9-LABEL: urem_i32_pow2_shl_denom:
5882 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5883 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
5884 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5885 ; GFX9-NEXT: s_lshl_b32 s0, 0x1000, s7
5886 ; GFX9-NEXT: s_add_i32 s0, s0, -1
5887 ; GFX9-NEXT: s_and_b32 s0, s6, s0
5888 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
5889 ; GFX9-NEXT: global_store_dword v0, v1, s[4:5]
5890 ; GFX9-NEXT: s_endpgm
5891 %shl.y = shl i32 4096, %y
5892 %r = urem i32 %x, %shl.y
5893 store i32 %r, ptr addrspace(1) %out
5897 define amdgpu_kernel void @urem_v2i32_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
5898 ; CHECK-LABEL: @urem_v2i32_pow2k_denom(
5899 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
5900 ; CHECK-NEXT: [[TMP2:%.*]] = urem i32 [[TMP1]], 4096
5901 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
5902 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
5903 ; CHECK-NEXT: [[TMP5:%.*]] = urem i32 [[TMP4]], 4096
5904 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
5905 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
5906 ; CHECK-NEXT: ret void
5908 ; GFX6-LABEL: urem_v2i32_pow2k_denom:
5910 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
5911 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
5912 ; GFX6-NEXT: s_mov_b32 s6, -1
5913 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5914 ; GFX6-NEXT: s_mov_b32 s4, s0
5915 ; GFX6-NEXT: s_mov_b32 s5, s1
5916 ; GFX6-NEXT: s_and_b32 s0, s2, 0xfff
5917 ; GFX6-NEXT: s_and_b32 s1, s3, 0xfff
5918 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
5919 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
5920 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
5921 ; GFX6-NEXT: s_endpgm
5923 ; GFX9-LABEL: urem_v2i32_pow2k_denom:
5925 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
5926 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
5927 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
5928 ; GFX9-NEXT: s_and_b32 s0, s6, 0xfff
5929 ; GFX9-NEXT: s_and_b32 s1, s7, 0xfff
5930 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
5931 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
5932 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
5933 ; GFX9-NEXT: s_endpgm
5934 %r = urem <2 x i32> %x, <i32 4096, i32 4096>
5935 store <2 x i32> %r, ptr addrspace(1) %out
5939 define amdgpu_kernel void @urem_v2i32_pow2_shl_denom(ptr addrspace(1) %out, <2 x i32> %x, <2 x i32> %y) {
5940 ; CHECK-LABEL: @urem_v2i32_pow2_shl_denom(
5941 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i32> <i32 4096, i32 4096>, [[Y:%.*]]
5942 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
5943 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 0
5944 ; CHECK-NEXT: [[TMP3:%.*]] = uitofp i32 [[TMP2]] to float
5945 ; CHECK-NEXT: [[TMP4:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP3]])
5946 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast float [[TMP4]], 0x41EFFFFFC0000000
5947 ; CHECK-NEXT: [[TMP6:%.*]] = fptoui float [[TMP5]] to i32
5948 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 0, [[TMP2]]
5949 ; CHECK-NEXT: [[TMP8:%.*]] = mul i32 [[TMP7]], [[TMP6]]
5950 ; CHECK-NEXT: [[TMP9:%.*]] = zext i32 [[TMP6]] to i64
5951 ; CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP8]] to i64
5952 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP9]], [[TMP10]]
5953 ; CHECK-NEXT: [[TMP12:%.*]] = trunc i64 [[TMP11]] to i32
5954 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i64 [[TMP11]], 32
5955 ; CHECK-NEXT: [[TMP14:%.*]] = trunc i64 [[TMP13]] to i32
5956 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP6]], [[TMP14]]
5957 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP1]] to i64
5958 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
5959 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
5960 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
5961 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
5962 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
5963 ; CHECK-NEXT: [[TMP22:%.*]] = mul i32 [[TMP21]], [[TMP2]]
5964 ; CHECK-NEXT: [[TMP23:%.*]] = sub i32 [[TMP1]], [[TMP22]]
5965 ; CHECK-NEXT: [[TMP24:%.*]] = icmp uge i32 [[TMP23]], [[TMP2]]
5966 ; CHECK-NEXT: [[TMP25:%.*]] = sub i32 [[TMP23]], [[TMP2]]
5967 ; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP24]], i32 [[TMP25]], i32 [[TMP23]]
5968 ; CHECK-NEXT: [[TMP27:%.*]] = icmp uge i32 [[TMP26]], [[TMP2]]
5969 ; CHECK-NEXT: [[TMP28:%.*]] = sub i32 [[TMP26]], [[TMP2]]
5970 ; CHECK-NEXT: [[TMP29:%.*]] = select i1 [[TMP27]], i32 [[TMP28]], i32 [[TMP26]]
5971 ; CHECK-NEXT: [[TMP30:%.*]] = insertelement <2 x i32> poison, i32 [[TMP29]], i64 0
5972 ; CHECK-NEXT: [[TMP31:%.*]] = extractelement <2 x i32> [[X]], i64 1
5973 ; CHECK-NEXT: [[TMP32:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 1
5974 ; CHECK-NEXT: [[TMP33:%.*]] = uitofp i32 [[TMP32]] to float
5975 ; CHECK-NEXT: [[TMP34:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP33]])
5976 ; CHECK-NEXT: [[TMP35:%.*]] = fmul fast float [[TMP34]], 0x41EFFFFFC0000000
5977 ; CHECK-NEXT: [[TMP36:%.*]] = fptoui float [[TMP35]] to i32
5978 ; CHECK-NEXT: [[TMP37:%.*]] = sub i32 0, [[TMP32]]
5979 ; CHECK-NEXT: [[TMP38:%.*]] = mul i32 [[TMP37]], [[TMP36]]
5980 ; CHECK-NEXT: [[TMP39:%.*]] = zext i32 [[TMP36]] to i64
5981 ; CHECK-NEXT: [[TMP40:%.*]] = zext i32 [[TMP38]] to i64
5982 ; CHECK-NEXT: [[TMP41:%.*]] = mul i64 [[TMP39]], [[TMP40]]
5983 ; CHECK-NEXT: [[TMP42:%.*]] = trunc i64 [[TMP41]] to i32
5984 ; CHECK-NEXT: [[TMP43:%.*]] = lshr i64 [[TMP41]], 32
5985 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i64 [[TMP43]] to i32
5986 ; CHECK-NEXT: [[TMP45:%.*]] = add i32 [[TMP36]], [[TMP44]]
5987 ; CHECK-NEXT: [[TMP46:%.*]] = zext i32 [[TMP31]] to i64
5988 ; CHECK-NEXT: [[TMP47:%.*]] = zext i32 [[TMP45]] to i64
5989 ; CHECK-NEXT: [[TMP48:%.*]] = mul i64 [[TMP46]], [[TMP47]]
5990 ; CHECK-NEXT: [[TMP49:%.*]] = trunc i64 [[TMP48]] to i32
5991 ; CHECK-NEXT: [[TMP50:%.*]] = lshr i64 [[TMP48]], 32
5992 ; CHECK-NEXT: [[TMP51:%.*]] = trunc i64 [[TMP50]] to i32
5993 ; CHECK-NEXT: [[TMP52:%.*]] = mul i32 [[TMP51]], [[TMP32]]
5994 ; CHECK-NEXT: [[TMP53:%.*]] = sub i32 [[TMP31]], [[TMP52]]
5995 ; CHECK-NEXT: [[TMP54:%.*]] = icmp uge i32 [[TMP53]], [[TMP32]]
5996 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 [[TMP53]], [[TMP32]]
5997 ; CHECK-NEXT: [[TMP56:%.*]] = select i1 [[TMP54]], i32 [[TMP55]], i32 [[TMP53]]
5998 ; CHECK-NEXT: [[TMP57:%.*]] = icmp uge i32 [[TMP56]], [[TMP32]]
5999 ; CHECK-NEXT: [[TMP58:%.*]] = sub i32 [[TMP56]], [[TMP32]]
6000 ; CHECK-NEXT: [[TMP59:%.*]] = select i1 [[TMP57]], i32 [[TMP58]], i32 [[TMP56]]
6001 ; CHECK-NEXT: [[TMP60:%.*]] = insertelement <2 x i32> [[TMP30]], i32 [[TMP59]], i64 1
6002 ; CHECK-NEXT: store <2 x i32> [[TMP60]], ptr addrspace(1) [[OUT:%.*]], align 8
6003 ; CHECK-NEXT: ret void
6005 ; GFX6-LABEL: urem_v2i32_pow2_shl_denom:
6007 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
6008 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6009 ; GFX6-NEXT: s_lshl_b32 s0, 0x1000, s6
6010 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s0
6011 ; GFX6-NEXT: s_sub_i32 s1, 0, s0
6012 ; GFX6-NEXT: s_lshl_b32 s6, 0x1000, s7
6013 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
6014 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6015 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
6016 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6017 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6018 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v0
6019 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6020 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6021 ; GFX6-NEXT: v_mul_hi_u32 v0, s4, v0
6022 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
6023 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
6024 ; GFX6-NEXT: v_readfirstlane_b32 s1, v0
6025 ; GFX6-NEXT: s_mul_i32 s1, s1, s0
6026 ; GFX6-NEXT: s_sub_i32 s1, s4, s1
6027 ; GFX6-NEXT: s_sub_i32 s4, s1, s0
6028 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
6029 ; GFX6-NEXT: s_cselect_b32 s1, s4, s1
6030 ; GFX6-NEXT: s_sub_i32 s4, s1, s0
6031 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
6032 ; GFX6-NEXT: s_cselect_b32 s4, s4, s1
6033 ; GFX6-NEXT: s_sub_i32 s0, 0, s6
6034 ; GFX6-NEXT: v_mul_lo_u32 v0, s0, v1
6035 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6036 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6037 ; GFX6-NEXT: s_mov_b32 s2, -1
6038 ; GFX6-NEXT: v_mul_hi_u32 v0, v1, v0
6039 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v1, v0
6040 ; GFX6-NEXT: v_mul_hi_u32 v0, s5, v0
6041 ; GFX6-NEXT: v_readfirstlane_b32 s7, v0
6042 ; GFX6-NEXT: s_mul_i32 s7, s7, s6
6043 ; GFX6-NEXT: s_sub_i32 s5, s5, s7
6044 ; GFX6-NEXT: s_sub_i32 s7, s5, s6
6045 ; GFX6-NEXT: s_cmp_ge_u32 s5, s6
6046 ; GFX6-NEXT: s_cselect_b32 s5, s7, s5
6047 ; GFX6-NEXT: s_sub_i32 s7, s5, s6
6048 ; GFX6-NEXT: s_cmp_ge_u32 s5, s6
6049 ; GFX6-NEXT: s_cselect_b32 s5, s7, s5
6050 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6051 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6052 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6053 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
6054 ; GFX6-NEXT: s_endpgm
6056 ; GFX9-LABEL: urem_v2i32_pow2_shl_denom:
6058 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
6059 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6060 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
6061 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6062 ; GFX9-NEXT: s_lshl_b32 s6, 0x1000, s6
6063 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s6
6064 ; GFX9-NEXT: s_lshl_b32 s7, 0x1000, s7
6065 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s7
6066 ; GFX9-NEXT: s_sub_i32 s2, 0, s6
6067 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
6068 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v1, v1
6069 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6070 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
6071 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v1
6072 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
6073 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
6074 ; GFX9-NEXT: s_mul_i32 s2, s2, s3
6075 ; GFX9-NEXT: s_mul_hi_u32 s2, s3, s2
6076 ; GFX9-NEXT: s_add_i32 s3, s3, s2
6077 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, s3
6078 ; GFX9-NEXT: s_mul_i32 s2, s2, s6
6079 ; GFX9-NEXT: s_sub_i32 s2, s4, s2
6080 ; GFX9-NEXT: s_sub_i32 s3, s2, s6
6081 ; GFX9-NEXT: s_cmp_ge_u32 s2, s6
6082 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
6083 ; GFX9-NEXT: s_sub_i32 s3, s2, s6
6084 ; GFX9-NEXT: s_cmp_ge_u32 s2, s6
6085 ; GFX9-NEXT: v_readfirstlane_b32 s8, v1
6086 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
6087 ; GFX9-NEXT: s_sub_i32 s3, 0, s7
6088 ; GFX9-NEXT: s_mul_i32 s3, s3, s8
6089 ; GFX9-NEXT: s_mul_hi_u32 s3, s8, s3
6090 ; GFX9-NEXT: s_add_i32 s8, s8, s3
6091 ; GFX9-NEXT: s_mul_hi_u32 s3, s5, s8
6092 ; GFX9-NEXT: s_mul_i32 s3, s3, s7
6093 ; GFX9-NEXT: s_sub_i32 s3, s5, s3
6094 ; GFX9-NEXT: s_sub_i32 s4, s3, s7
6095 ; GFX9-NEXT: s_cmp_ge_u32 s3, s7
6096 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
6097 ; GFX9-NEXT: s_sub_i32 s4, s3, s7
6098 ; GFX9-NEXT: s_cmp_ge_u32 s3, s7
6099 ; GFX9-NEXT: s_cselect_b32 s3, s4, s3
6100 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
6101 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
6102 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
6103 ; GFX9-NEXT: s_endpgm
6104 %shl.y = shl <2 x i32> <i32 4096, i32 4096>, %y
6105 %r = urem <2 x i32> %x, %shl.y
6106 store <2 x i32> %r, ptr addrspace(1) %out
6110 define amdgpu_kernel void @sdiv_i32_oddk_denom(ptr addrspace(1) %out, i32 %x) {
6111 ; CHECK-LABEL: @sdiv_i32_oddk_denom(
6112 ; CHECK-NEXT: [[R:%.*]] = sdiv i32 [[X:%.*]], 1235195
6113 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6114 ; CHECK-NEXT: ret void
6116 ; GFX6-LABEL: sdiv_i32_oddk_denom:
6118 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
6119 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6120 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xd9528441
6121 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6122 ; GFX6-NEXT: s_mov_b32 s2, -1
6123 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6124 ; GFX6-NEXT: v_mul_hi_i32 v0, s4, v0
6125 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v0
6126 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 31, v0
6127 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 20, v0
6128 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6129 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6130 ; GFX6-NEXT: s_endpgm
6132 ; GFX9-LABEL: sdiv_i32_oddk_denom:
6134 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
6135 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6136 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
6137 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6138 ; GFX9-NEXT: s_mul_hi_i32 s2, s4, 0xd9528441
6139 ; GFX9-NEXT: s_add_i32 s2, s2, s4
6140 ; GFX9-NEXT: s_lshr_b32 s3, s2, 31
6141 ; GFX9-NEXT: s_ashr_i32 s2, s2, 20
6142 ; GFX9-NEXT: s_add_i32 s2, s2, s3
6143 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
6144 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
6145 ; GFX9-NEXT: s_endpgm
6146 %r = sdiv i32 %x, 1235195
6147 store i32 %r, ptr addrspace(1) %out
6151 define amdgpu_kernel void @sdiv_i32_pow2k_denom(ptr addrspace(1) %out, i32 %x) {
6152 ; CHECK-LABEL: @sdiv_i32_pow2k_denom(
6153 ; CHECK-NEXT: [[R:%.*]] = sdiv i32 [[X:%.*]], 4096
6154 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6155 ; CHECK-NEXT: ret void
6157 ; GFX6-LABEL: sdiv_i32_pow2k_denom:
6159 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
6160 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6161 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6162 ; GFX6-NEXT: s_mov_b32 s2, -1
6163 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6164 ; GFX6-NEXT: s_ashr_i32 s5, s4, 31
6165 ; GFX6-NEXT: s_lshr_b32 s5, s5, 20
6166 ; GFX6-NEXT: s_add_i32 s4, s4, s5
6167 ; GFX6-NEXT: s_ashr_i32 s4, s4, 12
6168 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6169 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6170 ; GFX6-NEXT: s_endpgm
6172 ; GFX9-LABEL: sdiv_i32_pow2k_denom:
6174 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
6175 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6176 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
6177 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6178 ; GFX9-NEXT: s_ashr_i32 s2, s4, 31
6179 ; GFX9-NEXT: s_lshr_b32 s2, s2, 20
6180 ; GFX9-NEXT: s_add_i32 s4, s4, s2
6181 ; GFX9-NEXT: s_ashr_i32 s2, s4, 12
6182 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
6183 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
6184 ; GFX9-NEXT: s_endpgm
6185 %r = sdiv i32 %x, 4096
6186 store i32 %r, ptr addrspace(1) %out
6190 define amdgpu_kernel void @sdiv_i32_pow2_shl_denom(ptr addrspace(1) %out, i32 %x, i32 %y) {
6191 ; CHECK-LABEL: @sdiv_i32_pow2_shl_denom(
6192 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 4096, [[Y:%.*]]
6193 ; CHECK-NEXT: [[R:%.*]] = sdiv i32 [[X:%.*]], [[SHL_Y]]
6194 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6195 ; CHECK-NEXT: ret void
6197 ; GFX6-LABEL: sdiv_i32_pow2_shl_denom:
6199 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
6200 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
6201 ; GFX6-NEXT: s_mov_b32 s6, -1
6202 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6203 ; GFX6-NEXT: s_lshl_b32 s3, 0x1000, s3
6204 ; GFX6-NEXT: s_ashr_i32 s8, s3, 31
6205 ; GFX6-NEXT: s_add_i32 s3, s3, s8
6206 ; GFX6-NEXT: s_xor_b32 s3, s3, s8
6207 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s3
6208 ; GFX6-NEXT: s_sub_i32 s4, 0, s3
6209 ; GFX6-NEXT: s_ashr_i32 s9, s2, 31
6210 ; GFX6-NEXT: s_add_i32 s2, s2, s9
6211 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6212 ; GFX6-NEXT: s_xor_b32 s2, s2, s9
6213 ; GFX6-NEXT: s_mov_b32 s5, s1
6214 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6215 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6216 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v0
6217 ; GFX6-NEXT: s_mov_b32 s4, s0
6218 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6219 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6220 ; GFX6-NEXT: v_mul_hi_u32 v0, s2, v0
6221 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
6222 ; GFX6-NEXT: s_mul_i32 s0, s0, s3
6223 ; GFX6-NEXT: s_sub_i32 s0, s2, s0
6224 ; GFX6-NEXT: s_sub_i32 s1, s0, s3
6225 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
6226 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
6227 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6228 ; GFX6-NEXT: s_cselect_b32 s0, s1, s0
6229 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
6230 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
6231 ; GFX6-NEXT: s_cmp_ge_u32 s0, s3
6232 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6233 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
6234 ; GFX6-NEXT: s_xor_b32 s0, s9, s8
6235 ; GFX6-NEXT: v_xor_b32_e32 v0, s0, v0
6236 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s0, v0
6237 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6238 ; GFX6-NEXT: s_endpgm
6240 ; GFX9-LABEL: sdiv_i32_pow2_shl_denom:
6242 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
6243 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
6244 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6245 ; GFX9-NEXT: s_lshl_b32 s0, 0x1000, s7
6246 ; GFX9-NEXT: s_ashr_i32 s1, s0, 31
6247 ; GFX9-NEXT: s_add_i32 s0, s0, s1
6248 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
6249 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
6250 ; GFX9-NEXT: s_ashr_i32 s2, s6, 31
6251 ; GFX9-NEXT: s_add_i32 s3, s6, s2
6252 ; GFX9-NEXT: s_sub_i32 s6, 0, s0
6253 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
6254 ; GFX9-NEXT: s_xor_b32 s3, s3, s2
6255 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6256 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
6257 ; GFX9-NEXT: v_readfirstlane_b32 s7, v0
6258 ; GFX9-NEXT: s_mul_i32 s6, s6, s7
6259 ; GFX9-NEXT: s_mul_hi_u32 s6, s7, s6
6260 ; GFX9-NEXT: s_add_i32 s7, s7, s6
6261 ; GFX9-NEXT: s_mul_hi_u32 s6, s3, s7
6262 ; GFX9-NEXT: s_mul_i32 s8, s6, s0
6263 ; GFX9-NEXT: s_sub_i32 s3, s3, s8
6264 ; GFX9-NEXT: s_add_i32 s7, s6, 1
6265 ; GFX9-NEXT: s_sub_i32 s8, s3, s0
6266 ; GFX9-NEXT: s_cmp_ge_u32 s3, s0
6267 ; GFX9-NEXT: s_cselect_b32 s6, s7, s6
6268 ; GFX9-NEXT: s_cselect_b32 s3, s8, s3
6269 ; GFX9-NEXT: s_add_i32 s7, s6, 1
6270 ; GFX9-NEXT: s_cmp_ge_u32 s3, s0
6271 ; GFX9-NEXT: s_cselect_b32 s0, s7, s6
6272 ; GFX9-NEXT: s_xor_b32 s1, s2, s1
6273 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
6274 ; GFX9-NEXT: s_sub_i32 s0, s0, s1
6275 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
6276 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
6277 ; GFX9-NEXT: s_endpgm
6278 %shl.y = shl i32 4096, %y
6279 %r = sdiv i32 %x, %shl.y
6280 store i32 %r, ptr addrspace(1) %out
6284 define amdgpu_kernel void @sdiv_v2i32_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
6285 ; CHECK-LABEL: @sdiv_v2i32_pow2k_denom(
6286 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
6287 ; CHECK-NEXT: [[TMP2:%.*]] = sdiv i32 [[TMP1]], 4096
6288 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
6289 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
6290 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv i32 [[TMP4]], 4096
6291 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
6292 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
6293 ; CHECK-NEXT: ret void
6295 ; GFX6-LABEL: sdiv_v2i32_pow2k_denom:
6297 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
6298 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
6299 ; GFX6-NEXT: s_mov_b32 s6, -1
6300 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6301 ; GFX6-NEXT: s_mov_b32 s4, s0
6302 ; GFX6-NEXT: s_mov_b32 s5, s1
6303 ; GFX6-NEXT: s_ashr_i32 s0, s2, 31
6304 ; GFX6-NEXT: s_ashr_i32 s1, s3, 31
6305 ; GFX6-NEXT: s_lshr_b32 s0, s0, 20
6306 ; GFX6-NEXT: s_lshr_b32 s1, s1, 20
6307 ; GFX6-NEXT: s_add_i32 s0, s2, s0
6308 ; GFX6-NEXT: s_add_i32 s1, s3, s1
6309 ; GFX6-NEXT: s_ashr_i32 s0, s0, 12
6310 ; GFX6-NEXT: s_ashr_i32 s1, s1, 12
6311 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
6312 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
6313 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
6314 ; GFX6-NEXT: s_endpgm
6316 ; GFX9-LABEL: sdiv_v2i32_pow2k_denom:
6318 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
6319 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
6320 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6321 ; GFX9-NEXT: s_ashr_i32 s0, s6, 31
6322 ; GFX9-NEXT: s_ashr_i32 s1, s7, 31
6323 ; GFX9-NEXT: s_lshr_b32 s0, s0, 20
6324 ; GFX9-NEXT: s_lshr_b32 s1, s1, 20
6325 ; GFX9-NEXT: s_add_i32 s0, s6, s0
6326 ; GFX9-NEXT: s_add_i32 s1, s7, s1
6327 ; GFX9-NEXT: s_ashr_i32 s0, s0, 12
6328 ; GFX9-NEXT: s_ashr_i32 s1, s1, 12
6329 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
6330 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
6331 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
6332 ; GFX9-NEXT: s_endpgm
6333 %r = sdiv <2 x i32> %x, <i32 4096, i32 4096>
6334 store <2 x i32> %r, ptr addrspace(1) %out
6338 define amdgpu_kernel void @ssdiv_v2i32_mixed_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
6339 ; CHECK-LABEL: @ssdiv_v2i32_mixed_pow2k_denom(
6340 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
6341 ; CHECK-NEXT: [[TMP2:%.*]] = sdiv i32 [[TMP1]], 4096
6342 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
6343 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
6344 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv i32 [[TMP4]], 4095
6345 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
6346 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
6347 ; CHECK-NEXT: ret void
6349 ; GFX6-LABEL: ssdiv_v2i32_mixed_pow2k_denom:
6351 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
6352 ; GFX6-NEXT: v_mov_b32_e32 v0, 0x80080081
6353 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
6354 ; GFX6-NEXT: s_mov_b32 s6, -1
6355 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6356 ; GFX6-NEXT: v_mul_hi_i32 v0, s3, v0
6357 ; GFX6-NEXT: s_mov_b32 s4, s0
6358 ; GFX6-NEXT: s_ashr_i32 s0, s2, 31
6359 ; GFX6-NEXT: s_lshr_b32 s0, s0, 20
6360 ; GFX6-NEXT: s_add_i32 s0, s2, s0
6361 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s3, v0
6362 ; GFX6-NEXT: s_ashr_i32 s0, s0, 12
6363 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 31, v0
6364 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 11, v0
6365 ; GFX6-NEXT: s_mov_b32 s5, s1
6366 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v0, v1
6367 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
6368 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
6369 ; GFX6-NEXT: s_endpgm
6371 ; GFX9-LABEL: ssdiv_v2i32_mixed_pow2k_denom:
6373 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
6374 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
6375 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6376 ; GFX9-NEXT: s_ashr_i32 s0, s6, 31
6377 ; GFX9-NEXT: s_mul_hi_i32 s1, s7, 0x80080081
6378 ; GFX9-NEXT: s_lshr_b32 s0, s0, 20
6379 ; GFX9-NEXT: s_add_i32 s1, s1, s7
6380 ; GFX9-NEXT: s_add_i32 s0, s6, s0
6381 ; GFX9-NEXT: s_lshr_b32 s2, s1, 31
6382 ; GFX9-NEXT: s_ashr_i32 s1, s1, 11
6383 ; GFX9-NEXT: s_ashr_i32 s0, s0, 12
6384 ; GFX9-NEXT: s_add_i32 s1, s1, s2
6385 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
6386 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
6387 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
6388 ; GFX9-NEXT: s_endpgm
6389 %r = sdiv <2 x i32> %x, <i32 4096, i32 4095>
6390 store <2 x i32> %r, ptr addrspace(1) %out
6394 define amdgpu_kernel void @sdiv_v2i32_pow2_shl_denom(ptr addrspace(1) %out, <2 x i32> %x, <2 x i32> %y) {
6395 ; CHECK-LABEL: @sdiv_v2i32_pow2_shl_denom(
6396 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i32> <i32 4096, i32 4096>, [[Y:%.*]]
6397 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
6398 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 0
6399 ; CHECK-NEXT: [[TMP3:%.*]] = ashr i32 [[TMP1]], 31
6400 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP2]], 31
6401 ; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP3]], [[TMP4]]
6402 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP1]], [[TMP3]]
6403 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 [[TMP2]], [[TMP4]]
6404 ; CHECK-NEXT: [[TMP8:%.*]] = xor i32 [[TMP6]], [[TMP3]]
6405 ; CHECK-NEXT: [[TMP9:%.*]] = xor i32 [[TMP7]], [[TMP4]]
6406 ; CHECK-NEXT: [[TMP10:%.*]] = uitofp i32 [[TMP9]] to float
6407 ; CHECK-NEXT: [[TMP11:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP10]])
6408 ; CHECK-NEXT: [[TMP12:%.*]] = fmul fast float [[TMP11]], 0x41EFFFFFC0000000
6409 ; CHECK-NEXT: [[TMP13:%.*]] = fptoui float [[TMP12]] to i32
6410 ; CHECK-NEXT: [[TMP14:%.*]] = sub i32 0, [[TMP9]]
6411 ; CHECK-NEXT: [[TMP15:%.*]] = mul i32 [[TMP14]], [[TMP13]]
6412 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP13]] to i64
6413 ; CHECK-NEXT: [[TMP17:%.*]] = zext i32 [[TMP15]] to i64
6414 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP16]], [[TMP17]]
6415 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i64 [[TMP18]] to i32
6416 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i64 [[TMP18]], 32
6417 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i64 [[TMP20]] to i32
6418 ; CHECK-NEXT: [[TMP22:%.*]] = add i32 [[TMP13]], [[TMP21]]
6419 ; CHECK-NEXT: [[TMP23:%.*]] = zext i32 [[TMP8]] to i64
6420 ; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP22]] to i64
6421 ; CHECK-NEXT: [[TMP25:%.*]] = mul i64 [[TMP23]], [[TMP24]]
6422 ; CHECK-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP25]] to i32
6423 ; CHECK-NEXT: [[TMP27:%.*]] = lshr i64 [[TMP25]], 32
6424 ; CHECK-NEXT: [[TMP28:%.*]] = trunc i64 [[TMP27]] to i32
6425 ; CHECK-NEXT: [[TMP29:%.*]] = mul i32 [[TMP28]], [[TMP9]]
6426 ; CHECK-NEXT: [[TMP30:%.*]] = sub i32 [[TMP8]], [[TMP29]]
6427 ; CHECK-NEXT: [[TMP31:%.*]] = icmp uge i32 [[TMP30]], [[TMP9]]
6428 ; CHECK-NEXT: [[TMP32:%.*]] = add i32 [[TMP28]], 1
6429 ; CHECK-NEXT: [[TMP33:%.*]] = select i1 [[TMP31]], i32 [[TMP32]], i32 [[TMP28]]
6430 ; CHECK-NEXT: [[TMP34:%.*]] = sub i32 [[TMP30]], [[TMP9]]
6431 ; CHECK-NEXT: [[TMP35:%.*]] = select i1 [[TMP31]], i32 [[TMP34]], i32 [[TMP30]]
6432 ; CHECK-NEXT: [[TMP36:%.*]] = icmp uge i32 [[TMP35]], [[TMP9]]
6433 ; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP33]], 1
6434 ; CHECK-NEXT: [[TMP38:%.*]] = select i1 [[TMP36]], i32 [[TMP37]], i32 [[TMP33]]
6435 ; CHECK-NEXT: [[TMP39:%.*]] = xor i32 [[TMP38]], [[TMP5]]
6436 ; CHECK-NEXT: [[TMP40:%.*]] = sub i32 [[TMP39]], [[TMP5]]
6437 ; CHECK-NEXT: [[TMP41:%.*]] = insertelement <2 x i32> poison, i32 [[TMP40]], i64 0
6438 ; CHECK-NEXT: [[TMP42:%.*]] = extractelement <2 x i32> [[X]], i64 1
6439 ; CHECK-NEXT: [[TMP43:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 1
6440 ; CHECK-NEXT: [[TMP44:%.*]] = ashr i32 [[TMP42]], 31
6441 ; CHECK-NEXT: [[TMP45:%.*]] = ashr i32 [[TMP43]], 31
6442 ; CHECK-NEXT: [[TMP46:%.*]] = xor i32 [[TMP44]], [[TMP45]]
6443 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP42]], [[TMP44]]
6444 ; CHECK-NEXT: [[TMP48:%.*]] = add i32 [[TMP43]], [[TMP45]]
6445 ; CHECK-NEXT: [[TMP49:%.*]] = xor i32 [[TMP47]], [[TMP44]]
6446 ; CHECK-NEXT: [[TMP50:%.*]] = xor i32 [[TMP48]], [[TMP45]]
6447 ; CHECK-NEXT: [[TMP51:%.*]] = uitofp i32 [[TMP50]] to float
6448 ; CHECK-NEXT: [[TMP52:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP51]])
6449 ; CHECK-NEXT: [[TMP53:%.*]] = fmul fast float [[TMP52]], 0x41EFFFFFC0000000
6450 ; CHECK-NEXT: [[TMP54:%.*]] = fptoui float [[TMP53]] to i32
6451 ; CHECK-NEXT: [[TMP55:%.*]] = sub i32 0, [[TMP50]]
6452 ; CHECK-NEXT: [[TMP56:%.*]] = mul i32 [[TMP55]], [[TMP54]]
6453 ; CHECK-NEXT: [[TMP57:%.*]] = zext i32 [[TMP54]] to i64
6454 ; CHECK-NEXT: [[TMP58:%.*]] = zext i32 [[TMP56]] to i64
6455 ; CHECK-NEXT: [[TMP59:%.*]] = mul i64 [[TMP57]], [[TMP58]]
6456 ; CHECK-NEXT: [[TMP60:%.*]] = trunc i64 [[TMP59]] to i32
6457 ; CHECK-NEXT: [[TMP61:%.*]] = lshr i64 [[TMP59]], 32
6458 ; CHECK-NEXT: [[TMP62:%.*]] = trunc i64 [[TMP61]] to i32
6459 ; CHECK-NEXT: [[TMP63:%.*]] = add i32 [[TMP54]], [[TMP62]]
6460 ; CHECK-NEXT: [[TMP64:%.*]] = zext i32 [[TMP49]] to i64
6461 ; CHECK-NEXT: [[TMP65:%.*]] = zext i32 [[TMP63]] to i64
6462 ; CHECK-NEXT: [[TMP66:%.*]] = mul i64 [[TMP64]], [[TMP65]]
6463 ; CHECK-NEXT: [[TMP67:%.*]] = trunc i64 [[TMP66]] to i32
6464 ; CHECK-NEXT: [[TMP68:%.*]] = lshr i64 [[TMP66]], 32
6465 ; CHECK-NEXT: [[TMP69:%.*]] = trunc i64 [[TMP68]] to i32
6466 ; CHECK-NEXT: [[TMP70:%.*]] = mul i32 [[TMP69]], [[TMP50]]
6467 ; CHECK-NEXT: [[TMP71:%.*]] = sub i32 [[TMP49]], [[TMP70]]
6468 ; CHECK-NEXT: [[TMP72:%.*]] = icmp uge i32 [[TMP71]], [[TMP50]]
6469 ; CHECK-NEXT: [[TMP73:%.*]] = add i32 [[TMP69]], 1
6470 ; CHECK-NEXT: [[TMP74:%.*]] = select i1 [[TMP72]], i32 [[TMP73]], i32 [[TMP69]]
6471 ; CHECK-NEXT: [[TMP75:%.*]] = sub i32 [[TMP71]], [[TMP50]]
6472 ; CHECK-NEXT: [[TMP76:%.*]] = select i1 [[TMP72]], i32 [[TMP75]], i32 [[TMP71]]
6473 ; CHECK-NEXT: [[TMP77:%.*]] = icmp uge i32 [[TMP76]], [[TMP50]]
6474 ; CHECK-NEXT: [[TMP78:%.*]] = add i32 [[TMP74]], 1
6475 ; CHECK-NEXT: [[TMP79:%.*]] = select i1 [[TMP77]], i32 [[TMP78]], i32 [[TMP74]]
6476 ; CHECK-NEXT: [[TMP80:%.*]] = xor i32 [[TMP79]], [[TMP46]]
6477 ; CHECK-NEXT: [[TMP81:%.*]] = sub i32 [[TMP80]], [[TMP46]]
6478 ; CHECK-NEXT: [[TMP82:%.*]] = insertelement <2 x i32> [[TMP41]], i32 [[TMP81]], i64 1
6479 ; CHECK-NEXT: store <2 x i32> [[TMP82]], ptr addrspace(1) [[OUT:%.*]], align 8
6480 ; CHECK-NEXT: ret void
6482 ; GFX6-LABEL: sdiv_v2i32_pow2_shl_denom:
6484 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
6485 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6486 ; GFX6-NEXT: s_lshl_b32 s0, 0x1000, s6
6487 ; GFX6-NEXT: s_abs_i32 s1, s0
6488 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s1
6489 ; GFX6-NEXT: s_sub_i32 s6, 0, s1
6490 ; GFX6-NEXT: s_xor_b32 s0, s4, s0
6491 ; GFX6-NEXT: s_lshl_b32 s7, 0x1000, s7
6492 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6493 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6494 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6495 ; GFX6-NEXT: v_mul_lo_u32 v1, s6, v0
6496 ; GFX6-NEXT: s_abs_i32 s6, s4
6497 ; GFX6-NEXT: s_ashr_i32 s4, s0, 31
6498 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6499 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6500 ; GFX6-NEXT: v_mul_hi_u32 v0, s6, v0
6501 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
6502 ; GFX6-NEXT: s_mul_i32 s0, s0, s1
6503 ; GFX6-NEXT: s_sub_i32 s0, s6, s0
6504 ; GFX6-NEXT: s_sub_i32 s6, s0, s1
6505 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
6506 ; GFX6-NEXT: s_cmp_ge_u32 s0, s1
6507 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6508 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
6509 ; GFX6-NEXT: s_cselect_b32 s0, s6, s0
6510 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, 1, v0
6511 ; GFX6-NEXT: s_cmp_ge_u32 s0, s1
6512 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6513 ; GFX6-NEXT: s_abs_i32 s6, s7
6514 ; GFX6-NEXT: v_cvt_f32_u32_e32 v2, s6
6515 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6516 ; GFX6-NEXT: s_sub_i32 s2, 0, s6
6517 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
6518 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v2, v2
6519 ; GFX6-NEXT: s_xor_b32 s7, s5, s7
6520 ; GFX6-NEXT: s_abs_i32 s5, s5
6521 ; GFX6-NEXT: v_xor_b32_e32 v0, s4, v0
6522 ; GFX6-NEXT: v_mul_f32_e32 v2, 0x4f7ffffe, v2
6523 ; GFX6-NEXT: v_cvt_u32_f32_e32 v2, v2
6524 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s4, v0
6525 ; GFX6-NEXT: s_ashr_i32 s7, s7, 31
6526 ; GFX6-NEXT: v_mul_lo_u32 v3, s2, v2
6527 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6528 ; GFX6-NEXT: s_mov_b32 s2, -1
6529 ; GFX6-NEXT: v_mul_hi_u32 v1, v2, v3
6530 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
6531 ; GFX6-NEXT: v_mul_hi_u32 v1, s5, v1
6532 ; GFX6-NEXT: v_readfirstlane_b32 s4, v1
6533 ; GFX6-NEXT: s_mul_i32 s4, s4, s6
6534 ; GFX6-NEXT: s_sub_i32 s4, s5, s4
6535 ; GFX6-NEXT: s_sub_i32 s5, s4, s6
6536 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v1
6537 ; GFX6-NEXT: s_cmp_ge_u32 s4, s6
6538 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6539 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
6540 ; GFX6-NEXT: s_cselect_b32 s4, s5, s4
6541 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v1
6542 ; GFX6-NEXT: s_cmp_ge_u32 s4, s6
6543 ; GFX6-NEXT: s_cselect_b64 vcc, -1, 0
6544 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
6545 ; GFX6-NEXT: v_xor_b32_e32 v1, s7, v1
6546 ; GFX6-NEXT: v_subrev_i32_e32 v1, vcc, s7, v1
6547 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6548 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
6549 ; GFX6-NEXT: s_endpgm
6551 ; GFX9-LABEL: sdiv_v2i32_pow2_shl_denom:
6553 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
6554 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
6555 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6556 ; GFX9-NEXT: s_lshl_b32 s0, 0x1000, s6
6557 ; GFX9-NEXT: s_abs_i32 s1, s0
6558 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s1
6559 ; GFX9-NEXT: s_xor_b32 s0, s4, s0
6560 ; GFX9-NEXT: s_lshl_b32 s6, 0x1000, s7
6561 ; GFX9-NEXT: s_abs_i32 s7, s4
6562 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
6563 ; GFX9-NEXT: s_ashr_i32 s4, s0, 31
6564 ; GFX9-NEXT: s_sub_i32 s0, 0, s1
6565 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6566 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
6567 ; GFX9-NEXT: v_readfirstlane_b32 s8, v0
6568 ; GFX9-NEXT: s_mul_i32 s0, s0, s8
6569 ; GFX9-NEXT: s_mul_hi_u32 s0, s8, s0
6570 ; GFX9-NEXT: s_add_i32 s8, s8, s0
6571 ; GFX9-NEXT: s_mul_hi_u32 s0, s7, s8
6572 ; GFX9-NEXT: s_mul_i32 s8, s0, s1
6573 ; GFX9-NEXT: s_sub_i32 s7, s7, s8
6574 ; GFX9-NEXT: s_add_i32 s9, s0, 1
6575 ; GFX9-NEXT: s_sub_i32 s8, s7, s1
6576 ; GFX9-NEXT: s_cmp_ge_u32 s7, s1
6577 ; GFX9-NEXT: s_cselect_b32 s0, s9, s0
6578 ; GFX9-NEXT: s_cselect_b32 s7, s8, s7
6579 ; GFX9-NEXT: s_add_i32 s8, s0, 1
6580 ; GFX9-NEXT: s_cmp_ge_u32 s7, s1
6581 ; GFX9-NEXT: s_cselect_b32 s7, s8, s0
6582 ; GFX9-NEXT: s_abs_i32 s8, s6
6583 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s8
6584 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6585 ; GFX9-NEXT: s_xor_b32 s2, s5, s6
6586 ; GFX9-NEXT: s_abs_i32 s3, s5
6587 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
6588 ; GFX9-NEXT: s_xor_b32 s5, s7, s4
6589 ; GFX9-NEXT: s_sub_i32 s6, 0, s8
6590 ; GFX9-NEXT: s_sub_i32 s4, s5, s4
6591 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6592 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
6593 ; GFX9-NEXT: s_ashr_i32 s2, s2, 31
6594 ; GFX9-NEXT: v_readfirstlane_b32 s5, v0
6595 ; GFX9-NEXT: s_mul_i32 s6, s6, s5
6596 ; GFX9-NEXT: s_mul_hi_u32 s6, s5, s6
6597 ; GFX9-NEXT: s_add_i32 s5, s5, s6
6598 ; GFX9-NEXT: s_mul_hi_u32 s5, s3, s5
6599 ; GFX9-NEXT: s_mul_i32 s6, s5, s8
6600 ; GFX9-NEXT: s_sub_i32 s3, s3, s6
6601 ; GFX9-NEXT: s_add_i32 s7, s5, 1
6602 ; GFX9-NEXT: s_sub_i32 s6, s3, s8
6603 ; GFX9-NEXT: s_cmp_ge_u32 s3, s8
6604 ; GFX9-NEXT: s_cselect_b32 s5, s7, s5
6605 ; GFX9-NEXT: s_cselect_b32 s3, s6, s3
6606 ; GFX9-NEXT: s_add_i32 s6, s5, 1
6607 ; GFX9-NEXT: s_cmp_ge_u32 s3, s8
6608 ; GFX9-NEXT: s_cselect_b32 s3, s6, s5
6609 ; GFX9-NEXT: s_xor_b32 s3, s3, s2
6610 ; GFX9-NEXT: s_sub_i32 s2, s3, s2
6611 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
6612 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
6613 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6614 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
6615 ; GFX9-NEXT: s_endpgm
6616 %shl.y = shl <2 x i32> <i32 4096, i32 4096>, %y
6617 %r = sdiv <2 x i32> %x, %shl.y
6618 store <2 x i32> %r, ptr addrspace(1) %out
6622 define amdgpu_kernel void @srem_i32_oddk_denom(ptr addrspace(1) %out, i32 %x) {
6623 ; CHECK-LABEL: @srem_i32_oddk_denom(
6624 ; CHECK-NEXT: [[R:%.*]] = srem i32 [[X:%.*]], 1235195
6625 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6626 ; CHECK-NEXT: ret void
6628 ; GFX6-LABEL: srem_i32_oddk_denom:
6630 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
6631 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6632 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xd9528441
6633 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6634 ; GFX6-NEXT: s_mov_b32 s2, -1
6635 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6636 ; GFX6-NEXT: v_mul_hi_i32 v0, s4, v0
6637 ; GFX6-NEXT: v_readfirstlane_b32 s5, v0
6638 ; GFX6-NEXT: s_add_i32 s5, s5, s4
6639 ; GFX6-NEXT: s_lshr_b32 s6, s5, 31
6640 ; GFX6-NEXT: s_ashr_i32 s5, s5, 20
6641 ; GFX6-NEXT: s_add_i32 s5, s5, s6
6642 ; GFX6-NEXT: s_mul_i32 s5, s5, 0x12d8fb
6643 ; GFX6-NEXT: s_sub_i32 s4, s4, s5
6644 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6645 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6646 ; GFX6-NEXT: s_endpgm
6648 ; GFX9-LABEL: srem_i32_oddk_denom:
6650 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
6651 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6652 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
6653 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6654 ; GFX9-NEXT: s_mul_hi_i32 s2, s4, 0xd9528441
6655 ; GFX9-NEXT: s_add_i32 s2, s2, s4
6656 ; GFX9-NEXT: s_lshr_b32 s3, s2, 31
6657 ; GFX9-NEXT: s_ashr_i32 s2, s2, 20
6658 ; GFX9-NEXT: s_add_i32 s2, s2, s3
6659 ; GFX9-NEXT: s_mul_i32 s2, s2, 0x12d8fb
6660 ; GFX9-NEXT: s_sub_i32 s2, s4, s2
6661 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
6662 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
6663 ; GFX9-NEXT: s_endpgm
6664 %r = srem i32 %x, 1235195
6665 store i32 %r, ptr addrspace(1) %out
6669 define amdgpu_kernel void @srem_i32_pow2k_denom(ptr addrspace(1) %out, i32 %x) {
6670 ; CHECK-LABEL: @srem_i32_pow2k_denom(
6671 ; CHECK-NEXT: [[R:%.*]] = srem i32 [[X:%.*]], 4096
6672 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6673 ; CHECK-NEXT: ret void
6675 ; GFX6-LABEL: srem_i32_pow2k_denom:
6677 ; GFX6-NEXT: s_load_dword s4, s[2:3], 0xb
6678 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6679 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6680 ; GFX6-NEXT: s_mov_b32 s2, -1
6681 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6682 ; GFX6-NEXT: s_ashr_i32 s5, s4, 31
6683 ; GFX6-NEXT: s_lshr_b32 s5, s5, 20
6684 ; GFX6-NEXT: s_add_i32 s5, s4, s5
6685 ; GFX6-NEXT: s_and_b32 s5, s5, 0xfffff000
6686 ; GFX6-NEXT: s_sub_i32 s4, s4, s5
6687 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6688 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6689 ; GFX6-NEXT: s_endpgm
6691 ; GFX9-LABEL: srem_i32_pow2k_denom:
6693 ; GFX9-NEXT: s_load_dword s4, s[2:3], 0x2c
6694 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
6695 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
6696 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6697 ; GFX9-NEXT: s_ashr_i32 s2, s4, 31
6698 ; GFX9-NEXT: s_lshr_b32 s2, s2, 20
6699 ; GFX9-NEXT: s_add_i32 s2, s4, s2
6700 ; GFX9-NEXT: s_and_b32 s2, s2, 0xfffff000
6701 ; GFX9-NEXT: s_sub_i32 s2, s4, s2
6702 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
6703 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
6704 ; GFX9-NEXT: s_endpgm
6705 %r = srem i32 %x, 4096
6706 store i32 %r, ptr addrspace(1) %out
6710 define amdgpu_kernel void @srem_i32_pow2_shl_denom(ptr addrspace(1) %out, i32 %x, i32 %y) {
6711 ; CHECK-LABEL: @srem_i32_pow2_shl_denom(
6712 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 4096, [[Y:%.*]]
6713 ; CHECK-NEXT: [[R:%.*]] = srem i32 [[X:%.*]], [[SHL_Y]]
6714 ; CHECK-NEXT: store i32 [[R]], ptr addrspace(1) [[OUT:%.*]], align 4
6715 ; CHECK-NEXT: ret void
6717 ; GFX6-LABEL: srem_i32_pow2_shl_denom:
6719 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
6720 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6721 ; GFX6-NEXT: s_lshl_b32 s3, 0x1000, s3
6722 ; GFX6-NEXT: s_ashr_i32 s4, s3, 31
6723 ; GFX6-NEXT: s_add_i32 s3, s3, s4
6724 ; GFX6-NEXT: s_xor_b32 s4, s3, s4
6725 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s4
6726 ; GFX6-NEXT: s_sub_i32 s3, 0, s4
6727 ; GFX6-NEXT: s_ashr_i32 s5, s2, 31
6728 ; GFX6-NEXT: s_add_i32 s2, s2, s5
6729 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6730 ; GFX6-NEXT: s_xor_b32 s6, s2, s5
6731 ; GFX6-NEXT: s_mov_b32 s2, -1
6732 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6733 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6734 ; GFX6-NEXT: v_mul_lo_u32 v1, s3, v0
6735 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6736 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6737 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6738 ; GFX6-NEXT: v_mul_hi_u32 v0, s6, v0
6739 ; GFX6-NEXT: v_readfirstlane_b32 s7, v0
6740 ; GFX6-NEXT: s_mul_i32 s7, s7, s4
6741 ; GFX6-NEXT: s_sub_i32 s6, s6, s7
6742 ; GFX6-NEXT: s_sub_i32 s7, s6, s4
6743 ; GFX6-NEXT: s_cmp_ge_u32 s6, s4
6744 ; GFX6-NEXT: s_cselect_b32 s6, s7, s6
6745 ; GFX6-NEXT: s_sub_i32 s7, s6, s4
6746 ; GFX6-NEXT: s_cmp_ge_u32 s6, s4
6747 ; GFX6-NEXT: s_cselect_b32 s4, s7, s6
6748 ; GFX6-NEXT: s_xor_b32 s4, s4, s5
6749 ; GFX6-NEXT: s_sub_i32 s4, s4, s5
6750 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6751 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6752 ; GFX6-NEXT: s_endpgm
6754 ; GFX9-LABEL: srem_i32_pow2_shl_denom:
6756 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
6757 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
6758 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6759 ; GFX9-NEXT: s_lshl_b32 s0, 0x1000, s7
6760 ; GFX9-NEXT: s_ashr_i32 s1, s0, 31
6761 ; GFX9-NEXT: s_add_i32 s0, s0, s1
6762 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
6763 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
6764 ; GFX9-NEXT: s_ashr_i32 s1, s6, 31
6765 ; GFX9-NEXT: s_add_i32 s2, s6, s1
6766 ; GFX9-NEXT: s_sub_i32 s3, 0, s0
6767 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
6768 ; GFX9-NEXT: s_xor_b32 s2, s2, s1
6769 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6770 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
6771 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
6772 ; GFX9-NEXT: s_mul_i32 s3, s3, s6
6773 ; GFX9-NEXT: s_mul_hi_u32 s3, s6, s3
6774 ; GFX9-NEXT: s_add_i32 s6, s6, s3
6775 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, s6
6776 ; GFX9-NEXT: s_mul_i32 s3, s3, s0
6777 ; GFX9-NEXT: s_sub_i32 s2, s2, s3
6778 ; GFX9-NEXT: s_sub_i32 s3, s2, s0
6779 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
6780 ; GFX9-NEXT: s_cselect_b32 s2, s3, s2
6781 ; GFX9-NEXT: s_sub_i32 s3, s2, s0
6782 ; GFX9-NEXT: s_cmp_ge_u32 s2, s0
6783 ; GFX9-NEXT: s_cselect_b32 s0, s3, s2
6784 ; GFX9-NEXT: s_xor_b32 s0, s0, s1
6785 ; GFX9-NEXT: s_sub_i32 s0, s0, s1
6786 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
6787 ; GFX9-NEXT: global_store_dword v1, v0, s[4:5]
6788 ; GFX9-NEXT: s_endpgm
6789 %shl.y = shl i32 4096, %y
6790 %r = srem i32 %x, %shl.y
6791 store i32 %r, ptr addrspace(1) %out
6795 define amdgpu_kernel void @srem_v2i32_pow2k_denom(ptr addrspace(1) %out, <2 x i32> %x) {
6796 ; CHECK-LABEL: @srem_v2i32_pow2k_denom(
6797 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
6798 ; CHECK-NEXT: [[TMP2:%.*]] = srem i32 [[TMP1]], 4096
6799 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i32> poison, i32 [[TMP2]], i64 0
6800 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i32> [[X]], i64 1
6801 ; CHECK-NEXT: [[TMP5:%.*]] = srem i32 [[TMP4]], 4096
6802 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[TMP5]], i64 1
6803 ; CHECK-NEXT: store <2 x i32> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 8
6804 ; CHECK-NEXT: ret void
6806 ; GFX6-LABEL: srem_v2i32_pow2k_denom:
6808 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
6809 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
6810 ; GFX6-NEXT: s_mov_b32 s6, -1
6811 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6812 ; GFX6-NEXT: s_mov_b32 s4, s0
6813 ; GFX6-NEXT: s_mov_b32 s5, s1
6814 ; GFX6-NEXT: s_ashr_i32 s0, s2, 31
6815 ; GFX6-NEXT: s_ashr_i32 s1, s3, 31
6816 ; GFX6-NEXT: s_lshr_b32 s0, s0, 20
6817 ; GFX6-NEXT: s_lshr_b32 s1, s1, 20
6818 ; GFX6-NEXT: s_add_i32 s0, s2, s0
6819 ; GFX6-NEXT: s_add_i32 s1, s3, s1
6820 ; GFX6-NEXT: s_and_b32 s0, s0, 0xfffff000
6821 ; GFX6-NEXT: s_and_b32 s1, s1, 0xfffff000
6822 ; GFX6-NEXT: s_sub_i32 s0, s2, s0
6823 ; GFX6-NEXT: s_sub_i32 s1, s3, s1
6824 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
6825 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
6826 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
6827 ; GFX6-NEXT: s_endpgm
6829 ; GFX9-LABEL: srem_v2i32_pow2k_denom:
6831 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
6832 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
6833 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
6834 ; GFX9-NEXT: s_ashr_i32 s0, s6, 31
6835 ; GFX9-NEXT: s_ashr_i32 s1, s7, 31
6836 ; GFX9-NEXT: s_lshr_b32 s0, s0, 20
6837 ; GFX9-NEXT: s_lshr_b32 s1, s1, 20
6838 ; GFX9-NEXT: s_add_i32 s0, s6, s0
6839 ; GFX9-NEXT: s_add_i32 s1, s7, s1
6840 ; GFX9-NEXT: s_and_b32 s0, s0, 0xfffff000
6841 ; GFX9-NEXT: s_and_b32 s1, s1, 0xfffff000
6842 ; GFX9-NEXT: s_sub_i32 s0, s6, s0
6843 ; GFX9-NEXT: s_sub_i32 s1, s7, s1
6844 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
6845 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
6846 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
6847 ; GFX9-NEXT: s_endpgm
6848 %r = srem <2 x i32> %x, <i32 4096, i32 4096>
6849 store <2 x i32> %r, ptr addrspace(1) %out
6853 define amdgpu_kernel void @srem_v2i32_pow2_shl_denom(ptr addrspace(1) %out, <2 x i32> %x, <2 x i32> %y) {
6854 ; CHECK-LABEL: @srem_v2i32_pow2_shl_denom(
6855 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i32> <i32 4096, i32 4096>, [[Y:%.*]]
6856 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[X:%.*]], i64 0
6857 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 0
6858 ; CHECK-NEXT: [[TMP3:%.*]] = ashr i32 [[TMP1]], 31
6859 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i32 [[TMP2]], 31
6860 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[TMP1]], [[TMP3]]
6861 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP2]], [[TMP4]]
6862 ; CHECK-NEXT: [[TMP7:%.*]] = xor i32 [[TMP5]], [[TMP3]]
6863 ; CHECK-NEXT: [[TMP8:%.*]] = xor i32 [[TMP6]], [[TMP4]]
6864 ; CHECK-NEXT: [[TMP9:%.*]] = uitofp i32 [[TMP8]] to float
6865 ; CHECK-NEXT: [[TMP10:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP9]])
6866 ; CHECK-NEXT: [[TMP11:%.*]] = fmul fast float [[TMP10]], 0x41EFFFFFC0000000
6867 ; CHECK-NEXT: [[TMP12:%.*]] = fptoui float [[TMP11]] to i32
6868 ; CHECK-NEXT: [[TMP13:%.*]] = sub i32 0, [[TMP8]]
6869 ; CHECK-NEXT: [[TMP14:%.*]] = mul i32 [[TMP13]], [[TMP12]]
6870 ; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP12]] to i64
6871 ; CHECK-NEXT: [[TMP16:%.*]] = zext i32 [[TMP14]] to i64
6872 ; CHECK-NEXT: [[TMP17:%.*]] = mul i64 [[TMP15]], [[TMP16]]
6873 ; CHECK-NEXT: [[TMP18:%.*]] = trunc i64 [[TMP17]] to i32
6874 ; CHECK-NEXT: [[TMP19:%.*]] = lshr i64 [[TMP17]], 32
6875 ; CHECK-NEXT: [[TMP20:%.*]] = trunc i64 [[TMP19]] to i32
6876 ; CHECK-NEXT: [[TMP21:%.*]] = add i32 [[TMP12]], [[TMP20]]
6877 ; CHECK-NEXT: [[TMP22:%.*]] = zext i32 [[TMP7]] to i64
6878 ; CHECK-NEXT: [[TMP23:%.*]] = zext i32 [[TMP21]] to i64
6879 ; CHECK-NEXT: [[TMP24:%.*]] = mul i64 [[TMP22]], [[TMP23]]
6880 ; CHECK-NEXT: [[TMP25:%.*]] = trunc i64 [[TMP24]] to i32
6881 ; CHECK-NEXT: [[TMP26:%.*]] = lshr i64 [[TMP24]], 32
6882 ; CHECK-NEXT: [[TMP27:%.*]] = trunc i64 [[TMP26]] to i32
6883 ; CHECK-NEXT: [[TMP28:%.*]] = mul i32 [[TMP27]], [[TMP8]]
6884 ; CHECK-NEXT: [[TMP29:%.*]] = sub i32 [[TMP7]], [[TMP28]]
6885 ; CHECK-NEXT: [[TMP30:%.*]] = icmp uge i32 [[TMP29]], [[TMP8]]
6886 ; CHECK-NEXT: [[TMP31:%.*]] = sub i32 [[TMP29]], [[TMP8]]
6887 ; CHECK-NEXT: [[TMP32:%.*]] = select i1 [[TMP30]], i32 [[TMP31]], i32 [[TMP29]]
6888 ; CHECK-NEXT: [[TMP33:%.*]] = icmp uge i32 [[TMP32]], [[TMP8]]
6889 ; CHECK-NEXT: [[TMP34:%.*]] = sub i32 [[TMP32]], [[TMP8]]
6890 ; CHECK-NEXT: [[TMP35:%.*]] = select i1 [[TMP33]], i32 [[TMP34]], i32 [[TMP32]]
6891 ; CHECK-NEXT: [[TMP36:%.*]] = xor i32 [[TMP35]], [[TMP3]]
6892 ; CHECK-NEXT: [[TMP37:%.*]] = sub i32 [[TMP36]], [[TMP3]]
6893 ; CHECK-NEXT: [[TMP38:%.*]] = insertelement <2 x i32> poison, i32 [[TMP37]], i64 0
6894 ; CHECK-NEXT: [[TMP39:%.*]] = extractelement <2 x i32> [[X]], i64 1
6895 ; CHECK-NEXT: [[TMP40:%.*]] = extractelement <2 x i32> [[SHL_Y]], i64 1
6896 ; CHECK-NEXT: [[TMP41:%.*]] = ashr i32 [[TMP39]], 31
6897 ; CHECK-NEXT: [[TMP42:%.*]] = ashr i32 [[TMP40]], 31
6898 ; CHECK-NEXT: [[TMP43:%.*]] = add i32 [[TMP39]], [[TMP41]]
6899 ; CHECK-NEXT: [[TMP44:%.*]] = add i32 [[TMP40]], [[TMP42]]
6900 ; CHECK-NEXT: [[TMP45:%.*]] = xor i32 [[TMP43]], [[TMP41]]
6901 ; CHECK-NEXT: [[TMP46:%.*]] = xor i32 [[TMP44]], [[TMP42]]
6902 ; CHECK-NEXT: [[TMP47:%.*]] = uitofp i32 [[TMP46]] to float
6903 ; CHECK-NEXT: [[TMP48:%.*]] = call fast float @llvm.amdgcn.rcp.f32(float [[TMP47]])
6904 ; CHECK-NEXT: [[TMP49:%.*]] = fmul fast float [[TMP48]], 0x41EFFFFFC0000000
6905 ; CHECK-NEXT: [[TMP50:%.*]] = fptoui float [[TMP49]] to i32
6906 ; CHECK-NEXT: [[TMP51:%.*]] = sub i32 0, [[TMP46]]
6907 ; CHECK-NEXT: [[TMP52:%.*]] = mul i32 [[TMP51]], [[TMP50]]
6908 ; CHECK-NEXT: [[TMP53:%.*]] = zext i32 [[TMP50]] to i64
6909 ; CHECK-NEXT: [[TMP54:%.*]] = zext i32 [[TMP52]] to i64
6910 ; CHECK-NEXT: [[TMP55:%.*]] = mul i64 [[TMP53]], [[TMP54]]
6911 ; CHECK-NEXT: [[TMP56:%.*]] = trunc i64 [[TMP55]] to i32
6912 ; CHECK-NEXT: [[TMP57:%.*]] = lshr i64 [[TMP55]], 32
6913 ; CHECK-NEXT: [[TMP58:%.*]] = trunc i64 [[TMP57]] to i32
6914 ; CHECK-NEXT: [[TMP59:%.*]] = add i32 [[TMP50]], [[TMP58]]
6915 ; CHECK-NEXT: [[TMP60:%.*]] = zext i32 [[TMP45]] to i64
6916 ; CHECK-NEXT: [[TMP61:%.*]] = zext i32 [[TMP59]] to i64
6917 ; CHECK-NEXT: [[TMP62:%.*]] = mul i64 [[TMP60]], [[TMP61]]
6918 ; CHECK-NEXT: [[TMP63:%.*]] = trunc i64 [[TMP62]] to i32
6919 ; CHECK-NEXT: [[TMP64:%.*]] = lshr i64 [[TMP62]], 32
6920 ; CHECK-NEXT: [[TMP65:%.*]] = trunc i64 [[TMP64]] to i32
6921 ; CHECK-NEXT: [[TMP66:%.*]] = mul i32 [[TMP65]], [[TMP46]]
6922 ; CHECK-NEXT: [[TMP67:%.*]] = sub i32 [[TMP45]], [[TMP66]]
6923 ; CHECK-NEXT: [[TMP68:%.*]] = icmp uge i32 [[TMP67]], [[TMP46]]
6924 ; CHECK-NEXT: [[TMP69:%.*]] = sub i32 [[TMP67]], [[TMP46]]
6925 ; CHECK-NEXT: [[TMP70:%.*]] = select i1 [[TMP68]], i32 [[TMP69]], i32 [[TMP67]]
6926 ; CHECK-NEXT: [[TMP71:%.*]] = icmp uge i32 [[TMP70]], [[TMP46]]
6927 ; CHECK-NEXT: [[TMP72:%.*]] = sub i32 [[TMP70]], [[TMP46]]
6928 ; CHECK-NEXT: [[TMP73:%.*]] = select i1 [[TMP71]], i32 [[TMP72]], i32 [[TMP70]]
6929 ; CHECK-NEXT: [[TMP74:%.*]] = xor i32 [[TMP73]], [[TMP41]]
6930 ; CHECK-NEXT: [[TMP75:%.*]] = sub i32 [[TMP74]], [[TMP41]]
6931 ; CHECK-NEXT: [[TMP76:%.*]] = insertelement <2 x i32> [[TMP38]], i32 [[TMP75]], i64 1
6932 ; CHECK-NEXT: store <2 x i32> [[TMP76]], ptr addrspace(1) [[OUT:%.*]], align 8
6933 ; CHECK-NEXT: ret void
6935 ; GFX6-LABEL: srem_v2i32_pow2_shl_denom:
6937 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xb
6938 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6939 ; GFX6-NEXT: s_lshl_b32 s0, 0x1000, s6
6940 ; GFX6-NEXT: s_abs_i32 s0, s0
6941 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s0
6942 ; GFX6-NEXT: s_sub_i32 s1, 0, s0
6943 ; GFX6-NEXT: s_lshl_b32 s6, 0x1000, s7
6944 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6945 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6946 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6947 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v0
6948 ; GFX6-NEXT: s_abs_i32 s1, s4
6949 ; GFX6-NEXT: s_ashr_i32 s4, s4, 31
6950 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6951 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6952 ; GFX6-NEXT: v_mul_hi_u32 v0, s1, v0
6953 ; GFX6-NEXT: v_readfirstlane_b32 s7, v0
6954 ; GFX6-NEXT: s_mul_i32 s7, s7, s0
6955 ; GFX6-NEXT: s_sub_i32 s1, s1, s7
6956 ; GFX6-NEXT: s_sub_i32 s7, s1, s0
6957 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
6958 ; GFX6-NEXT: s_cselect_b32 s1, s7, s1
6959 ; GFX6-NEXT: s_sub_i32 s7, s1, s0
6960 ; GFX6-NEXT: s_cmp_ge_u32 s1, s0
6961 ; GFX6-NEXT: s_cselect_b32 s7, s7, s1
6962 ; GFX6-NEXT: s_abs_i32 s6, s6
6963 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s6
6964 ; GFX6-NEXT: s_sub_i32 s0, 0, s6
6965 ; GFX6-NEXT: s_abs_i32 s8, s5
6966 ; GFX6-NEXT: s_xor_b32 s7, s7, s4
6967 ; GFX6-NEXT: v_rcp_iflag_f32_e32 v0, v0
6968 ; GFX6-NEXT: s_sub_i32 s4, s7, s4
6969 ; GFX6-NEXT: s_ashr_i32 s5, s5, 31
6970 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
6971 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
6972 ; GFX6-NEXT: v_mul_lo_u32 v1, s0, v0
6973 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
6974 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
6975 ; GFX6-NEXT: s_mov_b32 s2, -1
6976 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, v1
6977 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
6978 ; GFX6-NEXT: v_mul_hi_u32 v0, s8, v0
6979 ; GFX6-NEXT: v_readfirstlane_b32 s7, v0
6980 ; GFX6-NEXT: s_mul_i32 s7, s7, s6
6981 ; GFX6-NEXT: s_sub_i32 s7, s8, s7
6982 ; GFX6-NEXT: s_sub_i32 s8, s7, s6
6983 ; GFX6-NEXT: s_cmp_ge_u32 s7, s6
6984 ; GFX6-NEXT: s_cselect_b32 s7, s8, s7
6985 ; GFX6-NEXT: s_sub_i32 s8, s7, s6
6986 ; GFX6-NEXT: s_cmp_ge_u32 s7, s6
6987 ; GFX6-NEXT: s_cselect_b32 s6, s8, s7
6988 ; GFX6-NEXT: s_xor_b32 s6, s6, s5
6989 ; GFX6-NEXT: s_sub_i32 s5, s6, s5
6990 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6991 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6992 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6993 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
6994 ; GFX6-NEXT: s_endpgm
6996 ; GFX9-LABEL: srem_v2i32_pow2_shl_denom:
6998 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x2c
6999 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7000 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7001 ; GFX9-NEXT: s_lshl_b32 s0, 0x1000, s6
7002 ; GFX9-NEXT: s_abs_i32 s0, s0
7003 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s0
7004 ; GFX9-NEXT: s_lshl_b32 s1, 0x1000, s7
7005 ; GFX9-NEXT: s_sub_i32 s7, 0, s0
7006 ; GFX9-NEXT: s_ashr_i32 s6, s4, 31
7007 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
7008 ; GFX9-NEXT: s_abs_i32 s4, s4
7009 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
7010 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
7011 ; GFX9-NEXT: v_readfirstlane_b32 s8, v0
7012 ; GFX9-NEXT: s_mul_i32 s7, s7, s8
7013 ; GFX9-NEXT: s_mul_hi_u32 s7, s8, s7
7014 ; GFX9-NEXT: s_add_i32 s8, s8, s7
7015 ; GFX9-NEXT: s_mul_hi_u32 s7, s4, s8
7016 ; GFX9-NEXT: s_mul_i32 s7, s7, s0
7017 ; GFX9-NEXT: s_sub_i32 s4, s4, s7
7018 ; GFX9-NEXT: s_sub_i32 s7, s4, s0
7019 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
7020 ; GFX9-NEXT: s_cselect_b32 s4, s7, s4
7021 ; GFX9-NEXT: s_sub_i32 s7, s4, s0
7022 ; GFX9-NEXT: s_cmp_ge_u32 s4, s0
7023 ; GFX9-NEXT: s_cselect_b32 s4, s7, s4
7024 ; GFX9-NEXT: s_abs_i32 s7, s1
7025 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s7
7026 ; GFX9-NEXT: s_xor_b32 s4, s4, s6
7027 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
7028 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
7029 ; GFX9-NEXT: v_rcp_iflag_f32_e32 v0, v0
7030 ; GFX9-NEXT: s_abs_i32 s3, s5
7031 ; GFX9-NEXT: s_sub_i32 s5, 0, s7
7032 ; GFX9-NEXT: s_sub_i32 s4, s4, s6
7033 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
7034 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
7035 ; GFX9-NEXT: v_readfirstlane_b32 s6, v0
7036 ; GFX9-NEXT: s_mul_i32 s5, s5, s6
7037 ; GFX9-NEXT: s_mul_hi_u32 s5, s6, s5
7038 ; GFX9-NEXT: s_add_i32 s6, s6, s5
7039 ; GFX9-NEXT: s_mul_hi_u32 s5, s3, s6
7040 ; GFX9-NEXT: s_mul_i32 s5, s5, s7
7041 ; GFX9-NEXT: s_sub_i32 s3, s3, s5
7042 ; GFX9-NEXT: s_sub_i32 s5, s3, s7
7043 ; GFX9-NEXT: s_cmp_ge_u32 s3, s7
7044 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
7045 ; GFX9-NEXT: s_sub_i32 s5, s3, s7
7046 ; GFX9-NEXT: s_cmp_ge_u32 s3, s7
7047 ; GFX9-NEXT: s_cselect_b32 s3, s5, s3
7048 ; GFX9-NEXT: s_xor_b32 s3, s3, s2
7049 ; GFX9-NEXT: s_sub_i32 s2, s3, s2
7050 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
7051 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
7052 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7053 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1]
7054 ; GFX9-NEXT: s_endpgm
7055 %shl.y = shl <2 x i32> <i32 4096, i32 4096>, %y
7056 %r = srem <2 x i32> %x, %shl.y
7057 store <2 x i32> %r, ptr addrspace(1) %out
7061 define amdgpu_kernel void @udiv_i64_oddk_denom(ptr addrspace(1) %out, i64 %x) {
7062 ; CHECK-LABEL: @udiv_i64_oddk_denom(
7063 ; CHECK-NEXT: [[R:%.*]] = udiv i64 [[X:%.*]], 1235195949943
7064 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7065 ; CHECK-NEXT: ret void
7067 ; GFX6-LABEL: udiv_i64_oddk_denom:
7069 ; GFX6-NEXT: s_add_u32 s4, 3, 0
7070 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xe3e0f6
7071 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s4, v0
7072 ; GFX6-NEXT: s_addc_u32 s5, 0, 0
7073 ; GFX6-NEXT: s_or_b32 s4, vcc_lo, vcc_hi
7074 ; GFX6-NEXT: s_cmp_lg_u32 s4, 0
7075 ; GFX6-NEXT: s_mov_b32 s4, 0x68958c89
7076 ; GFX6-NEXT: s_movk_i32 s6, 0xfee0
7077 ; GFX6-NEXT: v_mul_lo_u32 v1, v0, s6
7078 ; GFX6-NEXT: v_mul_hi_u32 v2, v0, s4
7079 ; GFX6-NEXT: s_addc_u32 s5, s5, 0
7080 ; GFX6-NEXT: s_mul_i32 s6, s5, 0x68958c89
7081 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
7082 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
7083 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s4
7084 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s6, v1
7085 ; GFX6-NEXT: v_mul_lo_u32 v3, v0, v1
7086 ; GFX6-NEXT: v_mul_hi_u32 v4, v0, v2
7087 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, v1
7088 ; GFX6-NEXT: v_mul_hi_u32 v6, s5, v1
7089 ; GFX6-NEXT: v_mul_lo_u32 v1, s5, v1
7090 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v4, v3
7091 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v5, vcc
7092 ; GFX6-NEXT: v_mul_lo_u32 v5, s5, v2
7093 ; GFX6-NEXT: v_mul_hi_u32 v2, s5, v2
7094 ; GFX6-NEXT: s_movk_i32 s8, 0x11f
7095 ; GFX6-NEXT: s_mov_b32 s9, 0x976a7377
7096 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
7097 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v4, v2, vcc
7098 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v6, vcc
7099 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
7100 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
7101 ; GFX6-NEXT: v_mov_b32_e32 v3, s5
7102 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7103 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
7104 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7105 ; GFX6-NEXT: v_mul_lo_u32 v2, s2, v1
7106 ; GFX6-NEXT: v_mul_hi_u32 v3, s2, v0
7107 ; GFX6-NEXT: v_mul_hi_u32 v4, s2, v1
7108 ; GFX6-NEXT: v_mul_hi_u32 v5, s3, v1
7109 ; GFX6-NEXT: v_mul_lo_u32 v1, s3, v1
7110 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
7111 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
7112 ; GFX6-NEXT: v_mul_lo_u32 v4, s3, v0
7113 ; GFX6-NEXT: v_mul_hi_u32 v0, s3, v0
7114 ; GFX6-NEXT: s_mov_b32 s4, s0
7115 ; GFX6-NEXT: s_mov_b32 s5, s1
7116 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
7117 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
7118 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
7119 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7120 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
7121 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s8
7122 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, s9
7123 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, s9
7124 ; GFX6-NEXT: v_mov_b32_e32 v5, 0x11f
7125 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
7126 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
7127 ; GFX6-NEXT: v_mul_lo_u32 v3, v0, s9
7128 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v4, v2
7129 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s3, v2
7130 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s2, v3
7131 ; GFX6-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc
7132 ; GFX6-NEXT: v_subrev_i32_e64 v5, s[0:1], s9, v3
7133 ; GFX6-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1]
7134 ; GFX6-NEXT: s_movk_i32 s2, 0x11e
7135 ; GFX6-NEXT: v_cmp_lt_u32_e64 s[0:1], s2, v4
7136 ; GFX6-NEXT: s_mov_b32 s9, 0x976a7376
7137 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[0:1]
7138 ; GFX6-NEXT: v_cmp_lt_u32_e64 s[0:1], s9, v5
7139 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[0:1]
7140 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[0:1], s8, v4
7141 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v6, v5, s[0:1]
7142 ; GFX6-NEXT: v_add_i32_e64 v5, s[0:1], 1, v0
7143 ; GFX6-NEXT: v_addc_u32_e64 v6, s[0:1], 0, v1, s[0:1]
7144 ; GFX6-NEXT: v_add_i32_e64 v7, s[0:1], 2, v0
7145 ; GFX6-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v1, s[0:1]
7146 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v4
7147 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v5, v7, s[0:1]
7148 ; GFX6-NEXT: v_cndmask_b32_e64 v5, v6, v8, s[0:1]
7149 ; GFX6-NEXT: v_mov_b32_e32 v6, s3
7150 ; GFX6-NEXT: v_subb_u32_e32 v2, vcc, v6, v2, vcc
7151 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s2, v2
7152 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
7153 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s9, v3
7154 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
7155 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s8, v2
7156 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v6, v3, vcc
7157 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
7158 ; GFX6-NEXT: s_mov_b32 s6, -1
7159 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc
7160 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
7161 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
7162 ; GFX6-NEXT: s_endpgm
7164 ; GFX9-LABEL: udiv_i64_oddk_denom:
7166 ; GFX9-NEXT: s_add_u32 s0, 3, 0
7167 ; GFX9-NEXT: v_mov_b32_e32 v0, 0xe3e0f6
7168 ; GFX9-NEXT: s_addc_u32 s1, 0, 0
7169 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
7170 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7171 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7172 ; GFX9-NEXT: v_readfirstlane_b32 s2, v0
7173 ; GFX9-NEXT: s_addc_u32 s0, s1, 0
7174 ; GFX9-NEXT: s_mul_i32 s3, s2, 0xfffffee0
7175 ; GFX9-NEXT: s_mul_hi_u32 s8, s2, 0x68958c89
7176 ; GFX9-NEXT: s_mul_i32 s1, s0, 0x68958c89
7177 ; GFX9-NEXT: s_add_i32 s3, s8, s3
7178 ; GFX9-NEXT: s_add_i32 s3, s3, s1
7179 ; GFX9-NEXT: s_mul_i32 s9, s2, 0x68958c89
7180 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
7181 ; GFX9-NEXT: s_mul_i32 s8, s2, s3
7182 ; GFX9-NEXT: s_mul_hi_u32 s2, s2, s9
7183 ; GFX9-NEXT: s_add_u32 s2, s2, s8
7184 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
7185 ; GFX9-NEXT: s_mul_hi_u32 s10, s0, s9
7186 ; GFX9-NEXT: s_mul_i32 s9, s0, s9
7187 ; GFX9-NEXT: s_add_u32 s2, s2, s9
7188 ; GFX9-NEXT: s_mul_hi_u32 s8, s0, s3
7189 ; GFX9-NEXT: s_addc_u32 s1, s1, s10
7190 ; GFX9-NEXT: s_addc_u32 s2, s8, 0
7191 ; GFX9-NEXT: s_mul_i32 s3, s0, s3
7192 ; GFX9-NEXT: s_add_u32 s1, s1, s3
7193 ; GFX9-NEXT: s_addc_u32 s2, 0, s2
7194 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s1, v0
7195 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7196 ; GFX9-NEXT: s_addc_u32 s0, s0, s2
7197 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
7198 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7199 ; GFX9-NEXT: s_mul_i32 s2, s6, s0
7200 ; GFX9-NEXT: s_mul_hi_u32 s8, s6, s3
7201 ; GFX9-NEXT: s_mul_hi_u32 s1, s6, s0
7202 ; GFX9-NEXT: s_add_u32 s2, s8, s2
7203 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
7204 ; GFX9-NEXT: s_mul_hi_u32 s9, s7, s3
7205 ; GFX9-NEXT: s_mul_i32 s3, s7, s3
7206 ; GFX9-NEXT: s_add_u32 s2, s2, s3
7207 ; GFX9-NEXT: s_mul_hi_u32 s8, s7, s0
7208 ; GFX9-NEXT: s_addc_u32 s1, s1, s9
7209 ; GFX9-NEXT: s_addc_u32 s2, s8, 0
7210 ; GFX9-NEXT: s_mul_i32 s0, s7, s0
7211 ; GFX9-NEXT: s_add_u32 s3, s1, s0
7212 ; GFX9-NEXT: s_addc_u32 s2, 0, s2
7213 ; GFX9-NEXT: s_mul_i32 s0, s3, 0x11f
7214 ; GFX9-NEXT: s_mul_hi_u32 s8, s3, 0x976a7377
7215 ; GFX9-NEXT: s_add_i32 s0, s8, s0
7216 ; GFX9-NEXT: s_mul_i32 s8, s2, 0x976a7377
7217 ; GFX9-NEXT: s_mul_i32 s9, s3, 0x976a7377
7218 ; GFX9-NEXT: s_add_i32 s8, s0, s8
7219 ; GFX9-NEXT: v_mov_b32_e32 v0, s9
7220 ; GFX9-NEXT: s_sub_i32 s0, s7, s8
7221 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s6, v0
7222 ; GFX9-NEXT: s_mov_b32 s1, 0x976a7377
7223 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7224 ; GFX9-NEXT: s_subb_u32 s6, s0, 0x11f
7225 ; GFX9-NEXT: v_subrev_co_u32_e64 v1, s[0:1], s1, v0
7226 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
7227 ; GFX9-NEXT: s_subb_u32 s6, s6, 0
7228 ; GFX9-NEXT: s_cmpk_gt_u32 s6, 0x11e
7229 ; GFX9-NEXT: s_mov_b32 s10, 0x976a7376
7230 ; GFX9-NEXT: s_cselect_b32 s9, -1, 0
7231 ; GFX9-NEXT: v_cmp_lt_u32_e64 s[0:1], s10, v1
7232 ; GFX9-NEXT: s_cmpk_eq_i32 s6, 0x11f
7233 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, -1, s[0:1]
7234 ; GFX9-NEXT: v_mov_b32_e32 v3, s9
7235 ; GFX9-NEXT: s_cselect_b64 s[0:1], -1, 0
7236 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v3, v1, s[0:1]
7237 ; GFX9-NEXT: s_add_u32 s0, s3, 1
7238 ; GFX9-NEXT: s_addc_u32 s6, s2, 0
7239 ; GFX9-NEXT: s_add_u32 s1, s3, 2
7240 ; GFX9-NEXT: s_addc_u32 s9, s2, 0
7241 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
7242 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
7243 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v1
7244 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v3, v4, s[0:1]
7245 ; GFX9-NEXT: v_mov_b32_e32 v1, s6
7246 ; GFX9-NEXT: v_mov_b32_e32 v4, s9
7247 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7248 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, v4, s[0:1]
7249 ; GFX9-NEXT: s_subb_u32 s0, s7, s8
7250 ; GFX9-NEXT: s_cmpk_gt_u32 s0, 0x11e
7251 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
7252 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s10, v0
7253 ; GFX9-NEXT: s_cmpk_eq_i32 s0, 0x11f
7254 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
7255 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
7256 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
7257 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v4, v0, vcc
7258 ; GFX9-NEXT: v_mov_b32_e32 v4, s2
7259 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
7260 ; GFX9-NEXT: v_mov_b32_e32 v0, s3
7261 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7262 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v4, v1, vcc
7263 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
7264 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
7265 ; GFX9-NEXT: s_endpgm
7266 %r = udiv i64 %x, 1235195949943
7267 store i64 %r, ptr addrspace(1) %out
7271 define amdgpu_kernel void @udiv_i64_pow2k_denom(ptr addrspace(1) %out, i64 %x) {
7272 ; CHECK-LABEL: @udiv_i64_pow2k_denom(
7273 ; CHECK-NEXT: [[R:%.*]] = udiv i64 [[X:%.*]], 4096
7274 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7275 ; CHECK-NEXT: ret void
7277 ; GFX6-LABEL: udiv_i64_pow2k_denom:
7279 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
7280 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
7281 ; GFX6-NEXT: s_mov_b32 s6, -1
7282 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7283 ; GFX6-NEXT: s_mov_b32 s4, s0
7284 ; GFX6-NEXT: s_mov_b32 s5, s1
7285 ; GFX6-NEXT: s_lshr_b64 s[0:1], s[2:3], 12
7286 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
7287 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
7288 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
7289 ; GFX6-NEXT: s_endpgm
7291 ; GFX9-LABEL: udiv_i64_pow2k_denom:
7293 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7294 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7295 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7296 ; GFX9-NEXT: s_lshr_b64 s[0:1], s[6:7], 12
7297 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
7298 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
7299 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
7300 ; GFX9-NEXT: s_endpgm
7301 %r = udiv i64 %x, 4096
7302 store i64 %r, ptr addrspace(1) %out
7306 define amdgpu_kernel void @udiv_i64_pow2_shl_denom(ptr addrspace(1) %out, i64 %x, i64 %y) {
7307 ; CHECK-LABEL: @udiv_i64_pow2_shl_denom(
7308 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i64 4096, [[Y:%.*]]
7309 ; CHECK-NEXT: [[R:%.*]] = udiv i64 [[X:%.*]], [[SHL_Y]]
7310 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7311 ; CHECK-NEXT: ret void
7313 ; GFX6-LABEL: udiv_i64_pow2_shl_denom:
7315 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
7316 ; GFX6-NEXT: s_load_dword s8, s[2:3], 0xd
7317 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
7318 ; GFX6-NEXT: s_mov_b32 s2, -1
7319 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7320 ; GFX6-NEXT: s_mov_b32 s0, s4
7321 ; GFX6-NEXT: s_add_i32 s8, s8, 12
7322 ; GFX6-NEXT: s_mov_b32 s1, s5
7323 ; GFX6-NEXT: s_lshr_b64 s[4:5], s[6:7], s8
7324 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7325 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7326 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
7327 ; GFX6-NEXT: s_endpgm
7329 ; GFX9-LABEL: udiv_i64_pow2_shl_denom:
7331 ; GFX9-NEXT: s_load_dword s0, s[2:3], 0x34
7332 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7333 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7334 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7335 ; GFX9-NEXT: s_add_i32 s0, s0, 12
7336 ; GFX9-NEXT: s_lshr_b64 s[0:1], s[6:7], s0
7337 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
7338 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
7339 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
7340 ; GFX9-NEXT: s_endpgm
7341 %shl.y = shl i64 4096, %y
7342 %r = udiv i64 %x, %shl.y
7343 store i64 %r, ptr addrspace(1) %out
7347 define amdgpu_kernel void @udiv_v2i64_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
7348 ; CHECK-LABEL: @udiv_v2i64_pow2k_denom(
7349 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
7350 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[TMP1]], 4096
7351 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
7352 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
7353 ; CHECK-NEXT: [[TMP5:%.*]] = udiv i64 [[TMP4]], 4096
7354 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
7355 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
7356 ; CHECK-NEXT: ret void
7358 ; GFX6-LABEL: udiv_v2i64_pow2k_denom:
7360 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
7361 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
7362 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
7363 ; GFX6-NEXT: s_mov_b32 s2, -1
7364 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7365 ; GFX6-NEXT: s_lshr_b64 s[4:5], s[4:5], 12
7366 ; GFX6-NEXT: s_lshr_b64 s[6:7], s[6:7], 12
7367 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7368 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7369 ; GFX6-NEXT: v_mov_b32_e32 v2, s6
7370 ; GFX6-NEXT: v_mov_b32_e32 v3, s7
7371 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
7372 ; GFX6-NEXT: s_endpgm
7374 ; GFX9-LABEL: udiv_v2i64_pow2k_denom:
7376 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
7377 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
7378 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
7379 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7380 ; GFX9-NEXT: s_lshr_b64 s[2:3], s[4:5], 12
7381 ; GFX9-NEXT: s_lshr_b64 s[4:5], s[6:7], 12
7382 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
7383 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
7384 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
7385 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
7386 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
7387 ; GFX9-NEXT: s_endpgm
7388 %r = udiv <2 x i64> %x, <i64 4096, i64 4096>
7389 store <2 x i64> %r, ptr addrspace(1) %out
7393 define amdgpu_kernel void @udiv_v2i64_mixed_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
7394 ; CHECK-LABEL: @udiv_v2i64_mixed_pow2k_denom(
7395 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
7396 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[TMP1]], 4096
7397 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
7398 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
7399 ; CHECK-NEXT: [[TMP5:%.*]] = udiv i64 [[TMP4]], 4095
7400 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
7401 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
7402 ; CHECK-NEXT: ret void
7404 ; GFX6-LABEL: udiv_v2i64_mixed_pow2k_denom:
7406 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
7407 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
7408 ; GFX6-NEXT: s_mov_b32 s2, 0x2ff2fc01
7409 ; GFX6-NEXT: v_bfrev_b32_e32 v0, 7
7410 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7411 ; GFX6-NEXT: s_lshr_b64 s[4:5], s[4:5], 12
7412 ; GFX6-NEXT: s_add_u32 s2, 0xe037f, s2
7413 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s2, v0
7414 ; GFX6-NEXT: s_addc_u32 s3, 0, 0
7415 ; GFX6-NEXT: s_or_b32 s2, vcc_lo, vcc_hi
7416 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
7417 ; GFX6-NEXT: s_movk_i32 s2, 0xf001
7418 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, s2
7419 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s2
7420 ; GFX6-NEXT: s_addc_u32 s8, s3, 0x1000ff
7421 ; GFX6-NEXT: s_mul_i32 s3, s8, 0xfffff001
7422 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v0
7423 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s3, v1
7424 ; GFX6-NEXT: v_mul_lo_u32 v3, v0, v1
7425 ; GFX6-NEXT: v_mul_hi_u32 v4, v0, v2
7426 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, v1
7427 ; GFX6-NEXT: v_mul_hi_u32 v6, s8, v1
7428 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v1
7429 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v4, v3
7430 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v5, vcc
7431 ; GFX6-NEXT: v_mul_lo_u32 v5, s8, v2
7432 ; GFX6-NEXT: v_mul_hi_u32 v2, s8, v2
7433 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
7434 ; GFX6-NEXT: s_mov_b32 s2, -1
7435 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
7436 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v4, v2, vcc
7437 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v6, vcc
7438 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
7439 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
7440 ; GFX6-NEXT: v_mov_b32_e32 v3, s8
7441 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7442 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
7443 ; GFX6-NEXT: v_mul_lo_u32 v2, s6, v1
7444 ; GFX6-NEXT: v_mul_hi_u32 v3, s6, v0
7445 ; GFX6-NEXT: v_mul_hi_u32 v4, s6, v1
7446 ; GFX6-NEXT: v_mul_hi_u32 v5, s7, v1
7447 ; GFX6-NEXT: v_mul_lo_u32 v1, s7, v1
7448 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
7449 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
7450 ; GFX6-NEXT: v_mul_lo_u32 v4, s7, v0
7451 ; GFX6-NEXT: v_mul_hi_u32 v0, s7, v0
7452 ; GFX6-NEXT: s_movk_i32 s8, 0xfff
7453 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
7454 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
7455 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
7456 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7457 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
7458 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, s8
7459 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, s8
7460 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
7461 ; GFX6-NEXT: v_mul_lo_u32 v8, v0, s8
7462 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
7463 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 2, v0
7464 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
7465 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
7466 ; GFX6-NEXT: v_mov_b32_e32 v5, s7
7467 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s6, v8
7468 ; GFX6-NEXT: v_subb_u32_e32 v4, vcc, v5, v4, vcc
7469 ; GFX6-NEXT: v_subrev_i32_e32 v5, vcc, s8, v8
7470 ; GFX6-NEXT: v_subbrev_u32_e32 v9, vcc, 0, v4, vcc
7471 ; GFX6-NEXT: s_movk_i32 s6, 0xffe
7472 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s6, v5
7473 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
7474 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v9
7475 ; GFX6-NEXT: v_cndmask_b32_e32 v5, -1, v5, vcc
7476 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5
7477 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v6, vcc
7478 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v7, vcc
7479 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s6, v8
7480 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
7481 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v4
7482 ; GFX6-NEXT: v_cndmask_b32_e32 v4, -1, v5, vcc
7483 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
7484 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v1, v3, vcc
7485 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v0, v2, vcc
7486 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7487 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7488 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
7489 ; GFX6-NEXT: s_endpgm
7491 ; GFX9-LABEL: udiv_v2i64_mixed_pow2k_denom:
7493 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
7494 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
7495 ; GFX9-NEXT: s_mov_b32 s8, 0x2ff2fc01
7496 ; GFX9-NEXT: v_bfrev_b32_e32 v0, 7
7497 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
7498 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7499 ; GFX9-NEXT: s_lshr_b64 s[2:3], s[4:5], 12
7500 ; GFX9-NEXT: s_add_u32 s4, 0xe037f, s8
7501 ; GFX9-NEXT: s_addc_u32 s5, 0, 0
7502 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s4, v0
7503 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7504 ; GFX9-NEXT: v_readfirstlane_b32 s8, v0
7505 ; GFX9-NEXT: s_addc_u32 s4, s5, 0x1000ff
7506 ; GFX9-NEXT: s_mul_hi_u32 s9, s8, 0xfffff001
7507 ; GFX9-NEXT: s_mul_i32 s5, s4, 0xfffff001
7508 ; GFX9-NEXT: s_sub_i32 s9, s9, s8
7509 ; GFX9-NEXT: s_add_i32 s9, s9, s5
7510 ; GFX9-NEXT: s_mul_i32 s11, s8, 0xfffff001
7511 ; GFX9-NEXT: s_mul_hi_u32 s5, s8, s9
7512 ; GFX9-NEXT: s_mul_i32 s10, s8, s9
7513 ; GFX9-NEXT: s_mul_hi_u32 s8, s8, s11
7514 ; GFX9-NEXT: s_add_u32 s8, s8, s10
7515 ; GFX9-NEXT: s_addc_u32 s5, 0, s5
7516 ; GFX9-NEXT: s_mul_hi_u32 s12, s4, s11
7517 ; GFX9-NEXT: s_mul_i32 s11, s4, s11
7518 ; GFX9-NEXT: s_add_u32 s8, s8, s11
7519 ; GFX9-NEXT: s_mul_hi_u32 s10, s4, s9
7520 ; GFX9-NEXT: s_addc_u32 s5, s5, s12
7521 ; GFX9-NEXT: s_addc_u32 s8, s10, 0
7522 ; GFX9-NEXT: s_mul_i32 s9, s4, s9
7523 ; GFX9-NEXT: s_add_u32 s5, s5, s9
7524 ; GFX9-NEXT: s_addc_u32 s8, 0, s8
7525 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s5, v0
7526 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7527 ; GFX9-NEXT: s_addc_u32 s4, s4, s8
7528 ; GFX9-NEXT: v_readfirstlane_b32 s9, v0
7529 ; GFX9-NEXT: s_mul_i32 s8, s6, s4
7530 ; GFX9-NEXT: s_mul_hi_u32 s10, s6, s9
7531 ; GFX9-NEXT: s_mul_hi_u32 s5, s6, s4
7532 ; GFX9-NEXT: s_add_u32 s8, s10, s8
7533 ; GFX9-NEXT: s_addc_u32 s5, 0, s5
7534 ; GFX9-NEXT: s_mul_hi_u32 s11, s7, s9
7535 ; GFX9-NEXT: s_mul_i32 s9, s7, s9
7536 ; GFX9-NEXT: s_add_u32 s8, s8, s9
7537 ; GFX9-NEXT: s_mul_hi_u32 s10, s7, s4
7538 ; GFX9-NEXT: s_addc_u32 s5, s5, s11
7539 ; GFX9-NEXT: s_addc_u32 s8, s10, 0
7540 ; GFX9-NEXT: s_mul_i32 s4, s7, s4
7541 ; GFX9-NEXT: s_add_u32 s4, s5, s4
7542 ; GFX9-NEXT: s_addc_u32 s5, 0, s8
7543 ; GFX9-NEXT: s_add_u32 s8, s4, 1
7544 ; GFX9-NEXT: s_addc_u32 s9, s5, 0
7545 ; GFX9-NEXT: s_add_u32 s10, s4, 2
7546 ; GFX9-NEXT: s_mul_i32 s13, s5, 0xfff
7547 ; GFX9-NEXT: s_mul_hi_u32 s14, s4, 0xfff
7548 ; GFX9-NEXT: s_addc_u32 s11, s5, 0
7549 ; GFX9-NEXT: s_add_i32 s14, s14, s13
7550 ; GFX9-NEXT: s_mul_i32 s13, s4, 0xfff
7551 ; GFX9-NEXT: v_mov_b32_e32 v0, s13
7552 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s6, v0
7553 ; GFX9-NEXT: s_movk_i32 s12, 0xfff
7554 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7555 ; GFX9-NEXT: s_subb_u32 s6, s7, s14
7556 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s12, v0
7557 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7558 ; GFX9-NEXT: s_subb_u32 s7, s6, 0
7559 ; GFX9-NEXT: s_movk_i32 s12, 0xffe
7560 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s12, v1
7561 ; GFX9-NEXT: s_cmp_eq_u32 s7, 0
7562 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, -1, vcc
7563 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
7564 ; GFX9-NEXT: v_cndmask_b32_e32 v1, -1, v1, vcc
7565 ; GFX9-NEXT: v_mov_b32_e32 v2, s8
7566 ; GFX9-NEXT: v_mov_b32_e32 v3, s10
7567 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v1
7568 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v2, v3, vcc
7569 ; GFX9-NEXT: v_mov_b32_e32 v2, s9
7570 ; GFX9-NEXT: v_mov_b32_e32 v3, s11
7571 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v2, v3, vcc
7572 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s12, v0
7573 ; GFX9-NEXT: s_cmp_eq_u32 s6, 0
7574 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
7575 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
7576 ; GFX9-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
7577 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
7578 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
7579 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
7580 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v3, v2, vcc
7581 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v0, v1, vcc
7582 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
7583 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
7584 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
7585 ; GFX9-NEXT: s_endpgm
7586 %r = udiv <2 x i64> %x, <i64 4096, i64 4095>
7587 store <2 x i64> %r, ptr addrspace(1) %out
7591 define amdgpu_kernel void @udiv_v2i64_pow2_shl_denom(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
7592 ; CHECK-LABEL: @udiv_v2i64_pow2_shl_denom(
7593 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> <i64 4096, i64 4096>, [[Y:%.*]]
7594 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
7595 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0
7596 ; CHECK-NEXT: [[TMP3:%.*]] = udiv i64 [[TMP1]], [[TMP2]]
7597 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> poison, i64 [[TMP3]], i64 0
7598 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1
7599 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1
7600 ; CHECK-NEXT: [[TMP7:%.*]] = udiv i64 [[TMP5]], [[TMP6]]
7601 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1
7602 ; CHECK-NEXT: store <2 x i64> [[TMP8]], ptr addrspace(1) [[OUT:%.*]], align 16
7603 ; CHECK-NEXT: ret void
7605 ; GFX6-LABEL: udiv_v2i64_pow2_shl_denom:
7607 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
7608 ; GFX6-NEXT: s_load_dwordx2 s[12:13], s[2:3], 0x9
7609 ; GFX6-NEXT: s_mov_b32 s15, 0xf000
7610 ; GFX6-NEXT: s_mov_b32 s14, -1
7611 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7612 ; GFX6-NEXT: s_add_i32 s0, s8, 12
7613 ; GFX6-NEXT: s_add_i32 s2, s10, 12
7614 ; GFX6-NEXT: s_lshr_b64 s[0:1], s[4:5], s0
7615 ; GFX6-NEXT: s_lshr_b64 s[2:3], s[6:7], s2
7616 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
7617 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
7618 ; GFX6-NEXT: v_mov_b32_e32 v2, s2
7619 ; GFX6-NEXT: v_mov_b32_e32 v3, s3
7620 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[12:15], 0
7621 ; GFX6-NEXT: s_endpgm
7623 ; GFX9-LABEL: udiv_v2i64_pow2_shl_denom:
7625 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
7626 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
7627 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
7628 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7629 ; GFX9-NEXT: s_add_i32 s2, s8, 12
7630 ; GFX9-NEXT: s_add_i32 s8, s10, 12
7631 ; GFX9-NEXT: s_lshr_b64 s[2:3], s[4:5], s2
7632 ; GFX9-NEXT: s_lshr_b64 s[4:5], s[6:7], s8
7633 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
7634 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
7635 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
7636 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
7637 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
7638 ; GFX9-NEXT: s_endpgm
7639 %shl.y = shl <2 x i64> <i64 4096, i64 4096>, %y
7640 %r = udiv <2 x i64> %x, %shl.y
7641 store <2 x i64> %r, ptr addrspace(1) %out
7645 define amdgpu_kernel void @urem_i64_oddk_denom(ptr addrspace(1) %out, i64 %x) {
7646 ; CHECK-LABEL: @urem_i64_oddk_denom(
7647 ; CHECK-NEXT: [[R:%.*]] = urem i64 [[X:%.*]], 1235195393993
7648 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7649 ; CHECK-NEXT: ret void
7651 ; GFX6-LABEL: urem_i64_oddk_denom:
7653 ; GFX6-NEXT: s_add_u32 s0, 4, 0
7654 ; GFX6-NEXT: v_mov_b32_e32 v0, 0xe3e0fc
7655 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
7656 ; GFX6-NEXT: s_addc_u32 s1, 0, 0
7657 ; GFX6-NEXT: s_or_b32 s0, vcc_lo, vcc_hi
7658 ; GFX6-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
7659 ; GFX6-NEXT: s_cmp_lg_u32 s0, 0
7660 ; GFX6-NEXT: s_mov_b32 s0, 0x689e0837
7661 ; GFX6-NEXT: s_movk_i32 s2, 0xfee0
7662 ; GFX6-NEXT: v_mul_lo_u32 v1, v0, s2
7663 ; GFX6-NEXT: v_mul_hi_u32 v2, v0, s0
7664 ; GFX6-NEXT: s_addc_u32 s1, s1, 0
7665 ; GFX6-NEXT: s_mul_i32 s2, s1, 0x689e0837
7666 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7667 ; GFX6-NEXT: s_mov_b32 s4, s8
7668 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
7669 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s0
7670 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s2, v1
7671 ; GFX6-NEXT: v_mul_lo_u32 v3, v0, v1
7672 ; GFX6-NEXT: v_mul_hi_u32 v4, v0, v2
7673 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, v1
7674 ; GFX6-NEXT: v_mul_hi_u32 v6, s1, v1
7675 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v1
7676 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v4, v3
7677 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v5, vcc
7678 ; GFX6-NEXT: v_mul_lo_u32 v5, s1, v2
7679 ; GFX6-NEXT: v_mul_hi_u32 v2, s1, v2
7680 ; GFX6-NEXT: s_movk_i32 s8, 0x11f
7681 ; GFX6-NEXT: s_mov_b32 s12, 0x9761f7c9
7682 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
7683 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v4, v2, vcc
7684 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v6, vcc
7685 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
7686 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
7687 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
7688 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7689 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
7690 ; GFX6-NEXT: v_mul_lo_u32 v2, s10, v1
7691 ; GFX6-NEXT: v_mul_hi_u32 v3, s10, v0
7692 ; GFX6-NEXT: v_mul_hi_u32 v4, s10, v1
7693 ; GFX6-NEXT: v_mul_hi_u32 v5, s11, v1
7694 ; GFX6-NEXT: v_mul_lo_u32 v1, s11, v1
7695 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
7696 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
7697 ; GFX6-NEXT: v_mul_lo_u32 v4, s11, v0
7698 ; GFX6-NEXT: v_mul_hi_u32 v0, s11, v0
7699 ; GFX6-NEXT: s_mov_b32 s5, s9
7700 ; GFX6-NEXT: s_movk_i32 s9, 0x11e
7701 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
7702 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
7703 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
7704 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
7705 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
7706 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s8
7707 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, s12
7708 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s12
7709 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s12
7710 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
7711 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
7712 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
7713 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s11, v1
7714 ; GFX6-NEXT: v_mov_b32_e32 v3, 0x11f
7715 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s10, v0
7716 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc
7717 ; GFX6-NEXT: v_subrev_i32_e64 v4, s[0:1], s12, v0
7718 ; GFX6-NEXT: v_subbrev_u32_e64 v5, s[2:3], 0, v2, s[0:1]
7719 ; GFX6-NEXT: v_cmp_lt_u32_e64 s[2:3], s9, v5
7720 ; GFX6-NEXT: s_mov_b32 s10, 0x9761f7c8
7721 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[2:3]
7722 ; GFX6-NEXT: v_cmp_lt_u32_e64 s[2:3], s10, v4
7723 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, s[0:1]
7724 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[2:3]
7725 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[2:3], s8, v5
7726 ; GFX6-NEXT: v_subrev_i32_e64 v3, s[0:1], s12, v4
7727 ; GFX6-NEXT: v_cndmask_b32_e64 v6, v6, v7, s[2:3]
7728 ; GFX6-NEXT: v_subbrev_u32_e64 v2, s[0:1], 0, v2, s[0:1]
7729 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
7730 ; GFX6-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[0:1]
7731 ; GFX6-NEXT: v_mov_b32_e32 v4, s11
7732 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v4, v1, vcc
7733 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s9, v1
7734 ; GFX6-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
7735 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s10, v0
7736 ; GFX6-NEXT: v_cndmask_b32_e64 v2, v5, v2, s[0:1]
7737 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
7738 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s8, v1
7739 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
7740 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
7741 ; GFX6-NEXT: s_mov_b32 s6, -1
7742 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
7743 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
7744 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
7745 ; GFX6-NEXT: s_endpgm
7747 ; GFX9-LABEL: urem_i64_oddk_denom:
7749 ; GFX9-NEXT: s_add_u32 s0, 4, 0
7750 ; GFX9-NEXT: v_mov_b32_e32 v0, 0xe3e0fc
7751 ; GFX9-NEXT: s_addc_u32 s1, 0, 0
7752 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
7753 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7754 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7755 ; GFX9-NEXT: v_readfirstlane_b32 s2, v0
7756 ; GFX9-NEXT: s_addc_u32 s0, s1, 0
7757 ; GFX9-NEXT: s_mul_i32 s3, s2, 0xfffffee0
7758 ; GFX9-NEXT: s_mul_hi_u32 s8, s2, 0x689e0837
7759 ; GFX9-NEXT: s_mul_i32 s1, s0, 0x689e0837
7760 ; GFX9-NEXT: s_add_i32 s3, s8, s3
7761 ; GFX9-NEXT: s_add_i32 s3, s3, s1
7762 ; GFX9-NEXT: s_mul_i32 s9, s2, 0x689e0837
7763 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
7764 ; GFX9-NEXT: s_mul_i32 s8, s2, s3
7765 ; GFX9-NEXT: s_mul_hi_u32 s2, s2, s9
7766 ; GFX9-NEXT: s_add_u32 s2, s2, s8
7767 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
7768 ; GFX9-NEXT: s_mul_hi_u32 s10, s0, s9
7769 ; GFX9-NEXT: s_mul_i32 s9, s0, s9
7770 ; GFX9-NEXT: s_add_u32 s2, s2, s9
7771 ; GFX9-NEXT: s_mul_hi_u32 s8, s0, s3
7772 ; GFX9-NEXT: s_addc_u32 s1, s1, s10
7773 ; GFX9-NEXT: s_addc_u32 s2, s8, 0
7774 ; GFX9-NEXT: s_mul_i32 s3, s0, s3
7775 ; GFX9-NEXT: s_add_u32 s1, s1, s3
7776 ; GFX9-NEXT: s_addc_u32 s2, 0, s2
7777 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s1, v0
7778 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7779 ; GFX9-NEXT: s_addc_u32 s0, s0, s2
7780 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
7781 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7782 ; GFX9-NEXT: s_mul_i32 s2, s6, s0
7783 ; GFX9-NEXT: s_mul_hi_u32 s8, s6, s3
7784 ; GFX9-NEXT: s_mul_hi_u32 s1, s6, s0
7785 ; GFX9-NEXT: s_add_u32 s2, s8, s2
7786 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
7787 ; GFX9-NEXT: s_mul_hi_u32 s9, s7, s3
7788 ; GFX9-NEXT: s_mul_i32 s3, s7, s3
7789 ; GFX9-NEXT: s_add_u32 s2, s2, s3
7790 ; GFX9-NEXT: s_mul_hi_u32 s8, s7, s0
7791 ; GFX9-NEXT: s_addc_u32 s1, s1, s9
7792 ; GFX9-NEXT: s_addc_u32 s2, s8, 0
7793 ; GFX9-NEXT: s_mul_i32 s0, s7, s0
7794 ; GFX9-NEXT: s_add_u32 s0, s1, s0
7795 ; GFX9-NEXT: s_addc_u32 s1, 0, s2
7796 ; GFX9-NEXT: s_mul_i32 s2, s0, 0x11f
7797 ; GFX9-NEXT: s_mul_hi_u32 s3, s0, 0x9761f7c9
7798 ; GFX9-NEXT: s_add_i32 s2, s3, s2
7799 ; GFX9-NEXT: s_mul_i32 s1, s1, 0x9761f7c9
7800 ; GFX9-NEXT: s_mul_i32 s0, s0, 0x9761f7c9
7801 ; GFX9-NEXT: s_add_i32 s9, s2, s1
7802 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
7803 ; GFX9-NEXT: s_sub_i32 s1, s7, s9
7804 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s6, v0
7805 ; GFX9-NEXT: s_mov_b32 s8, 0x9761f7c9
7806 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7807 ; GFX9-NEXT: s_subb_u32 s6, s1, 0x11f
7808 ; GFX9-NEXT: v_subrev_co_u32_e64 v1, s[0:1], s8, v0
7809 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
7810 ; GFX9-NEXT: s_subb_u32 s10, s6, 0
7811 ; GFX9-NEXT: s_cmpk_gt_u32 s10, 0x11e
7812 ; GFX9-NEXT: s_mov_b32 s12, 0x9761f7c8
7813 ; GFX9-NEXT: s_cselect_b32 s11, -1, 0
7814 ; GFX9-NEXT: v_cmp_lt_u32_e64 s[2:3], s12, v1
7815 ; GFX9-NEXT: s_cmpk_eq_i32 s10, 0x11f
7816 ; GFX9-NEXT: v_cndmask_b32_e64 v3, 0, -1, s[2:3]
7817 ; GFX9-NEXT: v_mov_b32_e32 v4, s11
7818 ; GFX9-NEXT: s_cselect_b64 s[2:3], -1, 0
7819 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
7820 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[2:3]
7821 ; GFX9-NEXT: s_subb_u32 s2, s6, 0x11f
7822 ; GFX9-NEXT: v_subrev_co_u32_e64 v4, s[0:1], s8, v1
7823 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
7824 ; GFX9-NEXT: s_subb_u32 s2, s2, 0
7825 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v3
7826 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v1, v4, s[0:1]
7827 ; GFX9-NEXT: v_mov_b32_e32 v1, s10
7828 ; GFX9-NEXT: v_mov_b32_e32 v4, s2
7829 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
7830 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, v4, s[0:1]
7831 ; GFX9-NEXT: s_subb_u32 s0, s7, s9
7832 ; GFX9-NEXT: s_cmpk_gt_u32 s0, 0x11e
7833 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
7834 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s12, v0
7835 ; GFX9-NEXT: s_cmpk_eq_i32 s0, 0x11f
7836 ; GFX9-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
7837 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
7838 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
7839 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc
7840 ; GFX9-NEXT: v_mov_b32_e32 v5, s0
7841 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
7842 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7843 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
7844 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
7845 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
7846 ; GFX9-NEXT: s_endpgm
7847 %r = urem i64 %x, 1235195393993
7848 store i64 %r, ptr addrspace(1) %out
7852 define amdgpu_kernel void @urem_i64_pow2k_denom(ptr addrspace(1) %out, i64 %x) {
7853 ; CHECK-LABEL: @urem_i64_pow2k_denom(
7854 ; CHECK-NEXT: [[R:%.*]] = urem i64 [[X:%.*]], 4096
7855 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7856 ; CHECK-NEXT: ret void
7858 ; GFX6-LABEL: urem_i64_pow2k_denom:
7860 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
7861 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
7862 ; GFX6-NEXT: s_mov_b32 s6, -1
7863 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
7864 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7865 ; GFX6-NEXT: s_mov_b32 s4, s0
7866 ; GFX6-NEXT: s_and_b32 s0, s2, 0xfff
7867 ; GFX6-NEXT: s_mov_b32 s5, s1
7868 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
7869 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
7870 ; GFX6-NEXT: s_endpgm
7872 ; GFX9-LABEL: urem_i64_pow2k_denom:
7874 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7875 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
7876 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7877 ; GFX9-NEXT: s_and_b32 s0, s6, 0xfff
7878 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
7879 ; GFX9-NEXT: global_store_dwordx2 v1, v[0:1], s[4:5]
7880 ; GFX9-NEXT: s_endpgm
7881 %r = urem i64 %x, 4096
7882 store i64 %r, ptr addrspace(1) %out
7886 define amdgpu_kernel void @urem_i64_pow2_shl_denom(ptr addrspace(1) %out, i64 %x, i64 %y) {
7887 ; CHECK-LABEL: @urem_i64_pow2_shl_denom(
7888 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i64 4096, [[Y:%.*]]
7889 ; CHECK-NEXT: [[R:%.*]] = urem i64 [[X:%.*]], [[SHL_Y]]
7890 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
7891 ; CHECK-NEXT: ret void
7893 ; GFX6-LABEL: urem_i64_pow2_shl_denom:
7895 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
7896 ; GFX6-NEXT: s_load_dword s8, s[2:3], 0xd
7897 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
7898 ; GFX6-NEXT: s_mov_b32 s2, -1
7899 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7900 ; GFX6-NEXT: s_mov_b32 s0, s4
7901 ; GFX6-NEXT: s_mov_b32 s1, s5
7902 ; GFX6-NEXT: s_lshl_b64 s[4:5], 0x1000, s8
7903 ; GFX6-NEXT: s_add_u32 s4, s4, -1
7904 ; GFX6-NEXT: s_addc_u32 s5, s5, -1
7905 ; GFX6-NEXT: s_and_b64 s[4:5], s[6:7], s[4:5]
7906 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7907 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7908 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
7909 ; GFX6-NEXT: s_endpgm
7911 ; GFX9-LABEL: urem_i64_pow2_shl_denom:
7913 ; GFX9-NEXT: s_load_dword s0, s[2:3], 0x34
7914 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
7915 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
7916 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7917 ; GFX9-NEXT: s_lshl_b64 s[0:1], 0x1000, s0
7918 ; GFX9-NEXT: s_add_u32 s0, s0, -1
7919 ; GFX9-NEXT: s_addc_u32 s1, s1, -1
7920 ; GFX9-NEXT: s_and_b64 s[0:1], s[6:7], s[0:1]
7921 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
7922 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
7923 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
7924 ; GFX9-NEXT: s_endpgm
7925 %shl.y = shl i64 4096, %y
7926 %r = urem i64 %x, %shl.y
7927 store i64 %r, ptr addrspace(1) %out
7931 define amdgpu_kernel void @urem_v2i64_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
7932 ; CHECK-LABEL: @urem_v2i64_pow2k_denom(
7933 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
7934 ; CHECK-NEXT: [[TMP2:%.*]] = urem i64 [[TMP1]], 4096
7935 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
7936 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
7937 ; CHECK-NEXT: [[TMP5:%.*]] = urem i64 [[TMP4]], 4096
7938 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
7939 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
7940 ; CHECK-NEXT: ret void
7942 ; GFX6-LABEL: urem_v2i64_pow2k_denom:
7944 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
7945 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
7946 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
7947 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
7948 ; GFX6-NEXT: s_mov_b32 s2, -1
7949 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7950 ; GFX6-NEXT: s_and_b32 s4, s4, 0xfff
7951 ; GFX6-NEXT: s_and_b32 s5, s6, 0xfff
7952 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7953 ; GFX6-NEXT: v_mov_b32_e32 v2, s5
7954 ; GFX6-NEXT: v_mov_b32_e32 v3, v1
7955 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
7956 ; GFX6-NEXT: s_endpgm
7958 ; GFX9-LABEL: urem_v2i64_pow2k_denom:
7960 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
7961 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
7962 ; GFX9-NEXT: v_mov_b32_e32 v1, 0
7963 ; GFX9-NEXT: v_mov_b32_e32 v3, v1
7964 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
7965 ; GFX9-NEXT: s_and_b32 s2, s4, 0xfff
7966 ; GFX9-NEXT: s_and_b32 s3, s6, 0xfff
7967 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
7968 ; GFX9-NEXT: v_mov_b32_e32 v2, s3
7969 ; GFX9-NEXT: global_store_dwordx4 v1, v[0:3], s[0:1]
7970 ; GFX9-NEXT: s_endpgm
7971 %r = urem <2 x i64> %x, <i64 4096, i64 4096>
7972 store <2 x i64> %r, ptr addrspace(1) %out
7976 define amdgpu_kernel void @urem_v2i64_pow2_shl_denom(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
7977 ; CHECK-LABEL: @urem_v2i64_pow2_shl_denom(
7978 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> <i64 4096, i64 4096>, [[Y:%.*]]
7979 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
7980 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0
7981 ; CHECK-NEXT: [[TMP3:%.*]] = urem i64 [[TMP1]], [[TMP2]]
7982 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> poison, i64 [[TMP3]], i64 0
7983 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1
7984 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1
7985 ; CHECK-NEXT: [[TMP7:%.*]] = urem i64 [[TMP5]], [[TMP6]]
7986 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1
7987 ; CHECK-NEXT: store <2 x i64> [[TMP8]], ptr addrspace(1) [[OUT:%.*]], align 16
7988 ; CHECK-NEXT: ret void
7990 ; GFX6-LABEL: urem_v2i64_pow2_shl_denom:
7992 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
7993 ; GFX6-NEXT: s_load_dwordx2 s[12:13], s[2:3], 0x9
7994 ; GFX6-NEXT: s_mov_b32 s15, 0xf000
7995 ; GFX6-NEXT: s_mov_b32 s14, -1
7996 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7997 ; GFX6-NEXT: s_lshl_b64 s[0:1], 0x1000, s10
7998 ; GFX6-NEXT: s_lshl_b64 s[2:3], 0x1000, s8
7999 ; GFX6-NEXT: s_add_u32 s2, s2, -1
8000 ; GFX6-NEXT: s_addc_u32 s3, s3, -1
8001 ; GFX6-NEXT: s_and_b64 s[2:3], s[4:5], s[2:3]
8002 ; GFX6-NEXT: s_add_u32 s0, s0, -1
8003 ; GFX6-NEXT: s_addc_u32 s1, s1, -1
8004 ; GFX6-NEXT: s_and_b64 s[0:1], s[6:7], s[0:1]
8005 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
8006 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
8007 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
8008 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
8009 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[12:15], 0
8010 ; GFX6-NEXT: s_endpgm
8012 ; GFX9-LABEL: urem_v2i64_pow2_shl_denom:
8014 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
8015 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
8016 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
8017 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8018 ; GFX9-NEXT: s_lshl_b64 s[2:3], 0x1000, s10
8019 ; GFX9-NEXT: s_lshl_b64 s[8:9], 0x1000, s8
8020 ; GFX9-NEXT: s_add_u32 s8, s8, -1
8021 ; GFX9-NEXT: s_addc_u32 s9, s9, -1
8022 ; GFX9-NEXT: s_and_b64 s[4:5], s[4:5], s[8:9]
8023 ; GFX9-NEXT: s_add_u32 s2, s2, -1
8024 ; GFX9-NEXT: s_addc_u32 s3, s3, -1
8025 ; GFX9-NEXT: s_and_b64 s[2:3], s[6:7], s[2:3]
8026 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
8027 ; GFX9-NEXT: v_mov_b32_e32 v1, s5
8028 ; GFX9-NEXT: v_mov_b32_e32 v2, s2
8029 ; GFX9-NEXT: v_mov_b32_e32 v3, s3
8030 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
8031 ; GFX9-NEXT: s_endpgm
8032 %shl.y = shl <2 x i64> <i64 4096, i64 4096>, %y
8033 %r = urem <2 x i64> %x, %shl.y
8034 store <2 x i64> %r, ptr addrspace(1) %out
8038 define amdgpu_kernel void @sdiv_i64_oddk_denom(ptr addrspace(1) %out, i64 %x) {
8039 ; CHECK-LABEL: @sdiv_i64_oddk_denom(
8040 ; CHECK-NEXT: [[R:%.*]] = sdiv i64 [[X:%.*]], 1235195
8041 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
8042 ; CHECK-NEXT: ret void
8044 ; GFX6-LABEL: sdiv_i64_oddk_denom:
8046 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
8047 ; GFX6-NEXT: s_mov_b32 s0, 0x33fe64
8048 ; GFX6-NEXT: s_add_u32 s1, 0x396, s0
8049 ; GFX6-NEXT: v_mov_b32_e32 v0, 0x28100000
8050 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s1, v0
8051 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8052 ; GFX6-NEXT: s_mov_b32 s0, s4
8053 ; GFX6-NEXT: s_addc_u32 s4, 0, 0
8054 ; GFX6-NEXT: s_or_b32 s1, vcc_lo, vcc_hi
8055 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
8056 ; GFX6-NEXT: s_mov_b32 s1, 0xffed2705
8057 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, s1
8058 ; GFX6-NEXT: s_addc_u32 s4, s4, 0xd95
8059 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s1
8060 ; GFX6-NEXT: s_mul_i32 s8, s4, 0xffed2705
8061 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s8, v1
8062 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v0
8063 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v1
8064 ; GFX6-NEXT: v_mul_hi_u32 v6, v0, v2
8065 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v1
8066 ; GFX6-NEXT: v_mul_hi_u32 v4, s4, v2
8067 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v2
8068 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v1
8069 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v6, v5
8070 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v7, vcc
8071 ; GFX6-NEXT: v_mul_lo_u32 v1, s4, v1
8072 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v5, v2
8073 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v6, v4, vcc
8074 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v3, vcc
8075 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
8076 ; GFX6-NEXT: s_ashr_i32 s8, s7, 31
8077 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
8078 ; GFX6-NEXT: s_add_u32 s6, s6, s8
8079 ; GFX6-NEXT: v_mov_b32_e32 v3, s4
8080 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8081 ; GFX6-NEXT: s_mov_b32 s9, s8
8082 ; GFX6-NEXT: s_addc_u32 s7, s7, s8
8083 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
8084 ; GFX6-NEXT: s_xor_b64 s[6:7], s[6:7], s[8:9]
8085 ; GFX6-NEXT: v_mul_lo_u32 v2, s6, v1
8086 ; GFX6-NEXT: v_mul_hi_u32 v3, s6, v0
8087 ; GFX6-NEXT: v_mul_hi_u32 v4, s6, v1
8088 ; GFX6-NEXT: v_mul_hi_u32 v5, s7, v1
8089 ; GFX6-NEXT: v_mul_lo_u32 v1, s7, v1
8090 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8091 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8092 ; GFX6-NEXT: v_mul_lo_u32 v4, s7, v0
8093 ; GFX6-NEXT: v_mul_hi_u32 v0, s7, v0
8094 ; GFX6-NEXT: s_mov_b32 s4, 0x12d8fb
8095 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
8096 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8097 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
8098 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
8099 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8100 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
8101 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, s4
8102 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, s4
8103 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
8104 ; GFX6-NEXT: v_mul_lo_u32 v8, v0, s4
8105 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
8106 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 2, v0
8107 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
8108 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
8109 ; GFX6-NEXT: v_mov_b32_e32 v5, s7
8110 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s6, v8
8111 ; GFX6-NEXT: v_subb_u32_e32 v4, vcc, v5, v4, vcc
8112 ; GFX6-NEXT: v_subrev_i32_e32 v5, vcc, s4, v8
8113 ; GFX6-NEXT: v_subbrev_u32_e32 v9, vcc, 0, v4, vcc
8114 ; GFX6-NEXT: s_mov_b32 s4, 0x12d8fa
8115 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s4, v5
8116 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
8117 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v9
8118 ; GFX6-NEXT: v_cndmask_b32_e32 v5, -1, v5, vcc
8119 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5
8120 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v6, vcc
8121 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v7, vcc
8122 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s4, v8
8123 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
8124 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v4
8125 ; GFX6-NEXT: v_cndmask_b32_e32 v4, -1, v5, vcc
8126 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
8127 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
8128 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
8129 ; GFX6-NEXT: v_xor_b32_e32 v0, s8, v0
8130 ; GFX6-NEXT: v_xor_b32_e32 v1, s8, v1
8131 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
8132 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s8, v0
8133 ; GFX6-NEXT: s_mov_b32 s2, -1
8134 ; GFX6-NEXT: s_mov_b32 s1, s5
8135 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v2, vcc
8136 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
8137 ; GFX6-NEXT: s_endpgm
8139 ; GFX9-LABEL: sdiv_i64_oddk_denom:
8141 ; GFX9-NEXT: s_mov_b32 s0, 0x33fe64
8142 ; GFX9-NEXT: s_add_u32 s0, 0x396, s0
8143 ; GFX9-NEXT: v_mov_b32_e32 v0, 0x28100000
8144 ; GFX9-NEXT: s_addc_u32 s1, 0, 0
8145 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
8146 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8147 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
8148 ; GFX9-NEXT: s_addc_u32 s0, s1, 0xd95
8149 ; GFX9-NEXT: v_readfirstlane_b32 s2, v0
8150 ; GFX9-NEXT: s_mul_i32 s1, s0, 0xffed2705
8151 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, 0xffed2705
8152 ; GFX9-NEXT: s_add_i32 s3, s3, s1
8153 ; GFX9-NEXT: s_sub_i32 s1, s3, s2
8154 ; GFX9-NEXT: s_mul_i32 s8, s2, 0xffed2705
8155 ; GFX9-NEXT: s_mul_hi_u32 s11, s2, s1
8156 ; GFX9-NEXT: s_mul_i32 s12, s2, s1
8157 ; GFX9-NEXT: s_mul_hi_u32 s2, s2, s8
8158 ; GFX9-NEXT: s_add_u32 s2, s2, s12
8159 ; GFX9-NEXT: s_mul_hi_u32 s9, s0, s8
8160 ; GFX9-NEXT: s_mul_i32 s10, s0, s8
8161 ; GFX9-NEXT: s_addc_u32 s8, 0, s11
8162 ; GFX9-NEXT: s_add_u32 s2, s2, s10
8163 ; GFX9-NEXT: s_mul_hi_u32 s3, s0, s1
8164 ; GFX9-NEXT: s_addc_u32 s2, s8, s9
8165 ; GFX9-NEXT: s_addc_u32 s3, s3, 0
8166 ; GFX9-NEXT: s_mul_i32 s1, s0, s1
8167 ; GFX9-NEXT: s_add_u32 s1, s2, s1
8168 ; GFX9-NEXT: s_addc_u32 s2, 0, s3
8169 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s1, v0
8170 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8171 ; GFX9-NEXT: s_addc_u32 s8, s0, s2
8172 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8173 ; GFX9-NEXT: s_ashr_i32 s0, s7, 31
8174 ; GFX9-NEXT: s_add_u32 s2, s6, s0
8175 ; GFX9-NEXT: s_mov_b32 s1, s0
8176 ; GFX9-NEXT: s_addc_u32 s3, s7, s0
8177 ; GFX9-NEXT: s_xor_b64 s[2:3], s[2:3], s[0:1]
8178 ; GFX9-NEXT: v_readfirstlane_b32 s9, v0
8179 ; GFX9-NEXT: s_mul_i32 s7, s2, s8
8180 ; GFX9-NEXT: s_mul_hi_u32 s10, s2, s9
8181 ; GFX9-NEXT: s_mul_hi_u32 s6, s2, s8
8182 ; GFX9-NEXT: s_add_u32 s7, s10, s7
8183 ; GFX9-NEXT: s_addc_u32 s6, 0, s6
8184 ; GFX9-NEXT: s_mul_hi_u32 s11, s3, s9
8185 ; GFX9-NEXT: s_mul_i32 s9, s3, s9
8186 ; GFX9-NEXT: s_add_u32 s7, s7, s9
8187 ; GFX9-NEXT: s_mul_hi_u32 s10, s3, s8
8188 ; GFX9-NEXT: s_addc_u32 s6, s6, s11
8189 ; GFX9-NEXT: s_addc_u32 s7, s10, 0
8190 ; GFX9-NEXT: s_mul_i32 s8, s3, s8
8191 ; GFX9-NEXT: s_add_u32 s6, s6, s8
8192 ; GFX9-NEXT: s_addc_u32 s7, 0, s7
8193 ; GFX9-NEXT: s_add_u32 s8, s6, 1
8194 ; GFX9-NEXT: s_addc_u32 s9, s7, 0
8195 ; GFX9-NEXT: s_add_u32 s10, s6, 2
8196 ; GFX9-NEXT: s_mul_i32 s13, s7, 0x12d8fb
8197 ; GFX9-NEXT: s_mul_hi_u32 s14, s6, 0x12d8fb
8198 ; GFX9-NEXT: s_addc_u32 s11, s7, 0
8199 ; GFX9-NEXT: s_add_i32 s14, s14, s13
8200 ; GFX9-NEXT: s_mul_i32 s13, s6, 0x12d8fb
8201 ; GFX9-NEXT: v_mov_b32_e32 v0, s13
8202 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s2, v0
8203 ; GFX9-NEXT: s_mov_b32 s12, 0x12d8fb
8204 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8205 ; GFX9-NEXT: s_subb_u32 s2, s3, s14
8206 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s12, v0
8207 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8208 ; GFX9-NEXT: s_subb_u32 s3, s2, 0
8209 ; GFX9-NEXT: v_readfirstlane_b32 s12, v1
8210 ; GFX9-NEXT: s_cmp_gt_u32 s12, 0x12d8fa
8211 ; GFX9-NEXT: s_cselect_b32 s12, -1, 0
8212 ; GFX9-NEXT: s_cmp_eq_u32 s3, 0
8213 ; GFX9-NEXT: s_cselect_b32 s3, s12, -1
8214 ; GFX9-NEXT: s_cmp_lg_u32 s3, 0
8215 ; GFX9-NEXT: s_cselect_b32 s3, s11, s9
8216 ; GFX9-NEXT: v_readfirstlane_b32 s9, v0
8217 ; GFX9-NEXT: s_cselect_b32 s8, s10, s8
8218 ; GFX9-NEXT: s_cmp_gt_u32 s9, 0x12d8fa
8219 ; GFX9-NEXT: s_cselect_b32 s9, -1, 0
8220 ; GFX9-NEXT: s_cmp_eq_u32 s2, 0
8221 ; GFX9-NEXT: s_cselect_b32 s2, s9, -1
8222 ; GFX9-NEXT: s_cmp_lg_u32 s2, 0
8223 ; GFX9-NEXT: s_cselect_b32 s3, s3, s7
8224 ; GFX9-NEXT: s_cselect_b32 s2, s8, s6
8225 ; GFX9-NEXT: s_xor_b64 s[2:3], s[2:3], s[0:1]
8226 ; GFX9-NEXT: s_sub_u32 s2, s2, s0
8227 ; GFX9-NEXT: s_subb_u32 s3, s3, s0
8228 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
8229 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
8230 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
8231 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
8232 ; GFX9-NEXT: s_endpgm
8233 %r = sdiv i64 %x, 1235195
8234 store i64 %r, ptr addrspace(1) %out
8238 define amdgpu_kernel void @sdiv_i64_pow2k_denom(ptr addrspace(1) %out, i64 %x) {
8239 ; CHECK-LABEL: @sdiv_i64_pow2k_denom(
8240 ; CHECK-NEXT: [[R:%.*]] = sdiv i64 [[X:%.*]], 4096
8241 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
8242 ; CHECK-NEXT: ret void
8244 ; GFX6-LABEL: sdiv_i64_pow2k_denom:
8246 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
8247 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
8248 ; GFX6-NEXT: s_mov_b32 s6, -1
8249 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8250 ; GFX6-NEXT: s_mov_b32 s4, s0
8251 ; GFX6-NEXT: s_ashr_i32 s0, s3, 31
8252 ; GFX6-NEXT: s_lshr_b32 s0, s0, 20
8253 ; GFX6-NEXT: s_add_u32 s0, s2, s0
8254 ; GFX6-NEXT: s_mov_b32 s5, s1
8255 ; GFX6-NEXT: s_addc_u32 s1, s3, 0
8256 ; GFX6-NEXT: s_ashr_i64 s[0:1], s[0:1], 12
8257 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
8258 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
8259 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
8260 ; GFX6-NEXT: s_endpgm
8262 ; GFX9-LABEL: sdiv_i64_pow2k_denom:
8264 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
8265 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
8266 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8267 ; GFX9-NEXT: s_ashr_i32 s0, s7, 31
8268 ; GFX9-NEXT: s_lshr_b32 s0, s0, 20
8269 ; GFX9-NEXT: s_add_u32 s0, s6, s0
8270 ; GFX9-NEXT: s_addc_u32 s1, s7, 0
8271 ; GFX9-NEXT: s_ashr_i64 s[0:1], s[0:1], 12
8272 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
8273 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
8274 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
8275 ; GFX9-NEXT: s_endpgm
8276 %r = sdiv i64 %x, 4096
8277 store i64 %r, ptr addrspace(1) %out
8281 define amdgpu_kernel void @sdiv_i64_pow2_shl_denom(ptr addrspace(1) %out, i64 %x, i64 %y) {
8282 ; CHECK-LABEL: @sdiv_i64_pow2_shl_denom(
8283 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i64 4096, [[Y:%.*]]
8284 ; CHECK-NEXT: [[R:%.*]] = sdiv i64 [[X:%.*]], [[SHL_Y]]
8285 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
8286 ; CHECK-NEXT: ret void
8288 ; GFX6-LABEL: sdiv_i64_pow2_shl_denom:
8290 ; GFX6-NEXT: s_load_dword s0, s[2:3], 0xd
8291 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
8292 ; GFX6-NEXT: s_mov_b32 s6, -1
8293 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8294 ; GFX6-NEXT: s_lshl_b64 s[0:1], 0x1000, s0
8295 ; GFX6-NEXT: s_ashr_i32 s8, s1, 31
8296 ; GFX6-NEXT: s_add_u32 s0, s0, s8
8297 ; GFX6-NEXT: s_mov_b32 s9, s8
8298 ; GFX6-NEXT: s_addc_u32 s1, s1, s8
8299 ; GFX6-NEXT: s_xor_b64 s[10:11], s[0:1], s[8:9]
8300 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s10
8301 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s11
8302 ; GFX6-NEXT: s_sub_u32 s4, 0, s10
8303 ; GFX6-NEXT: s_subb_u32 s5, 0, s11
8304 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
8305 ; GFX6-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
8306 ; GFX6-NEXT: v_rcp_f32_e32 v0, v0
8307 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8308 ; GFX6-NEXT: s_ashr_i32 s12, s3, 31
8309 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
8310 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
8311 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
8312 ; GFX6-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
8313 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
8314 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
8315 ; GFX6-NEXT: s_add_u32 s2, s2, s12
8316 ; GFX6-NEXT: s_mov_b32 s13, s12
8317 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
8318 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
8319 ; GFX6-NEXT: v_mul_lo_u32 v5, s5, v0
8320 ; GFX6-NEXT: v_mul_lo_u32 v4, s4, v0
8321 ; GFX6-NEXT: s_addc_u32 s3, s3, s12
8322 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8323 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v5
8324 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, v4
8325 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v2
8326 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v2
8327 ; GFX6-NEXT: v_mul_lo_u32 v6, v1, v4
8328 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v4
8329 ; GFX6-NEXT: v_mul_hi_u32 v8, v1, v2
8330 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
8331 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
8332 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
8333 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v6
8334 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v5, v4, vcc
8335 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
8336 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8337 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8338 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
8339 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
8340 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
8341 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
8342 ; GFX6-NEXT: v_mul_lo_u32 v4, s5, v0
8343 ; GFX6-NEXT: s_xor_b64 s[2:3], s[2:3], s[12:13]
8344 ; GFX6-NEXT: s_mov_b32 s5, s1
8345 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8346 ; GFX6-NEXT: v_mul_lo_u32 v3, s4, v0
8347 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8348 ; GFX6-NEXT: v_mul_lo_u32 v6, v0, v2
8349 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v3
8350 ; GFX6-NEXT: v_mul_hi_u32 v8, v0, v2
8351 ; GFX6-NEXT: v_mul_hi_u32 v5, v1, v3
8352 ; GFX6-NEXT: v_mul_lo_u32 v3, v1, v3
8353 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v2
8354 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
8355 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
8356 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
8357 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v6, v3
8358 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
8359 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
8360 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8361 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8362 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
8363 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
8364 ; GFX6-NEXT: v_mul_lo_u32 v2, s2, v1
8365 ; GFX6-NEXT: v_mul_hi_u32 v3, s2, v0
8366 ; GFX6-NEXT: v_mul_hi_u32 v4, s2, v1
8367 ; GFX6-NEXT: v_mul_hi_u32 v5, s3, v1
8368 ; GFX6-NEXT: v_mul_lo_u32 v1, s3, v1
8369 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8370 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8371 ; GFX6-NEXT: v_mul_lo_u32 v4, s3, v0
8372 ; GFX6-NEXT: v_mul_hi_u32 v0, s3, v0
8373 ; GFX6-NEXT: s_mov_b32 s4, s0
8374 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8375 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
8376 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
8377 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8378 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
8379 ; GFX6-NEXT: v_mul_lo_u32 v2, s10, v1
8380 ; GFX6-NEXT: v_mul_hi_u32 v3, s10, v0
8381 ; GFX6-NEXT: v_mul_lo_u32 v4, s11, v0
8382 ; GFX6-NEXT: v_mov_b32_e32 v5, s11
8383 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8384 ; GFX6-NEXT: v_mul_lo_u32 v3, s10, v0
8385 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v4, v2
8386 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s3, v2
8387 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s2, v3
8388 ; GFX6-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc
8389 ; GFX6-NEXT: v_subrev_i32_e64 v5, s[0:1], s10, v3
8390 ; GFX6-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1]
8391 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s11, v4
8392 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[0:1]
8393 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s10, v5
8394 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[0:1]
8395 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[0:1], s11, v4
8396 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v6, v5, s[0:1]
8397 ; GFX6-NEXT: v_add_i32_e64 v5, s[0:1], 1, v0
8398 ; GFX6-NEXT: v_addc_u32_e64 v6, s[0:1], 0, v1, s[0:1]
8399 ; GFX6-NEXT: v_add_i32_e64 v7, s[0:1], 2, v0
8400 ; GFX6-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v1, s[0:1]
8401 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v4
8402 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v5, v7, s[0:1]
8403 ; GFX6-NEXT: v_cndmask_b32_e64 v5, v6, v8, s[0:1]
8404 ; GFX6-NEXT: v_mov_b32_e32 v6, s3
8405 ; GFX6-NEXT: v_subb_u32_e32 v2, vcc, v6, v2, vcc
8406 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s11, v2
8407 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
8408 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s10, v3
8409 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
8410 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s11, v2
8411 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v6, v3, vcc
8412 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
8413 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
8414 ; GFX6-NEXT: s_xor_b64 s[0:1], s[12:13], s[8:9]
8415 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc
8416 ; GFX6-NEXT: v_xor_b32_e32 v0, s0, v0
8417 ; GFX6-NEXT: v_xor_b32_e32 v1, s1, v1
8418 ; GFX6-NEXT: v_mov_b32_e32 v2, s1
8419 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s0, v0
8420 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v2, vcc
8421 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
8422 ; GFX6-NEXT: s_endpgm
8424 ; GFX9-LABEL: sdiv_i64_pow2_shl_denom:
8426 ; GFX9-NEXT: s_load_dword s0, s[2:3], 0x34
8427 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
8428 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8429 ; GFX9-NEXT: s_lshl_b64 s[0:1], 0x1000, s0
8430 ; GFX9-NEXT: s_ashr_i32 s8, s1, 31
8431 ; GFX9-NEXT: s_add_u32 s0, s0, s8
8432 ; GFX9-NEXT: s_mov_b32 s9, s8
8433 ; GFX9-NEXT: s_addc_u32 s1, s1, s8
8434 ; GFX9-NEXT: s_xor_b64 s[10:11], s[0:1], s[8:9]
8435 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s10
8436 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s11
8437 ; GFX9-NEXT: s_sub_u32 s0, 0, s10
8438 ; GFX9-NEXT: s_subb_u32 s1, 0, s11
8439 ; GFX9-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
8440 ; GFX9-NEXT: v_rcp_f32_e32 v1, v0
8441 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
8442 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x5f7ffffc, v1
8443 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x2f800000, v1
8444 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
8445 ; GFX9-NEXT: v_madmk_f32 v1, v2, 0xcf800000, v1
8446 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
8447 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
8448 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
8449 ; GFX9-NEXT: v_readfirstlane_b32 s3, v1
8450 ; GFX9-NEXT: s_mul_i32 s12, s0, s2
8451 ; GFX9-NEXT: s_mul_hi_u32 s14, s0, s3
8452 ; GFX9-NEXT: s_mul_i32 s13, s1, s3
8453 ; GFX9-NEXT: s_add_i32 s12, s14, s12
8454 ; GFX9-NEXT: s_mul_i32 s15, s0, s3
8455 ; GFX9-NEXT: s_add_i32 s12, s12, s13
8456 ; GFX9-NEXT: s_mul_hi_u32 s14, s3, s15
8457 ; GFX9-NEXT: s_mul_hi_u32 s13, s3, s12
8458 ; GFX9-NEXT: s_mul_i32 s3, s3, s12
8459 ; GFX9-NEXT: s_add_u32 s3, s14, s3
8460 ; GFX9-NEXT: s_addc_u32 s13, 0, s13
8461 ; GFX9-NEXT: s_mul_hi_u32 s16, s2, s15
8462 ; GFX9-NEXT: s_mul_i32 s15, s2, s15
8463 ; GFX9-NEXT: s_add_u32 s3, s3, s15
8464 ; GFX9-NEXT: s_mul_hi_u32 s14, s2, s12
8465 ; GFX9-NEXT: s_addc_u32 s3, s13, s16
8466 ; GFX9-NEXT: s_addc_u32 s13, s14, 0
8467 ; GFX9-NEXT: s_mul_i32 s12, s2, s12
8468 ; GFX9-NEXT: s_add_u32 s3, s3, s12
8469 ; GFX9-NEXT: s_addc_u32 s12, 0, s13
8470 ; GFX9-NEXT: v_add_co_u32_e32 v1, vcc, s3, v1
8471 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8472 ; GFX9-NEXT: s_addc_u32 s2, s2, s12
8473 ; GFX9-NEXT: v_readfirstlane_b32 s12, v1
8474 ; GFX9-NEXT: s_mul_i32 s3, s0, s2
8475 ; GFX9-NEXT: s_mul_hi_u32 s13, s0, s12
8476 ; GFX9-NEXT: s_add_i32 s3, s13, s3
8477 ; GFX9-NEXT: s_mul_i32 s1, s1, s12
8478 ; GFX9-NEXT: s_add_i32 s3, s3, s1
8479 ; GFX9-NEXT: s_mul_i32 s0, s0, s12
8480 ; GFX9-NEXT: s_mul_hi_u32 s13, s2, s0
8481 ; GFX9-NEXT: s_mul_i32 s14, s2, s0
8482 ; GFX9-NEXT: s_mul_i32 s16, s12, s3
8483 ; GFX9-NEXT: s_mul_hi_u32 s0, s12, s0
8484 ; GFX9-NEXT: s_mul_hi_u32 s15, s12, s3
8485 ; GFX9-NEXT: s_add_u32 s0, s0, s16
8486 ; GFX9-NEXT: s_addc_u32 s12, 0, s15
8487 ; GFX9-NEXT: s_add_u32 s0, s0, s14
8488 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
8489 ; GFX9-NEXT: s_addc_u32 s0, s12, s13
8490 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
8491 ; GFX9-NEXT: s_mul_i32 s3, s2, s3
8492 ; GFX9-NEXT: s_add_u32 s0, s0, s3
8493 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
8494 ; GFX9-NEXT: v_add_co_u32_e32 v1, vcc, s0, v1
8495 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8496 ; GFX9-NEXT: s_addc_u32 s12, s2, s1
8497 ; GFX9-NEXT: s_ashr_i32 s2, s7, 31
8498 ; GFX9-NEXT: s_add_u32 s0, s6, s2
8499 ; GFX9-NEXT: s_mov_b32 s3, s2
8500 ; GFX9-NEXT: s_addc_u32 s1, s7, s2
8501 ; GFX9-NEXT: s_xor_b64 s[6:7], s[0:1], s[2:3]
8502 ; GFX9-NEXT: v_readfirstlane_b32 s13, v1
8503 ; GFX9-NEXT: s_mul_i32 s1, s6, s12
8504 ; GFX9-NEXT: s_mul_hi_u32 s14, s6, s13
8505 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s12
8506 ; GFX9-NEXT: s_add_u32 s1, s14, s1
8507 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
8508 ; GFX9-NEXT: s_mul_hi_u32 s15, s7, s13
8509 ; GFX9-NEXT: s_mul_i32 s13, s7, s13
8510 ; GFX9-NEXT: s_add_u32 s1, s1, s13
8511 ; GFX9-NEXT: s_mul_hi_u32 s14, s7, s12
8512 ; GFX9-NEXT: s_addc_u32 s0, s0, s15
8513 ; GFX9-NEXT: s_addc_u32 s1, s14, 0
8514 ; GFX9-NEXT: s_mul_i32 s12, s7, s12
8515 ; GFX9-NEXT: s_add_u32 s12, s0, s12
8516 ; GFX9-NEXT: s_addc_u32 s13, 0, s1
8517 ; GFX9-NEXT: s_mul_i32 s0, s10, s13
8518 ; GFX9-NEXT: s_mul_hi_u32 s1, s10, s12
8519 ; GFX9-NEXT: s_add_i32 s0, s1, s0
8520 ; GFX9-NEXT: s_mul_i32 s1, s11, s12
8521 ; GFX9-NEXT: s_add_i32 s14, s0, s1
8522 ; GFX9-NEXT: s_mul_i32 s1, s10, s12
8523 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
8524 ; GFX9-NEXT: s_sub_i32 s0, s7, s14
8525 ; GFX9-NEXT: v_sub_co_u32_e32 v1, vcc, s6, v1
8526 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8527 ; GFX9-NEXT: s_subb_u32 s6, s0, s11
8528 ; GFX9-NEXT: v_subrev_co_u32_e64 v2, s[0:1], s10, v1
8529 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
8530 ; GFX9-NEXT: s_subb_u32 s6, s6, 0
8531 ; GFX9-NEXT: s_cmp_ge_u32 s6, s11
8532 ; GFX9-NEXT: s_cselect_b32 s15, -1, 0
8533 ; GFX9-NEXT: v_cmp_le_u32_e64 s[0:1], s10, v2
8534 ; GFX9-NEXT: s_cmp_eq_u32 s6, s11
8535 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, -1, s[0:1]
8536 ; GFX9-NEXT: v_mov_b32_e32 v3, s15
8537 ; GFX9-NEXT: s_cselect_b64 s[0:1], -1, 0
8538 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v3, v2, s[0:1]
8539 ; GFX9-NEXT: s_add_u32 s0, s12, 1
8540 ; GFX9-NEXT: s_addc_u32 s6, s13, 0
8541 ; GFX9-NEXT: s_add_u32 s1, s12, 2
8542 ; GFX9-NEXT: s_addc_u32 s15, s13, 0
8543 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
8544 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
8545 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v2
8546 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v3, v4, s[0:1]
8547 ; GFX9-NEXT: v_mov_b32_e32 v3, s6
8548 ; GFX9-NEXT: v_mov_b32_e32 v4, s15
8549 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8550 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v3, v4, s[0:1]
8551 ; GFX9-NEXT: s_subb_u32 s0, s7, s14
8552 ; GFX9-NEXT: s_cmp_ge_u32 s0, s11
8553 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
8554 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s10, v1
8555 ; GFX9-NEXT: s_cmp_eq_u32 s0, s11
8556 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, -1, vcc
8557 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
8558 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
8559 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v4, v1, vcc
8560 ; GFX9-NEXT: v_mov_b32_e32 v4, s13
8561 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v1
8562 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v4, v3, vcc
8563 ; GFX9-NEXT: v_mov_b32_e32 v3, s12
8564 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v3, v2, vcc
8565 ; GFX9-NEXT: s_xor_b64 s[0:1], s[2:3], s[8:9]
8566 ; GFX9-NEXT: v_xor_b32_e32 v2, s0, v2
8567 ; GFX9-NEXT: v_xor_b32_e32 v3, s1, v1
8568 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
8569 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s0, v2
8570 ; GFX9-NEXT: v_subb_co_u32_e32 v2, vcc, v3, v4, vcc
8571 ; GFX9-NEXT: global_store_dwordx2 v0, v[1:2], s[4:5]
8572 ; GFX9-NEXT: s_endpgm
8573 %shl.y = shl i64 4096, %y
8574 %r = sdiv i64 %x, %shl.y
8575 store i64 %r, ptr addrspace(1) %out
8579 define amdgpu_kernel void @sdiv_v2i64_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
8580 ; CHECK-LABEL: @sdiv_v2i64_pow2k_denom(
8581 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
8582 ; CHECK-NEXT: [[TMP2:%.*]] = sdiv i64 [[TMP1]], 4096
8583 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
8584 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
8585 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv i64 [[TMP4]], 4096
8586 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
8587 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
8588 ; CHECK-NEXT: ret void
8590 ; GFX6-LABEL: sdiv_v2i64_pow2k_denom:
8592 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
8593 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
8594 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
8595 ; GFX6-NEXT: s_mov_b32 s2, -1
8596 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8597 ; GFX6-NEXT: s_ashr_i32 s8, s5, 31
8598 ; GFX6-NEXT: s_lshr_b32 s8, s8, 20
8599 ; GFX6-NEXT: s_add_u32 s4, s4, s8
8600 ; GFX6-NEXT: s_addc_u32 s5, s5, 0
8601 ; GFX6-NEXT: s_ashr_i32 s8, s7, 31
8602 ; GFX6-NEXT: s_ashr_i64 s[4:5], s[4:5], 12
8603 ; GFX6-NEXT: s_lshr_b32 s8, s8, 20
8604 ; GFX6-NEXT: s_add_u32 s6, s6, s8
8605 ; GFX6-NEXT: s_addc_u32 s7, s7, 0
8606 ; GFX6-NEXT: s_ashr_i64 s[6:7], s[6:7], 12
8607 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8608 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8609 ; GFX6-NEXT: v_mov_b32_e32 v2, s6
8610 ; GFX6-NEXT: v_mov_b32_e32 v3, s7
8611 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
8612 ; GFX6-NEXT: s_endpgm
8614 ; GFX9-LABEL: sdiv_v2i64_pow2k_denom:
8616 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
8617 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
8618 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
8619 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8620 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
8621 ; GFX9-NEXT: s_lshr_b32 s2, s2, 20
8622 ; GFX9-NEXT: s_add_u32 s2, s4, s2
8623 ; GFX9-NEXT: s_addc_u32 s3, s5, 0
8624 ; GFX9-NEXT: s_ashr_i32 s4, s7, 31
8625 ; GFX9-NEXT: s_ashr_i64 s[2:3], s[2:3], 12
8626 ; GFX9-NEXT: s_lshr_b32 s4, s4, 20
8627 ; GFX9-NEXT: s_add_u32 s4, s6, s4
8628 ; GFX9-NEXT: s_addc_u32 s5, s7, 0
8629 ; GFX9-NEXT: s_ashr_i64 s[4:5], s[4:5], 12
8630 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
8631 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
8632 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
8633 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
8634 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
8635 ; GFX9-NEXT: s_endpgm
8636 %r = sdiv <2 x i64> %x, <i64 4096, i64 4096>
8637 store <2 x i64> %r, ptr addrspace(1) %out
8641 define amdgpu_kernel void @ssdiv_v2i64_mixed_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
8642 ; CHECK-LABEL: @ssdiv_v2i64_mixed_pow2k_denom(
8643 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
8644 ; CHECK-NEXT: [[TMP2:%.*]] = sdiv i64 [[TMP1]], 4096
8645 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
8646 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
8647 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv i64 [[TMP4]], 4095
8648 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
8649 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
8650 ; CHECK-NEXT: ret void
8652 ; GFX6-LABEL: ssdiv_v2i64_mixed_pow2k_denom:
8654 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
8655 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
8656 ; GFX6-NEXT: s_mov_b32 s2, 0x2ff2fc01
8657 ; GFX6-NEXT: v_bfrev_b32_e32 v0, 7
8658 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
8659 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8660 ; GFX6-NEXT: s_ashr_i32 s8, s5, 31
8661 ; GFX6-NEXT: s_lshr_b32 s8, s8, 20
8662 ; GFX6-NEXT: s_add_u32 s4, s4, s8
8663 ; GFX6-NEXT: s_addc_u32 s5, s5, 0
8664 ; GFX6-NEXT: s_ashr_i64 s[4:5], s[4:5], 12
8665 ; GFX6-NEXT: s_add_u32 s2, 0xe037f, s2
8666 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s2, v0
8667 ; GFX6-NEXT: s_addc_u32 s8, 0, 0
8668 ; GFX6-NEXT: s_or_b32 s2, vcc_lo, vcc_hi
8669 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
8670 ; GFX6-NEXT: s_movk_i32 s2, 0xf001
8671 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, s2
8672 ; GFX6-NEXT: s_addc_u32 s8, s8, 0x1000ff
8673 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s2
8674 ; GFX6-NEXT: s_mul_i32 s9, s8, 0xfffff001
8675 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s9, v1
8676 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v0
8677 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v1
8678 ; GFX6-NEXT: v_mul_hi_u32 v6, v0, v2
8679 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v1
8680 ; GFX6-NEXT: v_mul_hi_u32 v4, s8, v2
8681 ; GFX6-NEXT: v_mul_lo_u32 v2, s8, v2
8682 ; GFX6-NEXT: v_mul_hi_u32 v3, s8, v1
8683 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v6, v5
8684 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v7, vcc
8685 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v1
8686 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v5, v2
8687 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v6, v4, vcc
8688 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v3, vcc
8689 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
8690 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
8691 ; GFX6-NEXT: v_mov_b32_e32 v3, s8
8692 ; GFX6-NEXT: s_ashr_i32 s8, s7, 31
8693 ; GFX6-NEXT: s_add_u32 s6, s6, s8
8694 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8695 ; GFX6-NEXT: s_mov_b32 s9, s8
8696 ; GFX6-NEXT: s_addc_u32 s7, s7, s8
8697 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
8698 ; GFX6-NEXT: s_xor_b64 s[6:7], s[6:7], s[8:9]
8699 ; GFX6-NEXT: v_mul_lo_u32 v2, s6, v1
8700 ; GFX6-NEXT: v_mul_hi_u32 v3, s6, v0
8701 ; GFX6-NEXT: v_mul_hi_u32 v4, s6, v1
8702 ; GFX6-NEXT: v_mul_hi_u32 v5, s7, v1
8703 ; GFX6-NEXT: v_mul_lo_u32 v1, s7, v1
8704 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8705 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8706 ; GFX6-NEXT: v_mul_lo_u32 v4, s7, v0
8707 ; GFX6-NEXT: v_mul_hi_u32 v0, s7, v0
8708 ; GFX6-NEXT: s_movk_i32 s9, 0xfff
8709 ; GFX6-NEXT: s_mov_b32 s2, -1
8710 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8711 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
8712 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
8713 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8714 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
8715 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, s9
8716 ; GFX6-NEXT: v_mul_hi_u32 v5, v0, s9
8717 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 1, v0
8718 ; GFX6-NEXT: v_mul_lo_u32 v8, v0, s9
8719 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
8720 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 2, v0
8721 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
8722 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
8723 ; GFX6-NEXT: v_mov_b32_e32 v5, s7
8724 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s6, v8
8725 ; GFX6-NEXT: v_subb_u32_e32 v4, vcc, v5, v4, vcc
8726 ; GFX6-NEXT: v_subrev_i32_e32 v5, vcc, s9, v8
8727 ; GFX6-NEXT: v_subbrev_u32_e32 v9, vcc, 0, v4, vcc
8728 ; GFX6-NEXT: s_movk_i32 s6, 0xffe
8729 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s6, v5
8730 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
8731 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v9
8732 ; GFX6-NEXT: v_cndmask_b32_e32 v5, -1, v5, vcc
8733 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5
8734 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v6, vcc
8735 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v7, vcc
8736 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s6, v8
8737 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
8738 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v4
8739 ; GFX6-NEXT: v_cndmask_b32_e32 v4, -1, v5, vcc
8740 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
8741 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
8742 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
8743 ; GFX6-NEXT: v_xor_b32_e32 v0, s8, v0
8744 ; GFX6-NEXT: v_xor_b32_e32 v1, s8, v1
8745 ; GFX6-NEXT: v_mov_b32_e32 v3, s8
8746 ; GFX6-NEXT: v_subrev_i32_e32 v2, vcc, s8, v0
8747 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v1, v3, vcc
8748 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8749 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8750 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
8751 ; GFX6-NEXT: s_endpgm
8753 ; GFX9-LABEL: ssdiv_v2i64_mixed_pow2k_denom:
8755 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
8756 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
8757 ; GFX9-NEXT: s_mov_b32 s8, 0x2ff2fc01
8758 ; GFX9-NEXT: v_bfrev_b32_e32 v0, 7
8759 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
8760 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
8761 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
8762 ; GFX9-NEXT: s_lshr_b32 s2, s2, 20
8763 ; GFX9-NEXT: s_add_u32 s2, s4, s2
8764 ; GFX9-NEXT: s_addc_u32 s3, s5, 0
8765 ; GFX9-NEXT: s_ashr_i64 s[2:3], s[2:3], 12
8766 ; GFX9-NEXT: s_add_u32 s4, 0xe037f, s8
8767 ; GFX9-NEXT: s_addc_u32 s5, 0, 0
8768 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s4, v0
8769 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8770 ; GFX9-NEXT: s_addc_u32 s4, s5, 0x1000ff
8771 ; GFX9-NEXT: v_readfirstlane_b32 s8, v0
8772 ; GFX9-NEXT: s_mul_i32 s5, s4, 0xfffff001
8773 ; GFX9-NEXT: s_mul_hi_u32 s9, s8, 0xfffff001
8774 ; GFX9-NEXT: s_add_i32 s9, s9, s5
8775 ; GFX9-NEXT: s_sub_i32 s5, s9, s8
8776 ; GFX9-NEXT: s_mul_i32 s10, s8, 0xfffff001
8777 ; GFX9-NEXT: s_mul_hi_u32 s13, s8, s5
8778 ; GFX9-NEXT: s_mul_i32 s14, s8, s5
8779 ; GFX9-NEXT: s_mul_hi_u32 s8, s8, s10
8780 ; GFX9-NEXT: s_add_u32 s8, s8, s14
8781 ; GFX9-NEXT: s_mul_hi_u32 s11, s4, s10
8782 ; GFX9-NEXT: s_mul_i32 s12, s4, s10
8783 ; GFX9-NEXT: s_addc_u32 s10, 0, s13
8784 ; GFX9-NEXT: s_add_u32 s8, s8, s12
8785 ; GFX9-NEXT: s_mul_hi_u32 s9, s4, s5
8786 ; GFX9-NEXT: s_addc_u32 s8, s10, s11
8787 ; GFX9-NEXT: s_addc_u32 s9, s9, 0
8788 ; GFX9-NEXT: s_mul_i32 s5, s4, s5
8789 ; GFX9-NEXT: s_add_u32 s5, s8, s5
8790 ; GFX9-NEXT: s_addc_u32 s8, 0, s9
8791 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s5, v0
8792 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8793 ; GFX9-NEXT: s_addc_u32 s8, s4, s8
8794 ; GFX9-NEXT: s_ashr_i32 s4, s7, 31
8795 ; GFX9-NEXT: s_add_u32 s6, s6, s4
8796 ; GFX9-NEXT: s_mov_b32 s5, s4
8797 ; GFX9-NEXT: s_addc_u32 s7, s7, s4
8798 ; GFX9-NEXT: s_xor_b64 s[6:7], s[6:7], s[4:5]
8799 ; GFX9-NEXT: v_readfirstlane_b32 s11, v0
8800 ; GFX9-NEXT: s_mul_i32 s10, s6, s8
8801 ; GFX9-NEXT: s_mul_hi_u32 s12, s6, s11
8802 ; GFX9-NEXT: s_mul_hi_u32 s9, s6, s8
8803 ; GFX9-NEXT: s_add_u32 s10, s12, s10
8804 ; GFX9-NEXT: s_addc_u32 s9, 0, s9
8805 ; GFX9-NEXT: s_mul_hi_u32 s13, s7, s11
8806 ; GFX9-NEXT: s_mul_i32 s11, s7, s11
8807 ; GFX9-NEXT: s_add_u32 s10, s10, s11
8808 ; GFX9-NEXT: s_mul_hi_u32 s12, s7, s8
8809 ; GFX9-NEXT: s_addc_u32 s9, s9, s13
8810 ; GFX9-NEXT: s_addc_u32 s10, s12, 0
8811 ; GFX9-NEXT: s_mul_i32 s8, s7, s8
8812 ; GFX9-NEXT: s_add_u32 s8, s9, s8
8813 ; GFX9-NEXT: s_addc_u32 s9, 0, s10
8814 ; GFX9-NEXT: s_add_u32 s10, s8, 1
8815 ; GFX9-NEXT: s_addc_u32 s11, s9, 0
8816 ; GFX9-NEXT: s_add_u32 s12, s8, 2
8817 ; GFX9-NEXT: s_mul_i32 s15, s9, 0xfff
8818 ; GFX9-NEXT: s_mul_hi_u32 s16, s8, 0xfff
8819 ; GFX9-NEXT: s_addc_u32 s13, s9, 0
8820 ; GFX9-NEXT: s_add_i32 s16, s16, s15
8821 ; GFX9-NEXT: s_mul_i32 s15, s8, 0xfff
8822 ; GFX9-NEXT: v_mov_b32_e32 v0, s15
8823 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s6, v0
8824 ; GFX9-NEXT: s_movk_i32 s14, 0xfff
8825 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8826 ; GFX9-NEXT: s_subb_u32 s6, s7, s16
8827 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s14, v0
8828 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
8829 ; GFX9-NEXT: s_subb_u32 s7, s6, 0
8830 ; GFX9-NEXT: v_readfirstlane_b32 s14, v1
8831 ; GFX9-NEXT: s_cmpk_gt_u32 s14, 0xffe
8832 ; GFX9-NEXT: s_cselect_b32 s14, -1, 0
8833 ; GFX9-NEXT: s_cmp_eq_u32 s7, 0
8834 ; GFX9-NEXT: s_cselect_b32 s7, s14, -1
8835 ; GFX9-NEXT: s_cmp_lg_u32 s7, 0
8836 ; GFX9-NEXT: s_cselect_b32 s7, s13, s11
8837 ; GFX9-NEXT: v_readfirstlane_b32 s11, v0
8838 ; GFX9-NEXT: s_cselect_b32 s10, s12, s10
8839 ; GFX9-NEXT: s_cmpk_gt_u32 s11, 0xffe
8840 ; GFX9-NEXT: s_cselect_b32 s11, -1, 0
8841 ; GFX9-NEXT: s_cmp_eq_u32 s6, 0
8842 ; GFX9-NEXT: s_cselect_b32 s6, s11, -1
8843 ; GFX9-NEXT: s_cmp_lg_u32 s6, 0
8844 ; GFX9-NEXT: s_cselect_b32 s7, s7, s9
8845 ; GFX9-NEXT: s_cselect_b32 s6, s10, s8
8846 ; GFX9-NEXT: s_xor_b64 s[6:7], s[6:7], s[4:5]
8847 ; GFX9-NEXT: s_sub_u32 s5, s6, s4
8848 ; GFX9-NEXT: s_subb_u32 s4, s7, s4
8849 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
8850 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
8851 ; GFX9-NEXT: v_mov_b32_e32 v2, s5
8852 ; GFX9-NEXT: v_mov_b32_e32 v3, s4
8853 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
8854 ; GFX9-NEXT: s_endpgm
8855 %r = sdiv <2 x i64> %x, <i64 4096, i64 4095>
8856 store <2 x i64> %r, ptr addrspace(1) %out
8860 define amdgpu_kernel void @sdiv_v2i64_pow2_shl_denom(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
8861 ; CHECK-LABEL: @sdiv_v2i64_pow2_shl_denom(
8862 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> <i64 4096, i64 4096>, [[Y:%.*]]
8863 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
8864 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0
8865 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i64 [[TMP1]], [[TMP2]]
8866 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> poison, i64 [[TMP3]], i64 0
8867 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1
8868 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1
8869 ; CHECK-NEXT: [[TMP7:%.*]] = sdiv i64 [[TMP5]], [[TMP6]]
8870 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1
8871 ; CHECK-NEXT: store <2 x i64> [[TMP8]], ptr addrspace(1) [[OUT:%.*]], align 16
8872 ; CHECK-NEXT: ret void
8874 ; GFX6-LABEL: sdiv_v2i64_pow2_shl_denom:
8876 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
8877 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8878 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
8879 ; GFX6-NEXT: s_lshl_b64 s[0:1], 0x1000, s8
8880 ; GFX6-NEXT: s_lshl_b64 s[14:15], 0x1000, s10
8881 ; GFX6-NEXT: s_ashr_i32 s16, s1, 31
8882 ; GFX6-NEXT: s_add_u32 s0, s0, s16
8883 ; GFX6-NEXT: s_mov_b32 s17, s16
8884 ; GFX6-NEXT: s_addc_u32 s1, s1, s16
8885 ; GFX6-NEXT: s_xor_b64 s[12:13], s[0:1], s[16:17]
8886 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s12
8887 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s13
8888 ; GFX6-NEXT: s_sub_u32 s0, 0, s12
8889 ; GFX6-NEXT: s_subb_u32 s1, 0, s13
8890 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x9
8891 ; GFX6-NEXT: v_mac_f32_e32 v0, 0x4f800000, v1
8892 ; GFX6-NEXT: v_rcp_f32_e32 v0, v0
8893 ; GFX6-NEXT: s_ashr_i32 s2, s5, 31
8894 ; GFX6-NEXT: s_mov_b32 s3, s2
8895 ; GFX6-NEXT: s_mov_b32 s10, -1
8896 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
8897 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
8898 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
8899 ; GFX6-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1
8900 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
8901 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
8902 ; GFX6-NEXT: v_mul_lo_u32 v2, s0, v1
8903 ; GFX6-NEXT: v_mul_hi_u32 v3, s0, v0
8904 ; GFX6-NEXT: v_mul_lo_u32 v5, s1, v0
8905 ; GFX6-NEXT: v_mul_lo_u32 v4, s0, v0
8906 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8907 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v5
8908 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, v4
8909 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v2
8910 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v2
8911 ; GFX6-NEXT: v_mul_hi_u32 v6, v1, v4
8912 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, v4
8913 ; GFX6-NEXT: v_mul_hi_u32 v8, v1, v2
8914 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
8915 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
8916 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
8917 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
8918 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
8919 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
8920 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8921 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8922 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
8923 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
8924 ; GFX6-NEXT: v_mul_lo_u32 v2, s0, v1
8925 ; GFX6-NEXT: v_mul_hi_u32 v3, s0, v0
8926 ; GFX6-NEXT: v_mul_lo_u32 v4, s1, v0
8927 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8928 ; GFX6-NEXT: v_mul_lo_u32 v3, s0, v0
8929 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8930 ; GFX6-NEXT: v_mul_lo_u32 v6, v0, v2
8931 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v3
8932 ; GFX6-NEXT: v_mul_hi_u32 v8, v0, v2
8933 ; GFX6-NEXT: v_mul_hi_u32 v5, v1, v3
8934 ; GFX6-NEXT: v_mul_lo_u32 v3, v1, v3
8935 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v2
8936 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
8937 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
8938 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
8939 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v6, v3
8940 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
8941 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
8942 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8943 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8944 ; GFX6-NEXT: s_add_u32 s0, s4, s2
8945 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
8946 ; GFX6-NEXT: s_addc_u32 s1, s5, s2
8947 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
8948 ; GFX6-NEXT: s_xor_b64 s[4:5], s[0:1], s[2:3]
8949 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
8950 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
8951 ; GFX6-NEXT: v_mul_hi_u32 v4, s4, v1
8952 ; GFX6-NEXT: v_mul_hi_u32 v5, s5, v1
8953 ; GFX6-NEXT: v_mul_lo_u32 v1, s5, v1
8954 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
8955 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
8956 ; GFX6-NEXT: v_mul_lo_u32 v4, s5, v0
8957 ; GFX6-NEXT: v_mul_hi_u32 v0, s5, v0
8958 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
8959 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
8960 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
8961 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
8962 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
8963 ; GFX6-NEXT: v_mul_lo_u32 v2, s12, v1
8964 ; GFX6-NEXT: v_mul_hi_u32 v3, s12, v0
8965 ; GFX6-NEXT: v_mul_lo_u32 v4, s13, v0
8966 ; GFX6-NEXT: v_mov_b32_e32 v5, s13
8967 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
8968 ; GFX6-NEXT: v_mul_lo_u32 v3, s12, v0
8969 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v4, v2
8970 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s5, v2
8971 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s4, v3
8972 ; GFX6-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc
8973 ; GFX6-NEXT: v_subrev_i32_e64 v5, s[0:1], s12, v3
8974 ; GFX6-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1]
8975 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s13, v4
8976 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[0:1]
8977 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s12, v5
8978 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[0:1]
8979 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[0:1], s13, v4
8980 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v6, v5, s[0:1]
8981 ; GFX6-NEXT: v_add_i32_e64 v5, s[0:1], 1, v0
8982 ; GFX6-NEXT: v_addc_u32_e64 v6, s[0:1], 0, v1, s[0:1]
8983 ; GFX6-NEXT: v_add_i32_e64 v7, s[0:1], 2, v0
8984 ; GFX6-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v1, s[0:1]
8985 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v4
8986 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v5, v7, s[0:1]
8987 ; GFX6-NEXT: v_cndmask_b32_e64 v5, v6, v8, s[0:1]
8988 ; GFX6-NEXT: s_xor_b64 s[0:1], s[2:3], s[16:17]
8989 ; GFX6-NEXT: s_ashr_i32 s2, s15, 31
8990 ; GFX6-NEXT: s_add_u32 s4, s14, s2
8991 ; GFX6-NEXT: v_mov_b32_e32 v6, s5
8992 ; GFX6-NEXT: s_mov_b32 s3, s2
8993 ; GFX6-NEXT: s_addc_u32 s5, s15, s2
8994 ; GFX6-NEXT: s_xor_b64 s[4:5], s[4:5], s[2:3]
8995 ; GFX6-NEXT: v_subb_u32_e32 v2, vcc, v6, v2, vcc
8996 ; GFX6-NEXT: v_cvt_f32_u32_e32 v6, s4
8997 ; GFX6-NEXT: v_cvt_f32_u32_e32 v7, s5
8998 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s13, v2
8999 ; GFX6-NEXT: v_cndmask_b32_e64 v8, 0, -1, vcc
9000 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s12, v3
9001 ; GFX6-NEXT: v_mac_f32_e32 v6, 0x4f800000, v7
9002 ; GFX6-NEXT: v_rcp_f32_e32 v6, v6
9003 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
9004 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s13, v2
9005 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v8, v3, vcc
9006 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
9007 ; GFX6-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v6
9008 ; GFX6-NEXT: v_mul_f32_e32 v3, 0x2f800000, v2
9009 ; GFX6-NEXT: v_trunc_f32_e32 v3, v3
9010 ; GFX6-NEXT: v_mac_f32_e32 v2, 0xcf800000, v3
9011 ; GFX6-NEXT: v_cvt_u32_f32_e32 v2, v2
9012 ; GFX6-NEXT: v_cvt_u32_f32_e32 v3, v3
9013 ; GFX6-NEXT: s_sub_u32 s12, 0, s4
9014 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc
9015 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
9016 ; GFX6-NEXT: v_mul_hi_u32 v4, s12, v2
9017 ; GFX6-NEXT: v_mul_lo_u32 v5, s12, v3
9018 ; GFX6-NEXT: s_subb_u32 s13, 0, s5
9019 ; GFX6-NEXT: v_mul_lo_u32 v6, s13, v2
9020 ; GFX6-NEXT: v_xor_b32_e32 v0, s0, v0
9021 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
9022 ; GFX6-NEXT: v_mul_lo_u32 v5, s12, v2
9023 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v6
9024 ; GFX6-NEXT: v_mul_lo_u32 v6, v2, v4
9025 ; GFX6-NEXT: v_mul_hi_u32 v7, v2, v5
9026 ; GFX6-NEXT: v_mul_hi_u32 v8, v2, v4
9027 ; GFX6-NEXT: v_mul_hi_u32 v9, v3, v4
9028 ; GFX6-NEXT: v_mul_lo_u32 v4, v3, v4
9029 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
9030 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
9031 ; GFX6-NEXT: v_mul_lo_u32 v8, v3, v5
9032 ; GFX6-NEXT: v_mul_hi_u32 v5, v3, v5
9033 ; GFX6-NEXT: v_xor_b32_e32 v1, s1, v1
9034 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v6, v8
9035 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v7, v5, vcc
9036 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v9, vcc
9037 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
9038 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
9039 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
9040 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v3, v5, vcc
9041 ; GFX6-NEXT: v_mul_lo_u32 v4, s12, v3
9042 ; GFX6-NEXT: v_mul_hi_u32 v5, s12, v2
9043 ; GFX6-NEXT: v_mul_lo_u32 v6, s13, v2
9044 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
9045 ; GFX6-NEXT: v_mul_lo_u32 v5, s12, v2
9046 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v6
9047 ; GFX6-NEXT: v_mul_lo_u32 v8, v2, v4
9048 ; GFX6-NEXT: v_mul_hi_u32 v9, v2, v5
9049 ; GFX6-NEXT: v_mul_hi_u32 v10, v2, v4
9050 ; GFX6-NEXT: v_mul_hi_u32 v7, v3, v5
9051 ; GFX6-NEXT: v_mul_lo_u32 v5, v3, v5
9052 ; GFX6-NEXT: v_mul_hi_u32 v6, v3, v4
9053 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v9, v8
9054 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
9055 ; GFX6-NEXT: v_mul_lo_u32 v4, v3, v4
9056 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v8, v5
9057 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v9, v7, vcc
9058 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
9059 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
9060 ; GFX6-NEXT: s_ashr_i32 s12, s7, 31
9061 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
9062 ; GFX6-NEXT: s_add_u32 s6, s6, s12
9063 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
9064 ; GFX6-NEXT: s_mov_b32 s13, s12
9065 ; GFX6-NEXT: s_addc_u32 s7, s7, s12
9066 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v3, v5, vcc
9067 ; GFX6-NEXT: s_xor_b64 s[6:7], s[6:7], s[12:13]
9068 ; GFX6-NEXT: v_mul_lo_u32 v4, s6, v3
9069 ; GFX6-NEXT: v_mul_hi_u32 v5, s6, v2
9070 ; GFX6-NEXT: v_mul_hi_u32 v7, s6, v3
9071 ; GFX6-NEXT: v_mul_hi_u32 v8, s7, v3
9072 ; GFX6-NEXT: v_mul_lo_u32 v3, s7, v3
9073 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
9074 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
9075 ; GFX6-NEXT: v_mul_lo_u32 v7, s7, v2
9076 ; GFX6-NEXT: v_mul_hi_u32 v2, s7, v2
9077 ; GFX6-NEXT: v_mov_b32_e32 v6, s1
9078 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v7
9079 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v5, v2, vcc
9080 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
9081 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
9082 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
9083 ; GFX6-NEXT: v_mul_lo_u32 v4, s4, v3
9084 ; GFX6-NEXT: v_mul_hi_u32 v5, s4, v2
9085 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s0, v0
9086 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v6, vcc
9087 ; GFX6-NEXT: v_mul_lo_u32 v6, s5, v2
9088 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
9089 ; GFX6-NEXT: v_mul_lo_u32 v5, s4, v2
9090 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v6, v4
9091 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s7, v4
9092 ; GFX6-NEXT: v_mov_b32_e32 v7, s5
9093 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s6, v5
9094 ; GFX6-NEXT: v_subb_u32_e64 v6, s[0:1], v6, v7, vcc
9095 ; GFX6-NEXT: v_subrev_i32_e64 v7, s[0:1], s4, v5
9096 ; GFX6-NEXT: v_subbrev_u32_e64 v6, s[0:1], 0, v6, s[0:1]
9097 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s5, v6
9098 ; GFX6-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[0:1]
9099 ; GFX6-NEXT: v_cmp_le_u32_e64 s[0:1], s4, v7
9100 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[0:1]
9101 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[0:1], s5, v6
9102 ; GFX6-NEXT: v_cndmask_b32_e64 v6, v8, v7, s[0:1]
9103 ; GFX6-NEXT: v_add_i32_e64 v7, s[0:1], 1, v2
9104 ; GFX6-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v3, s[0:1]
9105 ; GFX6-NEXT: v_add_i32_e64 v9, s[0:1], 2, v2
9106 ; GFX6-NEXT: v_addc_u32_e64 v10, s[0:1], 0, v3, s[0:1]
9107 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
9108 ; GFX6-NEXT: v_cndmask_b32_e64 v6, v7, v9, s[0:1]
9109 ; GFX6-NEXT: v_cndmask_b32_e64 v7, v8, v10, s[0:1]
9110 ; GFX6-NEXT: v_mov_b32_e32 v8, s7
9111 ; GFX6-NEXT: v_subb_u32_e32 v4, vcc, v8, v4, vcc
9112 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s5, v4
9113 ; GFX6-NEXT: v_cndmask_b32_e64 v8, 0, -1, vcc
9114 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s4, v5
9115 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
9116 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s5, v4
9117 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v8, v5, vcc
9118 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
9119 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v6, vcc
9120 ; GFX6-NEXT: s_xor_b64 s[0:1], s[12:13], s[2:3]
9121 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v7, vcc
9122 ; GFX6-NEXT: v_xor_b32_e32 v2, s0, v2
9123 ; GFX6-NEXT: v_xor_b32_e32 v3, s1, v3
9124 ; GFX6-NEXT: v_mov_b32_e32 v4, s1
9125 ; GFX6-NEXT: v_subrev_i32_e32 v2, vcc, s0, v2
9126 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v3, v4, vcc
9127 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9128 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
9129 ; GFX6-NEXT: s_endpgm
9131 ; GFX9-LABEL: sdiv_v2i64_pow2_shl_denom:
9133 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
9134 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
9135 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9136 ; GFX9-NEXT: s_lshl_b64 s[0:1], 0x1000, s8
9137 ; GFX9-NEXT: s_lshl_b64 s[10:11], 0x1000, s10
9138 ; GFX9-NEXT: s_ashr_i32 s12, s1, 31
9139 ; GFX9-NEXT: s_add_u32 s0, s0, s12
9140 ; GFX9-NEXT: s_mov_b32 s13, s12
9141 ; GFX9-NEXT: s_addc_u32 s1, s1, s12
9142 ; GFX9-NEXT: s_xor_b64 s[14:15], s[0:1], s[12:13]
9143 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s14
9144 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s15
9145 ; GFX9-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x24
9146 ; GFX9-NEXT: s_sub_u32 s0, 0, s14
9147 ; GFX9-NEXT: s_subb_u32 s1, 0, s15
9148 ; GFX9-NEXT: v_mac_f32_e32 v0, 0x4f800000, v1
9149 ; GFX9-NEXT: v_rcp_f32_e32 v0, v0
9150 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
9151 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
9152 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
9153 ; GFX9-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1
9154 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
9155 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
9156 ; GFX9-NEXT: v_readfirstlane_b32 s2, v1
9157 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
9158 ; GFX9-NEXT: s_mul_i32 s16, s0, s2
9159 ; GFX9-NEXT: s_mul_hi_u32 s18, s0, s3
9160 ; GFX9-NEXT: s_mul_i32 s17, s1, s3
9161 ; GFX9-NEXT: s_add_i32 s16, s18, s16
9162 ; GFX9-NEXT: s_mul_i32 s19, s0, s3
9163 ; GFX9-NEXT: s_add_i32 s16, s16, s17
9164 ; GFX9-NEXT: s_mul_hi_u32 s17, s3, s16
9165 ; GFX9-NEXT: s_mul_i32 s18, s3, s16
9166 ; GFX9-NEXT: s_mul_hi_u32 s3, s3, s19
9167 ; GFX9-NEXT: s_add_u32 s3, s3, s18
9168 ; GFX9-NEXT: s_addc_u32 s17, 0, s17
9169 ; GFX9-NEXT: s_mul_hi_u32 s20, s2, s19
9170 ; GFX9-NEXT: s_mul_i32 s19, s2, s19
9171 ; GFX9-NEXT: s_add_u32 s3, s3, s19
9172 ; GFX9-NEXT: s_mul_hi_u32 s18, s2, s16
9173 ; GFX9-NEXT: s_addc_u32 s3, s17, s20
9174 ; GFX9-NEXT: s_addc_u32 s17, s18, 0
9175 ; GFX9-NEXT: s_mul_i32 s16, s2, s16
9176 ; GFX9-NEXT: s_add_u32 s3, s3, s16
9177 ; GFX9-NEXT: s_addc_u32 s16, 0, s17
9178 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s3, v0
9179 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9180 ; GFX9-NEXT: s_addc_u32 s2, s2, s16
9181 ; GFX9-NEXT: v_readfirstlane_b32 s16, v0
9182 ; GFX9-NEXT: s_mul_i32 s3, s0, s2
9183 ; GFX9-NEXT: s_mul_hi_u32 s17, s0, s16
9184 ; GFX9-NEXT: s_add_i32 s3, s17, s3
9185 ; GFX9-NEXT: s_mul_i32 s1, s1, s16
9186 ; GFX9-NEXT: s_add_i32 s3, s3, s1
9187 ; GFX9-NEXT: s_mul_i32 s0, s0, s16
9188 ; GFX9-NEXT: s_mul_hi_u32 s17, s2, s0
9189 ; GFX9-NEXT: s_mul_i32 s18, s2, s0
9190 ; GFX9-NEXT: s_mul_i32 s20, s16, s3
9191 ; GFX9-NEXT: s_mul_hi_u32 s0, s16, s0
9192 ; GFX9-NEXT: s_mul_hi_u32 s19, s16, s3
9193 ; GFX9-NEXT: s_add_u32 s0, s0, s20
9194 ; GFX9-NEXT: s_addc_u32 s16, 0, s19
9195 ; GFX9-NEXT: s_add_u32 s0, s0, s18
9196 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
9197 ; GFX9-NEXT: s_addc_u32 s0, s16, s17
9198 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
9199 ; GFX9-NEXT: s_mul_i32 s3, s2, s3
9200 ; GFX9-NEXT: s_add_u32 s0, s0, s3
9201 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
9202 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
9203 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9204 ; GFX9-NEXT: s_addc_u32 s16, s2, s1
9205 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
9206 ; GFX9-NEXT: s_add_u32 s0, s4, s2
9207 ; GFX9-NEXT: s_mov_b32 s3, s2
9208 ; GFX9-NEXT: s_addc_u32 s1, s5, s2
9209 ; GFX9-NEXT: s_xor_b64 s[4:5], s[0:1], s[2:3]
9210 ; GFX9-NEXT: v_readfirstlane_b32 s17, v0
9211 ; GFX9-NEXT: s_mul_i32 s1, s4, s16
9212 ; GFX9-NEXT: s_mul_hi_u32 s18, s4, s17
9213 ; GFX9-NEXT: s_mul_hi_u32 s0, s4, s16
9214 ; GFX9-NEXT: s_add_u32 s1, s18, s1
9215 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
9216 ; GFX9-NEXT: s_mul_hi_u32 s19, s5, s17
9217 ; GFX9-NEXT: s_mul_i32 s17, s5, s17
9218 ; GFX9-NEXT: s_add_u32 s1, s1, s17
9219 ; GFX9-NEXT: s_mul_hi_u32 s18, s5, s16
9220 ; GFX9-NEXT: s_addc_u32 s0, s0, s19
9221 ; GFX9-NEXT: s_addc_u32 s1, s18, 0
9222 ; GFX9-NEXT: s_mul_i32 s16, s5, s16
9223 ; GFX9-NEXT: s_add_u32 s16, s0, s16
9224 ; GFX9-NEXT: s_addc_u32 s17, 0, s1
9225 ; GFX9-NEXT: s_mul_i32 s0, s14, s17
9226 ; GFX9-NEXT: s_mul_hi_u32 s1, s14, s16
9227 ; GFX9-NEXT: s_add_i32 s0, s1, s0
9228 ; GFX9-NEXT: s_mul_i32 s1, s15, s16
9229 ; GFX9-NEXT: s_add_i32 s18, s0, s1
9230 ; GFX9-NEXT: s_mul_i32 s1, s14, s16
9231 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
9232 ; GFX9-NEXT: s_sub_i32 s0, s5, s18
9233 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s4, v0
9234 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9235 ; GFX9-NEXT: s_subb_u32 s4, s0, s15
9236 ; GFX9-NEXT: v_subrev_co_u32_e64 v1, s[0:1], s14, v0
9237 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
9238 ; GFX9-NEXT: s_subb_u32 s4, s4, 0
9239 ; GFX9-NEXT: s_cmp_ge_u32 s4, s15
9240 ; GFX9-NEXT: s_cselect_b32 s19, -1, 0
9241 ; GFX9-NEXT: v_cmp_le_u32_e64 s[0:1], s14, v1
9242 ; GFX9-NEXT: s_cmp_eq_u32 s4, s15
9243 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, -1, s[0:1]
9244 ; GFX9-NEXT: v_mov_b32_e32 v2, s19
9245 ; GFX9-NEXT: s_cselect_b64 s[0:1], -1, 0
9246 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v2, v1, s[0:1]
9247 ; GFX9-NEXT: s_add_u32 s0, s16, 1
9248 ; GFX9-NEXT: s_addc_u32 s4, s17, 0
9249 ; GFX9-NEXT: s_add_u32 s1, s16, 2
9250 ; GFX9-NEXT: s_addc_u32 s19, s17, 0
9251 ; GFX9-NEXT: v_mov_b32_e32 v2, s0
9252 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
9253 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v1
9254 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v2, v3, s[0:1]
9255 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
9256 ; GFX9-NEXT: v_mov_b32_e32 v3, s19
9257 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9258 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v2, v3, s[0:1]
9259 ; GFX9-NEXT: s_subb_u32 s0, s5, s18
9260 ; GFX9-NEXT: s_cmp_ge_u32 s0, s15
9261 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
9262 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s14, v0
9263 ; GFX9-NEXT: s_cmp_eq_u32 s0, s15
9264 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
9265 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
9266 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
9267 ; GFX9-NEXT: s_xor_b64 s[0:1], s[2:3], s[12:13]
9268 ; GFX9-NEXT: s_ashr_i32 s2, s11, 31
9269 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v3, v0, vcc
9270 ; GFX9-NEXT: s_add_u32 s4, s10, s2
9271 ; GFX9-NEXT: v_mov_b32_e32 v3, s17
9272 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
9273 ; GFX9-NEXT: s_mov_b32 s3, s2
9274 ; GFX9-NEXT: s_addc_u32 s5, s11, s2
9275 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v3, v2, vcc
9276 ; GFX9-NEXT: v_mov_b32_e32 v2, s16
9277 ; GFX9-NEXT: s_xor_b64 s[4:5], s[4:5], s[2:3]
9278 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v2, v1, vcc
9279 ; GFX9-NEXT: v_cvt_f32_u32_e32 v2, s4
9280 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s5
9281 ; GFX9-NEXT: v_xor_b32_e32 v1, s0, v1
9282 ; GFX9-NEXT: v_xor_b32_e32 v5, s1, v0
9283 ; GFX9-NEXT: v_subrev_co_u32_e32 v0, vcc, s0, v1
9284 ; GFX9-NEXT: v_mac_f32_e32 v2, 0x4f800000, v3
9285 ; GFX9-NEXT: v_rcp_f32_e32 v2, v2
9286 ; GFX9-NEXT: s_sub_u32 s0, 0, s4
9287 ; GFX9-NEXT: v_mov_b32_e32 v6, s1
9288 ; GFX9-NEXT: s_subb_u32 s1, 0, s5
9289 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v2
9290 ; GFX9-NEXT: v_mul_f32_e32 v3, 0x2f800000, v2
9291 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
9292 ; GFX9-NEXT: v_mac_f32_e32 v2, 0xcf800000, v3
9293 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
9294 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v3
9295 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v5, v6, vcc
9296 ; GFX9-NEXT: v_readfirstlane_b32 s10, v2
9297 ; GFX9-NEXT: v_readfirstlane_b32 s13, v3
9298 ; GFX9-NEXT: s_mul_hi_u32 s12, s0, s10
9299 ; GFX9-NEXT: s_mul_i32 s14, s0, s13
9300 ; GFX9-NEXT: s_mul_i32 s11, s1, s10
9301 ; GFX9-NEXT: s_add_i32 s12, s12, s14
9302 ; GFX9-NEXT: s_add_i32 s12, s12, s11
9303 ; GFX9-NEXT: s_mul_i32 s15, s0, s10
9304 ; GFX9-NEXT: s_mul_hi_u32 s11, s10, s12
9305 ; GFX9-NEXT: s_mul_i32 s14, s10, s12
9306 ; GFX9-NEXT: s_mul_hi_u32 s10, s10, s15
9307 ; GFX9-NEXT: s_add_u32 s10, s10, s14
9308 ; GFX9-NEXT: s_addc_u32 s11, 0, s11
9309 ; GFX9-NEXT: s_mul_hi_u32 s16, s13, s15
9310 ; GFX9-NEXT: s_mul_i32 s15, s13, s15
9311 ; GFX9-NEXT: s_add_u32 s10, s10, s15
9312 ; GFX9-NEXT: s_mul_hi_u32 s14, s13, s12
9313 ; GFX9-NEXT: s_addc_u32 s10, s11, s16
9314 ; GFX9-NEXT: s_addc_u32 s11, s14, 0
9315 ; GFX9-NEXT: s_mul_i32 s12, s13, s12
9316 ; GFX9-NEXT: s_add_u32 s10, s10, s12
9317 ; GFX9-NEXT: s_addc_u32 s11, 0, s11
9318 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s10, v2
9319 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9320 ; GFX9-NEXT: s_addc_u32 s10, s13, s11
9321 ; GFX9-NEXT: v_readfirstlane_b32 s12, v2
9322 ; GFX9-NEXT: s_mul_i32 s11, s0, s10
9323 ; GFX9-NEXT: s_mul_hi_u32 s13, s0, s12
9324 ; GFX9-NEXT: s_add_i32 s11, s13, s11
9325 ; GFX9-NEXT: s_mul_i32 s1, s1, s12
9326 ; GFX9-NEXT: s_add_i32 s11, s11, s1
9327 ; GFX9-NEXT: s_mul_i32 s0, s0, s12
9328 ; GFX9-NEXT: s_mul_hi_u32 s13, s10, s0
9329 ; GFX9-NEXT: s_mul_i32 s14, s10, s0
9330 ; GFX9-NEXT: s_mul_i32 s16, s12, s11
9331 ; GFX9-NEXT: s_mul_hi_u32 s0, s12, s0
9332 ; GFX9-NEXT: s_mul_hi_u32 s15, s12, s11
9333 ; GFX9-NEXT: s_add_u32 s0, s0, s16
9334 ; GFX9-NEXT: s_addc_u32 s12, 0, s15
9335 ; GFX9-NEXT: s_add_u32 s0, s0, s14
9336 ; GFX9-NEXT: s_mul_hi_u32 s1, s10, s11
9337 ; GFX9-NEXT: s_addc_u32 s0, s12, s13
9338 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
9339 ; GFX9-NEXT: s_mul_i32 s11, s10, s11
9340 ; GFX9-NEXT: s_add_u32 s0, s0, s11
9341 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
9342 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s0, v2
9343 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9344 ; GFX9-NEXT: s_addc_u32 s12, s10, s1
9345 ; GFX9-NEXT: s_ashr_i32 s10, s7, 31
9346 ; GFX9-NEXT: s_add_u32 s0, s6, s10
9347 ; GFX9-NEXT: s_mov_b32 s11, s10
9348 ; GFX9-NEXT: s_addc_u32 s1, s7, s10
9349 ; GFX9-NEXT: s_xor_b64 s[6:7], s[0:1], s[10:11]
9350 ; GFX9-NEXT: v_readfirstlane_b32 s13, v2
9351 ; GFX9-NEXT: s_mul_i32 s1, s6, s12
9352 ; GFX9-NEXT: s_mul_hi_u32 s14, s6, s13
9353 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s12
9354 ; GFX9-NEXT: s_add_u32 s1, s14, s1
9355 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
9356 ; GFX9-NEXT: s_mul_hi_u32 s15, s7, s13
9357 ; GFX9-NEXT: s_mul_i32 s13, s7, s13
9358 ; GFX9-NEXT: s_add_u32 s1, s1, s13
9359 ; GFX9-NEXT: s_mul_hi_u32 s14, s7, s12
9360 ; GFX9-NEXT: s_addc_u32 s0, s0, s15
9361 ; GFX9-NEXT: s_addc_u32 s1, s14, 0
9362 ; GFX9-NEXT: s_mul_i32 s12, s7, s12
9363 ; GFX9-NEXT: s_add_u32 s12, s0, s12
9364 ; GFX9-NEXT: s_addc_u32 s13, 0, s1
9365 ; GFX9-NEXT: s_mul_i32 s0, s4, s13
9366 ; GFX9-NEXT: s_mul_hi_u32 s1, s4, s12
9367 ; GFX9-NEXT: s_add_i32 s0, s1, s0
9368 ; GFX9-NEXT: s_mul_i32 s1, s5, s12
9369 ; GFX9-NEXT: s_add_i32 s14, s0, s1
9370 ; GFX9-NEXT: s_mul_i32 s1, s4, s12
9371 ; GFX9-NEXT: v_mov_b32_e32 v2, s1
9372 ; GFX9-NEXT: s_sub_i32 s0, s7, s14
9373 ; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, s6, v2
9374 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9375 ; GFX9-NEXT: s_subb_u32 s6, s0, s5
9376 ; GFX9-NEXT: v_subrev_co_u32_e64 v3, s[0:1], s4, v2
9377 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
9378 ; GFX9-NEXT: s_subb_u32 s6, s6, 0
9379 ; GFX9-NEXT: s_cmp_ge_u32 s6, s5
9380 ; GFX9-NEXT: s_cselect_b32 s15, -1, 0
9381 ; GFX9-NEXT: v_cmp_le_u32_e64 s[0:1], s4, v3
9382 ; GFX9-NEXT: s_cmp_eq_u32 s6, s5
9383 ; GFX9-NEXT: v_cndmask_b32_e64 v3, 0, -1, s[0:1]
9384 ; GFX9-NEXT: v_mov_b32_e32 v5, s15
9385 ; GFX9-NEXT: s_cselect_b64 s[0:1], -1, 0
9386 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v5, v3, s[0:1]
9387 ; GFX9-NEXT: s_add_u32 s0, s12, 1
9388 ; GFX9-NEXT: s_addc_u32 s6, s13, 0
9389 ; GFX9-NEXT: s_add_u32 s1, s12, 2
9390 ; GFX9-NEXT: s_addc_u32 s15, s13, 0
9391 ; GFX9-NEXT: v_mov_b32_e32 v5, s0
9392 ; GFX9-NEXT: v_mov_b32_e32 v6, s1
9393 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v3
9394 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v5, v6, s[0:1]
9395 ; GFX9-NEXT: v_mov_b32_e32 v5, s6
9396 ; GFX9-NEXT: v_mov_b32_e32 v6, s15
9397 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9398 ; GFX9-NEXT: v_cndmask_b32_e64 v5, v5, v6, s[0:1]
9399 ; GFX9-NEXT: s_subb_u32 s0, s7, s14
9400 ; GFX9-NEXT: s_cmp_ge_u32 s0, s5
9401 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
9402 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s4, v2
9403 ; GFX9-NEXT: s_cmp_eq_u32 s0, s5
9404 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, -1, vcc
9405 ; GFX9-NEXT: v_mov_b32_e32 v6, s1
9406 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
9407 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v6, v2, vcc
9408 ; GFX9-NEXT: v_mov_b32_e32 v6, s13
9409 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
9410 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v6, v5, vcc
9411 ; GFX9-NEXT: v_mov_b32_e32 v5, s12
9412 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
9413 ; GFX9-NEXT: s_xor_b64 s[0:1], s[10:11], s[2:3]
9414 ; GFX9-NEXT: v_xor_b32_e32 v3, s0, v3
9415 ; GFX9-NEXT: v_xor_b32_e32 v5, s1, v2
9416 ; GFX9-NEXT: v_mov_b32_e32 v6, s1
9417 ; GFX9-NEXT: v_subrev_co_u32_e32 v2, vcc, s0, v3
9418 ; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v5, v6, vcc
9419 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9420 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[8:9]
9421 ; GFX9-NEXT: s_endpgm
9422 %shl.y = shl <2 x i64> <i64 4096, i64 4096>, %y
9423 %r = sdiv <2 x i64> %x, %shl.y
9424 store <2 x i64> %r, ptr addrspace(1) %out
9428 define amdgpu_kernel void @srem_i64_oddk_denom(ptr addrspace(1) %out, i64 %x) {
9429 ; CHECK-LABEL: @srem_i64_oddk_denom(
9430 ; CHECK-NEXT: [[R:%.*]] = srem i64 [[X:%.*]], 1235195
9431 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
9432 ; CHECK-NEXT: ret void
9434 ; GFX6-LABEL: srem_i64_oddk_denom:
9436 ; GFX6-NEXT: s_mov_b32 s0, 0x33fe64
9437 ; GFX6-NEXT: s_add_u32 s0, 0x396, s0
9438 ; GFX6-NEXT: v_mov_b32_e32 v0, 0x28100000
9439 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
9440 ; GFX6-NEXT: s_addc_u32 s1, 0, 0
9441 ; GFX6-NEXT: s_or_b32 s0, vcc_lo, vcc_hi
9442 ; GFX6-NEXT: s_cmp_lg_u32 s0, 0
9443 ; GFX6-NEXT: s_mov_b32 s0, 0xffed2705
9444 ; GFX6-NEXT: v_mul_hi_u32 v1, v0, s0
9445 ; GFX6-NEXT: s_addc_u32 s1, s1, 0xd95
9446 ; GFX6-NEXT: v_mul_lo_u32 v2, v0, s0
9447 ; GFX6-NEXT: s_mul_i32 s8, s1, 0xffed2705
9448 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s8, v1
9449 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v0
9450 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v1
9451 ; GFX6-NEXT: v_mul_hi_u32 v6, v0, v2
9452 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v1
9453 ; GFX6-NEXT: v_mul_hi_u32 v4, s1, v2
9454 ; GFX6-NEXT: v_mul_lo_u32 v2, s1, v2
9455 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
9456 ; GFX6-NEXT: v_mul_hi_u32 v3, s1, v1
9457 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v6, v5
9458 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v7, vcc
9459 ; GFX6-NEXT: v_mul_lo_u32 v1, s1, v1
9460 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v5, v2
9461 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v6, v4, vcc
9462 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v3, vcc
9463 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v2, v1
9464 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9465 ; GFX6-NEXT: s_ashr_i32 s8, s7, 31
9466 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v3, vcc
9467 ; GFX6-NEXT: s_add_u32 s0, s6, s8
9468 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
9469 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
9470 ; GFX6-NEXT: s_mov_b32 s9, s8
9471 ; GFX6-NEXT: s_addc_u32 s1, s7, s8
9472 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
9473 ; GFX6-NEXT: s_xor_b64 s[6:7], s[0:1], s[8:9]
9474 ; GFX6-NEXT: v_mul_lo_u32 v2, s6, v1
9475 ; GFX6-NEXT: v_mul_hi_u32 v3, s6, v0
9476 ; GFX6-NEXT: v_mul_hi_u32 v4, s6, v1
9477 ; GFX6-NEXT: v_mul_hi_u32 v5, s7, v1
9478 ; GFX6-NEXT: v_mul_lo_u32 v1, s7, v1
9479 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
9480 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
9481 ; GFX6-NEXT: v_mul_lo_u32 v4, s7, v0
9482 ; GFX6-NEXT: v_mul_hi_u32 v0, s7, v0
9483 ; GFX6-NEXT: s_mov_b32 s0, s4
9484 ; GFX6-NEXT: s_mov_b32 s4, 0x12d8fb
9485 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
9486 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
9487 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
9488 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
9489 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
9490 ; GFX6-NEXT: v_mul_lo_u32 v1, v1, s4
9491 ; GFX6-NEXT: v_mul_hi_u32 v2, v0, s4
9492 ; GFX6-NEXT: v_mul_lo_u32 v0, v0, s4
9493 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
9494 ; GFX6-NEXT: s_mov_b32 s2, -1
9495 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
9496 ; GFX6-NEXT: v_mov_b32_e32 v2, s7
9497 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s6, v0
9498 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v2, v1, vcc
9499 ; GFX6-NEXT: v_subrev_i32_e32 v2, vcc, s4, v0
9500 ; GFX6-NEXT: v_subbrev_u32_e32 v3, vcc, 0, v1, vcc
9501 ; GFX6-NEXT: v_subrev_i32_e32 v4, vcc, s4, v2
9502 ; GFX6-NEXT: v_subbrev_u32_e32 v5, vcc, 0, v3, vcc
9503 ; GFX6-NEXT: s_mov_b32 s4, 0x12d8fa
9504 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s4, v2
9505 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
9506 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v3
9507 ; GFX6-NEXT: v_cndmask_b32_e32 v6, -1, v6, vcc
9508 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v6
9509 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v5, vcc
9510 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v4, vcc
9511 ; GFX6-NEXT: v_cmp_lt_u32_e32 vcc, s4, v0
9512 ; GFX6-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
9513 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, 0, v1
9514 ; GFX6-NEXT: v_cndmask_b32_e32 v4, -1, v4, vcc
9515 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
9516 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
9517 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
9518 ; GFX6-NEXT: v_xor_b32_e32 v0, s8, v0
9519 ; GFX6-NEXT: v_xor_b32_e32 v1, s8, v1
9520 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
9521 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s8, v0
9522 ; GFX6-NEXT: s_mov_b32 s1, s5
9523 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v2, vcc
9524 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
9525 ; GFX6-NEXT: s_endpgm
9527 ; GFX9-LABEL: srem_i64_oddk_denom:
9529 ; GFX9-NEXT: s_mov_b32 s0, 0x33fe64
9530 ; GFX9-NEXT: s_add_u32 s0, 0x396, s0
9531 ; GFX9-NEXT: v_mov_b32_e32 v0, 0x28100000
9532 ; GFX9-NEXT: s_addc_u32 s1, 0, 0
9533 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
9534 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9535 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
9536 ; GFX9-NEXT: s_addc_u32 s0, s1, 0xd95
9537 ; GFX9-NEXT: v_readfirstlane_b32 s2, v0
9538 ; GFX9-NEXT: s_mul_i32 s1, s0, 0xffed2705
9539 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, 0xffed2705
9540 ; GFX9-NEXT: s_add_i32 s3, s3, s1
9541 ; GFX9-NEXT: s_sub_i32 s1, s3, s2
9542 ; GFX9-NEXT: s_mul_i32 s8, s2, 0xffed2705
9543 ; GFX9-NEXT: s_mul_hi_u32 s11, s2, s1
9544 ; GFX9-NEXT: s_mul_i32 s12, s2, s1
9545 ; GFX9-NEXT: s_mul_hi_u32 s2, s2, s8
9546 ; GFX9-NEXT: s_add_u32 s2, s2, s12
9547 ; GFX9-NEXT: s_mul_hi_u32 s9, s0, s8
9548 ; GFX9-NEXT: s_mul_i32 s10, s0, s8
9549 ; GFX9-NEXT: s_addc_u32 s8, 0, s11
9550 ; GFX9-NEXT: s_add_u32 s2, s2, s10
9551 ; GFX9-NEXT: s_mul_hi_u32 s3, s0, s1
9552 ; GFX9-NEXT: s_addc_u32 s2, s8, s9
9553 ; GFX9-NEXT: s_addc_u32 s3, s3, 0
9554 ; GFX9-NEXT: s_mul_i32 s1, s0, s1
9555 ; GFX9-NEXT: s_add_u32 s1, s2, s1
9556 ; GFX9-NEXT: s_addc_u32 s2, 0, s3
9557 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s1, v0
9558 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9559 ; GFX9-NEXT: s_addc_u32 s8, s0, s2
9560 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9561 ; GFX9-NEXT: s_ashr_i32 s0, s7, 31
9562 ; GFX9-NEXT: s_add_u32 s2, s6, s0
9563 ; GFX9-NEXT: s_mov_b32 s1, s0
9564 ; GFX9-NEXT: s_addc_u32 s3, s7, s0
9565 ; GFX9-NEXT: s_xor_b64 s[2:3], s[2:3], s[0:1]
9566 ; GFX9-NEXT: v_readfirstlane_b32 s7, v0
9567 ; GFX9-NEXT: s_mul_i32 s6, s2, s8
9568 ; GFX9-NEXT: s_mul_hi_u32 s9, s2, s7
9569 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s8
9570 ; GFX9-NEXT: s_add_u32 s6, s9, s6
9571 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
9572 ; GFX9-NEXT: s_mul_hi_u32 s10, s3, s7
9573 ; GFX9-NEXT: s_mul_i32 s7, s3, s7
9574 ; GFX9-NEXT: s_add_u32 s6, s6, s7
9575 ; GFX9-NEXT: s_mul_hi_u32 s9, s3, s8
9576 ; GFX9-NEXT: s_addc_u32 s1, s1, s10
9577 ; GFX9-NEXT: s_addc_u32 s6, s9, 0
9578 ; GFX9-NEXT: s_mul_i32 s7, s3, s8
9579 ; GFX9-NEXT: s_add_u32 s1, s1, s7
9580 ; GFX9-NEXT: s_addc_u32 s6, 0, s6
9581 ; GFX9-NEXT: s_mul_hi_u32 s8, s1, 0x12d8fb
9582 ; GFX9-NEXT: s_mul_i32 s1, s1, 0x12d8fb
9583 ; GFX9-NEXT: s_mul_i32 s6, s6, 0x12d8fb
9584 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
9585 ; GFX9-NEXT: s_add_i32 s8, s8, s6
9586 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s2, v0
9587 ; GFX9-NEXT: s_mov_b32 s7, 0x12d8fb
9588 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9589 ; GFX9-NEXT: s_subb_u32 s1, s3, s8
9590 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s7, v0
9591 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9592 ; GFX9-NEXT: s_subb_u32 s2, s1, 0
9593 ; GFX9-NEXT: v_subrev_co_u32_e32 v3, vcc, s7, v1
9594 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9595 ; GFX9-NEXT: s_subb_u32 s3, s2, 0
9596 ; GFX9-NEXT: s_mov_b32 s6, 0x12d8fa
9597 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s6, v1
9598 ; GFX9-NEXT: s_cmp_eq_u32 s2, 0
9599 ; GFX9-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
9600 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
9601 ; GFX9-NEXT: v_cndmask_b32_e32 v4, -1, v4, vcc
9602 ; GFX9-NEXT: v_mov_b32_e32 v5, s2
9603 ; GFX9-NEXT: v_mov_b32_e32 v6, s3
9604 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
9605 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v5, v6, vcc
9606 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
9607 ; GFX9-NEXT: v_cmp_lt_u32_e32 vcc, s6, v0
9608 ; GFX9-NEXT: s_cmp_eq_u32 s1, 0
9609 ; GFX9-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
9610 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
9611 ; GFX9-NEXT: v_cndmask_b32_e32 v3, -1, v3, vcc
9612 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
9613 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
9614 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
9615 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v4, vcc
9616 ; GFX9-NEXT: v_xor_b32_e32 v0, s0, v0
9617 ; GFX9-NEXT: v_xor_b32_e32 v1, s0, v3
9618 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
9619 ; GFX9-NEXT: v_subrev_co_u32_e32 v0, vcc, s0, v0
9620 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
9621 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v1, v3, vcc
9622 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
9623 ; GFX9-NEXT: s_endpgm
9624 %r = srem i64 %x, 1235195
9625 store i64 %r, ptr addrspace(1) %out
9629 define amdgpu_kernel void @srem_i64_pow2k_denom(ptr addrspace(1) %out, i64 %x) {
9630 ; CHECK-LABEL: @srem_i64_pow2k_denom(
9631 ; CHECK-NEXT: [[R:%.*]] = srem i64 [[X:%.*]], 4096
9632 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
9633 ; CHECK-NEXT: ret void
9635 ; GFX6-LABEL: srem_i64_pow2k_denom:
9637 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
9638 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
9639 ; GFX6-NEXT: s_mov_b32 s6, -1
9640 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9641 ; GFX6-NEXT: s_mov_b32 s4, s0
9642 ; GFX6-NEXT: s_ashr_i32 s0, s3, 31
9643 ; GFX6-NEXT: s_lshr_b32 s0, s0, 20
9644 ; GFX6-NEXT: s_add_u32 s0, s2, s0
9645 ; GFX6-NEXT: s_mov_b32 s5, s1
9646 ; GFX6-NEXT: s_addc_u32 s1, s3, 0
9647 ; GFX6-NEXT: s_and_b32 s0, s0, 0xfffff000
9648 ; GFX6-NEXT: s_sub_u32 s0, s2, s0
9649 ; GFX6-NEXT: s_subb_u32 s1, s3, s1
9650 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
9651 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
9652 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
9653 ; GFX6-NEXT: s_endpgm
9655 ; GFX9-LABEL: srem_i64_pow2k_denom:
9657 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
9658 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
9659 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9660 ; GFX9-NEXT: s_ashr_i32 s0, s7, 31
9661 ; GFX9-NEXT: s_lshr_b32 s0, s0, 20
9662 ; GFX9-NEXT: s_add_u32 s0, s6, s0
9663 ; GFX9-NEXT: s_addc_u32 s1, s7, 0
9664 ; GFX9-NEXT: s_and_b32 s0, s0, 0xfffff000
9665 ; GFX9-NEXT: s_sub_u32 s0, s6, s0
9666 ; GFX9-NEXT: s_subb_u32 s1, s7, s1
9667 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
9668 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
9669 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[4:5]
9670 ; GFX9-NEXT: s_endpgm
9671 %r = srem i64 %x, 4096
9672 store i64 %r, ptr addrspace(1) %out
9676 define amdgpu_kernel void @srem_i64_pow2_shl_denom(ptr addrspace(1) %out, i64 %x, i64 %y) {
9677 ; CHECK-LABEL: @srem_i64_pow2_shl_denom(
9678 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl i64 4096, [[Y:%.*]]
9679 ; CHECK-NEXT: [[R:%.*]] = srem i64 [[X:%.*]], [[SHL_Y]]
9680 ; CHECK-NEXT: store i64 [[R]], ptr addrspace(1) [[OUT:%.*]], align 8
9681 ; CHECK-NEXT: ret void
9683 ; GFX6-LABEL: srem_i64_pow2_shl_denom:
9685 ; GFX6-NEXT: s_load_dword s0, s[2:3], 0xd
9686 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
9687 ; GFX6-NEXT: s_mov_b32 s6, -1
9688 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9689 ; GFX6-NEXT: s_lshl_b64 s[0:1], 0x1000, s0
9690 ; GFX6-NEXT: s_ashr_i32 s4, s1, 31
9691 ; GFX6-NEXT: s_add_u32 s0, s0, s4
9692 ; GFX6-NEXT: s_mov_b32 s5, s4
9693 ; GFX6-NEXT: s_addc_u32 s1, s1, s4
9694 ; GFX6-NEXT: s_xor_b64 s[8:9], s[0:1], s[4:5]
9695 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s8
9696 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s9
9697 ; GFX6-NEXT: s_sub_u32 s4, 0, s8
9698 ; GFX6-NEXT: s_subb_u32 s5, 0, s9
9699 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
9700 ; GFX6-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
9701 ; GFX6-NEXT: v_rcp_f32_e32 v0, v0
9702 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9703 ; GFX6-NEXT: s_ashr_i32 s10, s3, 31
9704 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
9705 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
9706 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
9707 ; GFX6-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
9708 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
9709 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
9710 ; GFX6-NEXT: s_add_u32 s2, s2, s10
9711 ; GFX6-NEXT: s_mov_b32 s11, s10
9712 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
9713 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
9714 ; GFX6-NEXT: v_mul_lo_u32 v5, s5, v0
9715 ; GFX6-NEXT: v_mul_lo_u32 v4, s4, v0
9716 ; GFX6-NEXT: s_addc_u32 s3, s3, s10
9717 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
9718 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v5
9719 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, v4
9720 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v2
9721 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v2
9722 ; GFX6-NEXT: v_mul_lo_u32 v6, v1, v4
9723 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v4
9724 ; GFX6-NEXT: v_mul_hi_u32 v8, v1, v2
9725 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
9726 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
9727 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
9728 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v6
9729 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v5, v4, vcc
9730 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
9731 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
9732 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
9733 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
9734 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
9735 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
9736 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
9737 ; GFX6-NEXT: v_mul_lo_u32 v4, s5, v0
9738 ; GFX6-NEXT: s_xor_b64 s[12:13], s[2:3], s[10:11]
9739 ; GFX6-NEXT: s_mov_b32 s5, s1
9740 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
9741 ; GFX6-NEXT: v_mul_lo_u32 v3, s4, v0
9742 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
9743 ; GFX6-NEXT: v_mul_lo_u32 v6, v0, v2
9744 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v3
9745 ; GFX6-NEXT: v_mul_hi_u32 v8, v0, v2
9746 ; GFX6-NEXT: v_mul_hi_u32 v5, v1, v3
9747 ; GFX6-NEXT: v_mul_lo_u32 v3, v1, v3
9748 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v2
9749 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
9750 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
9751 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
9752 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v6, v3
9753 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
9754 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
9755 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
9756 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
9757 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
9758 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
9759 ; GFX6-NEXT: v_mul_lo_u32 v2, s12, v1
9760 ; GFX6-NEXT: v_mul_hi_u32 v3, s12, v0
9761 ; GFX6-NEXT: v_mul_hi_u32 v4, s12, v1
9762 ; GFX6-NEXT: v_mul_hi_u32 v5, s13, v1
9763 ; GFX6-NEXT: v_mul_lo_u32 v1, s13, v1
9764 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
9765 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
9766 ; GFX6-NEXT: v_mul_lo_u32 v4, s13, v0
9767 ; GFX6-NEXT: v_mul_hi_u32 v0, s13, v0
9768 ; GFX6-NEXT: s_mov_b32 s4, s0
9769 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
9770 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
9771 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
9772 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
9773 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
9774 ; GFX6-NEXT: v_mul_lo_u32 v1, s8, v1
9775 ; GFX6-NEXT: v_mul_hi_u32 v2, s8, v0
9776 ; GFX6-NEXT: v_mul_lo_u32 v3, s9, v0
9777 ; GFX6-NEXT: v_mul_lo_u32 v0, s8, v0
9778 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
9779 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v3, v1
9780 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s13, v1
9781 ; GFX6-NEXT: v_mov_b32_e32 v3, s9
9782 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s12, v0
9783 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc
9784 ; GFX6-NEXT: v_subrev_i32_e64 v4, s[0:1], s8, v0
9785 ; GFX6-NEXT: v_subbrev_u32_e64 v5, s[2:3], 0, v2, s[0:1]
9786 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s9, v5
9787 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[2:3]
9788 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s8, v4
9789 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, s[0:1]
9790 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[2:3]
9791 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[2:3], s9, v5
9792 ; GFX6-NEXT: v_subrev_i32_e64 v3, s[0:1], s8, v4
9793 ; GFX6-NEXT: v_cndmask_b32_e64 v6, v6, v7, s[2:3]
9794 ; GFX6-NEXT: v_subbrev_u32_e64 v2, s[0:1], 0, v2, s[0:1]
9795 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
9796 ; GFX6-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[0:1]
9797 ; GFX6-NEXT: v_mov_b32_e32 v4, s13
9798 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v4, v1, vcc
9799 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s9, v1
9800 ; GFX6-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
9801 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s8, v0
9802 ; GFX6-NEXT: v_cndmask_b32_e64 v2, v5, v2, s[0:1]
9803 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
9804 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s9, v1
9805 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
9806 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
9807 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
9808 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
9809 ; GFX6-NEXT: v_xor_b32_e32 v0, s10, v0
9810 ; GFX6-NEXT: v_xor_b32_e32 v1, s10, v1
9811 ; GFX6-NEXT: v_mov_b32_e32 v2, s10
9812 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s10, v0
9813 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v2, vcc
9814 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
9815 ; GFX6-NEXT: s_endpgm
9817 ; GFX9-LABEL: srem_i64_pow2_shl_denom:
9819 ; GFX9-NEXT: s_load_dword s0, s[2:3], 0x34
9820 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9821 ; GFX9-NEXT: s_lshl_b64 s[0:1], 0x1000, s0
9822 ; GFX9-NEXT: s_ashr_i32 s4, s1, 31
9823 ; GFX9-NEXT: s_add_u32 s0, s0, s4
9824 ; GFX9-NEXT: s_mov_b32 s5, s4
9825 ; GFX9-NEXT: s_addc_u32 s1, s1, s4
9826 ; GFX9-NEXT: s_xor_b64 s[8:9], s[0:1], s[4:5]
9827 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s8
9828 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s9
9829 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x24
9830 ; GFX9-NEXT: s_sub_u32 s0, 0, s8
9831 ; GFX9-NEXT: s_subb_u32 s1, 0, s9
9832 ; GFX9-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
9833 ; GFX9-NEXT: v_rcp_f32_e32 v1, v0
9834 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
9835 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x5f7ffffc, v1
9836 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x2f800000, v1
9837 ; GFX9-NEXT: v_trunc_f32_e32 v2, v2
9838 ; GFX9-NEXT: v_madmk_f32 v1, v2, 0xcf800000, v1
9839 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
9840 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
9841 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
9842 ; GFX9-NEXT: v_readfirstlane_b32 s3, v1
9843 ; GFX9-NEXT: s_mul_i32 s10, s0, s2
9844 ; GFX9-NEXT: s_mul_hi_u32 s12, s0, s3
9845 ; GFX9-NEXT: s_mul_i32 s11, s1, s3
9846 ; GFX9-NEXT: s_add_i32 s10, s12, s10
9847 ; GFX9-NEXT: s_mul_i32 s13, s0, s3
9848 ; GFX9-NEXT: s_add_i32 s10, s10, s11
9849 ; GFX9-NEXT: s_mul_hi_u32 s12, s3, s13
9850 ; GFX9-NEXT: s_mul_hi_u32 s11, s3, s10
9851 ; GFX9-NEXT: s_mul_i32 s3, s3, s10
9852 ; GFX9-NEXT: s_add_u32 s3, s12, s3
9853 ; GFX9-NEXT: s_addc_u32 s11, 0, s11
9854 ; GFX9-NEXT: s_mul_hi_u32 s14, s2, s13
9855 ; GFX9-NEXT: s_mul_i32 s13, s2, s13
9856 ; GFX9-NEXT: s_add_u32 s3, s3, s13
9857 ; GFX9-NEXT: s_mul_hi_u32 s12, s2, s10
9858 ; GFX9-NEXT: s_addc_u32 s3, s11, s14
9859 ; GFX9-NEXT: s_addc_u32 s11, s12, 0
9860 ; GFX9-NEXT: s_mul_i32 s10, s2, s10
9861 ; GFX9-NEXT: s_add_u32 s3, s3, s10
9862 ; GFX9-NEXT: s_addc_u32 s10, 0, s11
9863 ; GFX9-NEXT: v_add_co_u32_e32 v1, vcc, s3, v1
9864 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9865 ; GFX9-NEXT: s_addc_u32 s2, s2, s10
9866 ; GFX9-NEXT: v_readfirstlane_b32 s10, v1
9867 ; GFX9-NEXT: s_mul_i32 s3, s0, s2
9868 ; GFX9-NEXT: s_mul_hi_u32 s11, s0, s10
9869 ; GFX9-NEXT: s_add_i32 s3, s11, s3
9870 ; GFX9-NEXT: s_mul_i32 s1, s1, s10
9871 ; GFX9-NEXT: s_add_i32 s3, s3, s1
9872 ; GFX9-NEXT: s_mul_i32 s0, s0, s10
9873 ; GFX9-NEXT: s_mul_hi_u32 s11, s2, s0
9874 ; GFX9-NEXT: s_mul_i32 s12, s2, s0
9875 ; GFX9-NEXT: s_mul_i32 s14, s10, s3
9876 ; GFX9-NEXT: s_mul_hi_u32 s0, s10, s0
9877 ; GFX9-NEXT: s_mul_hi_u32 s13, s10, s3
9878 ; GFX9-NEXT: s_add_u32 s0, s0, s14
9879 ; GFX9-NEXT: s_addc_u32 s10, 0, s13
9880 ; GFX9-NEXT: s_add_u32 s0, s0, s12
9881 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
9882 ; GFX9-NEXT: s_addc_u32 s0, s10, s11
9883 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
9884 ; GFX9-NEXT: s_mul_i32 s3, s2, s3
9885 ; GFX9-NEXT: s_add_u32 s0, s0, s3
9886 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
9887 ; GFX9-NEXT: v_add_co_u32_e32 v1, vcc, s0, v1
9888 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9889 ; GFX9-NEXT: s_addc_u32 s2, s2, s1
9890 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
9891 ; GFX9-NEXT: s_ashr_i32 s10, s7, 31
9892 ; GFX9-NEXT: s_add_u32 s0, s6, s10
9893 ; GFX9-NEXT: s_mov_b32 s11, s10
9894 ; GFX9-NEXT: s_addc_u32 s1, s7, s10
9895 ; GFX9-NEXT: s_xor_b64 s[6:7], s[0:1], s[10:11]
9896 ; GFX9-NEXT: v_readfirstlane_b32 s3, v1
9897 ; GFX9-NEXT: s_mul_i32 s1, s6, s2
9898 ; GFX9-NEXT: s_mul_hi_u32 s11, s6, s3
9899 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s2
9900 ; GFX9-NEXT: s_add_u32 s1, s11, s1
9901 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
9902 ; GFX9-NEXT: s_mul_hi_u32 s12, s7, s3
9903 ; GFX9-NEXT: s_mul_i32 s3, s7, s3
9904 ; GFX9-NEXT: s_add_u32 s1, s1, s3
9905 ; GFX9-NEXT: s_mul_hi_u32 s11, s7, s2
9906 ; GFX9-NEXT: s_addc_u32 s0, s0, s12
9907 ; GFX9-NEXT: s_addc_u32 s1, s11, 0
9908 ; GFX9-NEXT: s_mul_i32 s2, s7, s2
9909 ; GFX9-NEXT: s_add_u32 s0, s0, s2
9910 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
9911 ; GFX9-NEXT: s_mul_i32 s1, s8, s1
9912 ; GFX9-NEXT: s_mul_hi_u32 s2, s8, s0
9913 ; GFX9-NEXT: s_add_i32 s1, s2, s1
9914 ; GFX9-NEXT: s_mul_i32 s2, s9, s0
9915 ; GFX9-NEXT: s_mul_i32 s0, s8, s0
9916 ; GFX9-NEXT: s_add_i32 s11, s1, s2
9917 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
9918 ; GFX9-NEXT: s_sub_i32 s1, s7, s11
9919 ; GFX9-NEXT: v_sub_co_u32_e32 v1, vcc, s6, v1
9920 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9921 ; GFX9-NEXT: s_subb_u32 s6, s1, s9
9922 ; GFX9-NEXT: v_subrev_co_u32_e64 v2, s[0:1], s8, v1
9923 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
9924 ; GFX9-NEXT: s_subb_u32 s12, s6, 0
9925 ; GFX9-NEXT: s_cmp_ge_u32 s12, s9
9926 ; GFX9-NEXT: s_cselect_b32 s13, -1, 0
9927 ; GFX9-NEXT: v_cmp_le_u32_e64 s[2:3], s8, v2
9928 ; GFX9-NEXT: s_cmp_eq_u32 s12, s9
9929 ; GFX9-NEXT: v_cndmask_b32_e64 v3, 0, -1, s[2:3]
9930 ; GFX9-NEXT: v_mov_b32_e32 v4, s13
9931 ; GFX9-NEXT: s_cselect_b64 s[2:3], -1, 0
9932 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
9933 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[2:3]
9934 ; GFX9-NEXT: s_subb_u32 s2, s6, s9
9935 ; GFX9-NEXT: v_subrev_co_u32_e64 v4, s[0:1], s8, v2
9936 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
9937 ; GFX9-NEXT: s_subb_u32 s2, s2, 0
9938 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v3
9939 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v2, v4, s[0:1]
9940 ; GFX9-NEXT: v_mov_b32_e32 v3, s12
9941 ; GFX9-NEXT: v_mov_b32_e32 v4, s2
9942 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
9943 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v3, v4, s[0:1]
9944 ; GFX9-NEXT: s_subb_u32 s0, s7, s11
9945 ; GFX9-NEXT: s_cmp_ge_u32 s0, s9
9946 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
9947 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s8, v1
9948 ; GFX9-NEXT: s_cmp_eq_u32 s0, s9
9949 ; GFX9-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
9950 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
9951 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
9952 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc
9953 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
9954 ; GFX9-NEXT: v_mov_b32_e32 v5, s0
9955 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
9956 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
9957 ; GFX9-NEXT: v_xor_b32_e32 v1, s10, v1
9958 ; GFX9-NEXT: v_xor_b32_e32 v2, s10, v3
9959 ; GFX9-NEXT: v_mov_b32_e32 v3, s10
9960 ; GFX9-NEXT: v_subrev_co_u32_e32 v1, vcc, s10, v1
9961 ; GFX9-NEXT: v_subb_co_u32_e32 v2, vcc, v2, v3, vcc
9962 ; GFX9-NEXT: global_store_dwordx2 v0, v[1:2], s[4:5]
9963 ; GFX9-NEXT: s_endpgm
9964 %shl.y = shl i64 4096, %y
9965 %r = srem i64 %x, %shl.y
9966 store i64 %r, ptr addrspace(1) %out
9970 define amdgpu_kernel void @srem_v2i64_pow2k_denom(ptr addrspace(1) %out, <2 x i64> %x) {
9971 ; CHECK-LABEL: @srem_v2i64_pow2k_denom(
9972 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
9973 ; CHECK-NEXT: [[TMP2:%.*]] = srem i64 [[TMP1]], 4096
9974 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> poison, i64 [[TMP2]], i64 0
9975 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1
9976 ; CHECK-NEXT: [[TMP5:%.*]] = srem i64 [[TMP4]], 4096
9977 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1
9978 ; CHECK-NEXT: store <2 x i64> [[TMP6]], ptr addrspace(1) [[OUT:%.*]], align 16
9979 ; CHECK-NEXT: ret void
9981 ; GFX6-LABEL: srem_v2i64_pow2k_denom:
9983 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0xd
9984 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x9
9985 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
9986 ; GFX6-NEXT: s_mov_b32 s2, -1
9987 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9988 ; GFX6-NEXT: s_ashr_i32 s8, s5, 31
9989 ; GFX6-NEXT: s_lshr_b32 s8, s8, 20
9990 ; GFX6-NEXT: s_add_u32 s8, s4, s8
9991 ; GFX6-NEXT: s_addc_u32 s9, s5, 0
9992 ; GFX6-NEXT: s_and_b32 s8, s8, 0xfffff000
9993 ; GFX6-NEXT: s_sub_u32 s4, s4, s8
9994 ; GFX6-NEXT: s_subb_u32 s5, s5, s9
9995 ; GFX6-NEXT: s_ashr_i32 s8, s7, 31
9996 ; GFX6-NEXT: s_lshr_b32 s8, s8, 20
9997 ; GFX6-NEXT: s_add_u32 s8, s6, s8
9998 ; GFX6-NEXT: s_addc_u32 s9, s7, 0
9999 ; GFX6-NEXT: s_and_b32 s8, s8, 0xfffff000
10000 ; GFX6-NEXT: s_sub_u32 s6, s6, s8
10001 ; GFX6-NEXT: s_subb_u32 s7, s7, s9
10002 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
10003 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
10004 ; GFX6-NEXT: v_mov_b32_e32 v2, s6
10005 ; GFX6-NEXT: v_mov_b32_e32 v3, s7
10006 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[0:3], 0
10007 ; GFX6-NEXT: s_endpgm
10009 ; GFX9-LABEL: srem_v2i64_pow2k_denom:
10011 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x34
10012 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x24
10013 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
10014 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
10015 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
10016 ; GFX9-NEXT: s_lshr_b32 s2, s2, 20
10017 ; GFX9-NEXT: s_add_u32 s2, s4, s2
10018 ; GFX9-NEXT: s_addc_u32 s3, s5, 0
10019 ; GFX9-NEXT: s_and_b32 s2, s2, 0xfffff000
10020 ; GFX9-NEXT: s_sub_u32 s2, s4, s2
10021 ; GFX9-NEXT: s_subb_u32 s3, s5, s3
10022 ; GFX9-NEXT: s_ashr_i32 s4, s7, 31
10023 ; GFX9-NEXT: s_lshr_b32 s4, s4, 20
10024 ; GFX9-NEXT: s_add_u32 s4, s6, s4
10025 ; GFX9-NEXT: s_addc_u32 s5, s7, 0
10026 ; GFX9-NEXT: s_and_b32 s4, s4, 0xfffff000
10027 ; GFX9-NEXT: s_sub_u32 s4, s6, s4
10028 ; GFX9-NEXT: s_subb_u32 s5, s7, s5
10029 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
10030 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
10031 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
10032 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
10033 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[0:1]
10034 ; GFX9-NEXT: s_endpgm
10035 %r = srem <2 x i64> %x, <i64 4096, i64 4096>
10036 store <2 x i64> %r, ptr addrspace(1) %out
10040 define amdgpu_kernel void @srem_v2i64_pow2_shl_denom(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
10041 ; CHECK-LABEL: @srem_v2i64_pow2_shl_denom(
10042 ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> <i64 4096, i64 4096>, [[Y:%.*]]
10043 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0
10044 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0
10045 ; CHECK-NEXT: [[TMP3:%.*]] = srem i64 [[TMP1]], [[TMP2]]
10046 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> poison, i64 [[TMP3]], i64 0
10047 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1
10048 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1
10049 ; CHECK-NEXT: [[TMP7:%.*]] = srem i64 [[TMP5]], [[TMP6]]
10050 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1
10051 ; CHECK-NEXT: store <2 x i64> [[TMP8]], ptr addrspace(1) [[OUT:%.*]], align 16
10052 ; CHECK-NEXT: ret void
10054 ; GFX6-LABEL: srem_v2i64_pow2_shl_denom:
10056 ; GFX6-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
10057 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10058 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
10059 ; GFX6-NEXT: s_lshl_b64 s[0:1], 0x1000, s8
10060 ; GFX6-NEXT: s_lshl_b64 s[16:17], 0x1000, s10
10061 ; GFX6-NEXT: s_ashr_i32 s8, s1, 31
10062 ; GFX6-NEXT: s_add_u32 s0, s0, s8
10063 ; GFX6-NEXT: s_mov_b32 s9, s8
10064 ; GFX6-NEXT: s_addc_u32 s1, s1, s8
10065 ; GFX6-NEXT: s_xor_b64 s[14:15], s[0:1], s[8:9]
10066 ; GFX6-NEXT: v_cvt_f32_u32_e32 v0, s14
10067 ; GFX6-NEXT: v_cvt_f32_u32_e32 v1, s15
10068 ; GFX6-NEXT: s_sub_u32 s0, 0, s14
10069 ; GFX6-NEXT: s_subb_u32 s1, 0, s15
10070 ; GFX6-NEXT: s_ashr_i32 s12, s5, 31
10071 ; GFX6-NEXT: v_mac_f32_e32 v0, 0x4f800000, v1
10072 ; GFX6-NEXT: v_rcp_f32_e32 v0, v0
10073 ; GFX6-NEXT: s_mov_b32 s13, s12
10074 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x9
10075 ; GFX6-NEXT: s_mov_b32 s10, -1
10076 ; GFX6-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
10077 ; GFX6-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
10078 ; GFX6-NEXT: v_trunc_f32_e32 v1, v1
10079 ; GFX6-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1
10080 ; GFX6-NEXT: v_cvt_u32_f32_e32 v1, v1
10081 ; GFX6-NEXT: v_cvt_u32_f32_e32 v0, v0
10082 ; GFX6-NEXT: v_mul_lo_u32 v2, s0, v1
10083 ; GFX6-NEXT: v_mul_hi_u32 v3, s0, v0
10084 ; GFX6-NEXT: v_mul_lo_u32 v5, s1, v0
10085 ; GFX6-NEXT: v_mul_lo_u32 v4, s0, v0
10086 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
10087 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v5
10088 ; GFX6-NEXT: v_mul_hi_u32 v3, v0, v4
10089 ; GFX6-NEXT: v_mul_lo_u32 v5, v0, v2
10090 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v2
10091 ; GFX6-NEXT: v_mul_hi_u32 v6, v1, v4
10092 ; GFX6-NEXT: v_mul_lo_u32 v4, v1, v4
10093 ; GFX6-NEXT: v_mul_hi_u32 v8, v1, v2
10094 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
10095 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
10096 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
10097 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
10098 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
10099 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
10100 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
10101 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
10102 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
10103 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
10104 ; GFX6-NEXT: v_mul_lo_u32 v2, s0, v1
10105 ; GFX6-NEXT: v_mul_hi_u32 v3, s0, v0
10106 ; GFX6-NEXT: v_mul_lo_u32 v4, s1, v0
10107 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
10108 ; GFX6-NEXT: v_mul_lo_u32 v3, s0, v0
10109 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
10110 ; GFX6-NEXT: v_mul_lo_u32 v6, v0, v2
10111 ; GFX6-NEXT: v_mul_hi_u32 v7, v0, v3
10112 ; GFX6-NEXT: v_mul_hi_u32 v8, v0, v2
10113 ; GFX6-NEXT: v_mul_hi_u32 v5, v1, v3
10114 ; GFX6-NEXT: v_mul_lo_u32 v3, v1, v3
10115 ; GFX6-NEXT: v_mul_hi_u32 v4, v1, v2
10116 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
10117 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
10118 ; GFX6-NEXT: v_mul_lo_u32 v2, v1, v2
10119 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v6, v3
10120 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
10121 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
10122 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
10123 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
10124 ; GFX6-NEXT: s_add_u32 s0, s4, s12
10125 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
10126 ; GFX6-NEXT: s_addc_u32 s1, s5, s12
10127 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
10128 ; GFX6-NEXT: s_xor_b64 s[4:5], s[0:1], s[12:13]
10129 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v1
10130 ; GFX6-NEXT: v_mul_hi_u32 v3, s4, v0
10131 ; GFX6-NEXT: v_mul_hi_u32 v4, s4, v1
10132 ; GFX6-NEXT: v_mul_hi_u32 v5, s5, v1
10133 ; GFX6-NEXT: v_mul_lo_u32 v1, s5, v1
10134 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v3, v2
10135 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
10136 ; GFX6-NEXT: v_mul_lo_u32 v4, s5, v0
10137 ; GFX6-NEXT: v_mul_hi_u32 v0, s5, v0
10138 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
10139 ; GFX6-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
10140 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
10141 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
10142 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
10143 ; GFX6-NEXT: v_mul_lo_u32 v1, s14, v1
10144 ; GFX6-NEXT: v_mul_hi_u32 v2, s14, v0
10145 ; GFX6-NEXT: v_mul_lo_u32 v3, s15, v0
10146 ; GFX6-NEXT: v_mul_lo_u32 v0, s14, v0
10147 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
10148 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v3, v1
10149 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s5, v1
10150 ; GFX6-NEXT: v_mov_b32_e32 v3, s15
10151 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, s4, v0
10152 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc
10153 ; GFX6-NEXT: v_subrev_i32_e64 v4, s[0:1], s14, v0
10154 ; GFX6-NEXT: v_subbrev_u32_e64 v5, s[2:3], 0, v2, s[0:1]
10155 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s15, v5
10156 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[2:3]
10157 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s14, v4
10158 ; GFX6-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, s[0:1]
10159 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[2:3]
10160 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[2:3], s15, v5
10161 ; GFX6-NEXT: v_subrev_i32_e64 v3, s[0:1], s14, v4
10162 ; GFX6-NEXT: v_cndmask_b32_e64 v6, v6, v7, s[2:3]
10163 ; GFX6-NEXT: v_subbrev_u32_e64 v2, s[0:1], 0, v2, s[0:1]
10164 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
10165 ; GFX6-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[0:1]
10166 ; GFX6-NEXT: v_cndmask_b32_e64 v2, v5, v2, s[0:1]
10167 ; GFX6-NEXT: s_ashr_i32 s0, s17, 31
10168 ; GFX6-NEXT: s_add_u32 s2, s16, s0
10169 ; GFX6-NEXT: s_mov_b32 s1, s0
10170 ; GFX6-NEXT: s_addc_u32 s3, s17, s0
10171 ; GFX6-NEXT: v_mov_b32_e32 v4, s5
10172 ; GFX6-NEXT: s_xor_b64 s[4:5], s[2:3], s[0:1]
10173 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v4, v1, vcc
10174 ; GFX6-NEXT: v_cvt_f32_u32_e32 v4, s4
10175 ; GFX6-NEXT: v_cvt_f32_u32_e32 v5, s5
10176 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s15, v1
10177 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
10178 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s14, v0
10179 ; GFX6-NEXT: v_mac_f32_e32 v4, 0x4f800000, v5
10180 ; GFX6-NEXT: v_rcp_f32_e32 v4, v4
10181 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, vcc
10182 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s15, v1
10183 ; GFX6-NEXT: v_cndmask_b32_e32 v5, v6, v7, vcc
10184 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5
10185 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
10186 ; GFX6-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v4
10187 ; GFX6-NEXT: v_mul_f32_e32 v4, 0x2f800000, v2
10188 ; GFX6-NEXT: v_trunc_f32_e32 v4, v4
10189 ; GFX6-NEXT: v_mac_f32_e32 v2, 0xcf800000, v4
10190 ; GFX6-NEXT: v_cvt_u32_f32_e32 v2, v2
10191 ; GFX6-NEXT: v_cvt_u32_f32_e32 v4, v4
10192 ; GFX6-NEXT: s_sub_u32 s0, 0, s4
10193 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
10194 ; GFX6-NEXT: v_mul_hi_u32 v3, s0, v2
10195 ; GFX6-NEXT: v_mul_lo_u32 v5, s0, v4
10196 ; GFX6-NEXT: s_subb_u32 s1, 0, s5
10197 ; GFX6-NEXT: v_mul_lo_u32 v6, s1, v2
10198 ; GFX6-NEXT: s_ashr_i32 s14, s7, 31
10199 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v5, v3
10200 ; GFX6-NEXT: v_mul_lo_u32 v5, s0, v2
10201 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v6
10202 ; GFX6-NEXT: v_mul_lo_u32 v6, v2, v3
10203 ; GFX6-NEXT: v_mul_hi_u32 v7, v2, v5
10204 ; GFX6-NEXT: v_mul_hi_u32 v8, v2, v3
10205 ; GFX6-NEXT: v_mul_hi_u32 v9, v4, v3
10206 ; GFX6-NEXT: v_mul_lo_u32 v3, v4, v3
10207 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v7, v6
10208 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
10209 ; GFX6-NEXT: v_mul_lo_u32 v8, v4, v5
10210 ; GFX6-NEXT: v_mul_hi_u32 v5, v4, v5
10211 ; GFX6-NEXT: s_mov_b32 s15, s14
10212 ; GFX6-NEXT: v_xor_b32_e32 v0, s12, v0
10213 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v6, v8
10214 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v7, v5, vcc
10215 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v9, vcc
10216 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v5, v3
10217 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
10218 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
10219 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v4, v5, vcc
10220 ; GFX6-NEXT: v_mul_lo_u32 v4, s0, v3
10221 ; GFX6-NEXT: v_mul_hi_u32 v5, s0, v2
10222 ; GFX6-NEXT: v_mul_lo_u32 v6, s1, v2
10223 ; GFX6-NEXT: v_xor_b32_e32 v1, s12, v1
10224 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
10225 ; GFX6-NEXT: v_mul_lo_u32 v5, s0, v2
10226 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v6
10227 ; GFX6-NEXT: v_mul_lo_u32 v8, v2, v4
10228 ; GFX6-NEXT: v_mul_hi_u32 v9, v2, v5
10229 ; GFX6-NEXT: v_mul_hi_u32 v10, v2, v4
10230 ; GFX6-NEXT: v_mul_hi_u32 v7, v3, v5
10231 ; GFX6-NEXT: v_mul_lo_u32 v5, v3, v5
10232 ; GFX6-NEXT: v_mul_hi_u32 v6, v3, v4
10233 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v9, v8
10234 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
10235 ; GFX6-NEXT: v_mul_lo_u32 v4, v3, v4
10236 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v8, v5
10237 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v9, v7, vcc
10238 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
10239 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
10240 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
10241 ; GFX6-NEXT: s_add_u32 s0, s6, s14
10242 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
10243 ; GFX6-NEXT: s_addc_u32 s1, s7, s14
10244 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v3, v5, vcc
10245 ; GFX6-NEXT: s_xor_b64 s[6:7], s[0:1], s[14:15]
10246 ; GFX6-NEXT: v_mul_lo_u32 v4, s6, v3
10247 ; GFX6-NEXT: v_mul_hi_u32 v5, s6, v2
10248 ; GFX6-NEXT: v_mul_hi_u32 v7, s6, v3
10249 ; GFX6-NEXT: v_mul_hi_u32 v8, s7, v3
10250 ; GFX6-NEXT: v_mul_lo_u32 v3, s7, v3
10251 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v5, v4
10252 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
10253 ; GFX6-NEXT: v_mul_lo_u32 v7, s7, v2
10254 ; GFX6-NEXT: v_mul_hi_u32 v2, s7, v2
10255 ; GFX6-NEXT: v_mov_b32_e32 v6, s12
10256 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v7
10257 ; GFX6-NEXT: v_addc_u32_e32 v2, vcc, v5, v2, vcc
10258 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
10259 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
10260 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
10261 ; GFX6-NEXT: v_mul_lo_u32 v3, s4, v3
10262 ; GFX6-NEXT: v_mul_hi_u32 v4, s4, v2
10263 ; GFX6-NEXT: v_mul_lo_u32 v5, s5, v2
10264 ; GFX6-NEXT: v_subrev_i32_e32 v0, vcc, s12, v0
10265 ; GFX6-NEXT: v_mul_lo_u32 v2, s4, v2
10266 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v6, vcc
10267 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
10268 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v5, v3
10269 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s7, v3
10270 ; GFX6-NEXT: v_mov_b32_e32 v5, s5
10271 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s6, v2
10272 ; GFX6-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc
10273 ; GFX6-NEXT: v_subrev_i32_e64 v6, s[0:1], s4, v2
10274 ; GFX6-NEXT: v_subbrev_u32_e64 v7, s[2:3], 0, v4, s[0:1]
10275 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s5, v7
10276 ; GFX6-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[2:3]
10277 ; GFX6-NEXT: v_cmp_le_u32_e64 s[2:3], s4, v6
10278 ; GFX6-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, s[0:1]
10279 ; GFX6-NEXT: v_cndmask_b32_e64 v9, 0, -1, s[2:3]
10280 ; GFX6-NEXT: v_cmp_eq_u32_e64 s[2:3], s5, v7
10281 ; GFX6-NEXT: v_subrev_i32_e64 v5, s[0:1], s4, v6
10282 ; GFX6-NEXT: v_cndmask_b32_e64 v8, v8, v9, s[2:3]
10283 ; GFX6-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1]
10284 ; GFX6-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v8
10285 ; GFX6-NEXT: v_cndmask_b32_e64 v5, v6, v5, s[0:1]
10286 ; GFX6-NEXT: v_mov_b32_e32 v6, s7
10287 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v6, v3, vcc
10288 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s5, v3
10289 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
10290 ; GFX6-NEXT: v_cmp_le_u32_e32 vcc, s4, v2
10291 ; GFX6-NEXT: v_cndmask_b32_e64 v4, v7, v4, s[0:1]
10292 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, -1, vcc
10293 ; GFX6-NEXT: v_cmp_eq_u32_e32 vcc, s5, v3
10294 ; GFX6-NEXT: v_cndmask_b32_e32 v6, v6, v7, vcc
10295 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v6
10296 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v2, v5, vcc
10297 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v3, v4, vcc
10298 ; GFX6-NEXT: v_xor_b32_e32 v2, s14, v2
10299 ; GFX6-NEXT: v_xor_b32_e32 v3, s14, v3
10300 ; GFX6-NEXT: v_mov_b32_e32 v4, s14
10301 ; GFX6-NEXT: v_subrev_i32_e32 v2, vcc, s14, v2
10302 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v3, v4, vcc
10303 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10304 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
10305 ; GFX6-NEXT: s_endpgm
10307 ; GFX9-LABEL: srem_v2i64_pow2_shl_denom:
10309 ; GFX9-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0x34
10310 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
10311 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
10312 ; GFX9-NEXT: s_lshl_b64 s[0:1], 0x1000, s8
10313 ; GFX9-NEXT: s_lshl_b64 s[10:11], 0x1000, s10
10314 ; GFX9-NEXT: s_ashr_i32 s8, s1, 31
10315 ; GFX9-NEXT: s_add_u32 s0, s0, s8
10316 ; GFX9-NEXT: s_mov_b32 s9, s8
10317 ; GFX9-NEXT: s_addc_u32 s1, s1, s8
10318 ; GFX9-NEXT: s_xor_b64 s[12:13], s[0:1], s[8:9]
10319 ; GFX9-NEXT: v_cvt_f32_u32_e32 v0, s12
10320 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s13
10321 ; GFX9-NEXT: s_load_dwordx2 s[8:9], s[2:3], 0x24
10322 ; GFX9-NEXT: s_sub_u32 s0, 0, s12
10323 ; GFX9-NEXT: s_subb_u32 s1, 0, s13
10324 ; GFX9-NEXT: v_mac_f32_e32 v0, 0x4f800000, v1
10325 ; GFX9-NEXT: v_rcp_f32_e32 v0, v0
10326 ; GFX9-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
10327 ; GFX9-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
10328 ; GFX9-NEXT: v_trunc_f32_e32 v1, v1
10329 ; GFX9-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1
10330 ; GFX9-NEXT: v_cvt_u32_f32_e32 v1, v1
10331 ; GFX9-NEXT: v_cvt_u32_f32_e32 v0, v0
10332 ; GFX9-NEXT: v_readfirstlane_b32 s2, v1
10333 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
10334 ; GFX9-NEXT: s_mul_i32 s14, s0, s2
10335 ; GFX9-NEXT: s_mul_hi_u32 s16, s0, s3
10336 ; GFX9-NEXT: s_mul_i32 s15, s1, s3
10337 ; GFX9-NEXT: s_add_i32 s14, s16, s14
10338 ; GFX9-NEXT: s_mul_i32 s17, s0, s3
10339 ; GFX9-NEXT: s_add_i32 s14, s14, s15
10340 ; GFX9-NEXT: s_mul_hi_u32 s15, s3, s14
10341 ; GFX9-NEXT: s_mul_i32 s16, s3, s14
10342 ; GFX9-NEXT: s_mul_hi_u32 s3, s3, s17
10343 ; GFX9-NEXT: s_add_u32 s3, s3, s16
10344 ; GFX9-NEXT: s_addc_u32 s15, 0, s15
10345 ; GFX9-NEXT: s_mul_hi_u32 s18, s2, s17
10346 ; GFX9-NEXT: s_mul_i32 s17, s2, s17
10347 ; GFX9-NEXT: s_add_u32 s3, s3, s17
10348 ; GFX9-NEXT: s_mul_hi_u32 s16, s2, s14
10349 ; GFX9-NEXT: s_addc_u32 s3, s15, s18
10350 ; GFX9-NEXT: s_addc_u32 s15, s16, 0
10351 ; GFX9-NEXT: s_mul_i32 s14, s2, s14
10352 ; GFX9-NEXT: s_add_u32 s3, s3, s14
10353 ; GFX9-NEXT: s_addc_u32 s14, 0, s15
10354 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s3, v0
10355 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10356 ; GFX9-NEXT: s_addc_u32 s2, s2, s14
10357 ; GFX9-NEXT: v_readfirstlane_b32 s14, v0
10358 ; GFX9-NEXT: s_mul_i32 s3, s0, s2
10359 ; GFX9-NEXT: s_mul_hi_u32 s15, s0, s14
10360 ; GFX9-NEXT: s_add_i32 s3, s15, s3
10361 ; GFX9-NEXT: s_mul_i32 s1, s1, s14
10362 ; GFX9-NEXT: s_add_i32 s3, s3, s1
10363 ; GFX9-NEXT: s_mul_i32 s0, s0, s14
10364 ; GFX9-NEXT: s_mul_hi_u32 s15, s2, s0
10365 ; GFX9-NEXT: s_mul_i32 s16, s2, s0
10366 ; GFX9-NEXT: s_mul_i32 s18, s14, s3
10367 ; GFX9-NEXT: s_mul_hi_u32 s0, s14, s0
10368 ; GFX9-NEXT: s_mul_hi_u32 s17, s14, s3
10369 ; GFX9-NEXT: s_add_u32 s0, s0, s18
10370 ; GFX9-NEXT: s_addc_u32 s14, 0, s17
10371 ; GFX9-NEXT: s_add_u32 s0, s0, s16
10372 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
10373 ; GFX9-NEXT: s_addc_u32 s0, s14, s15
10374 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
10375 ; GFX9-NEXT: s_mul_i32 s3, s2, s3
10376 ; GFX9-NEXT: s_add_u32 s0, s0, s3
10377 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
10378 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
10379 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10380 ; GFX9-NEXT: s_addc_u32 s2, s2, s1
10381 ; GFX9-NEXT: s_ashr_i32 s14, s5, 31
10382 ; GFX9-NEXT: s_add_u32 s0, s4, s14
10383 ; GFX9-NEXT: s_mov_b32 s15, s14
10384 ; GFX9-NEXT: s_addc_u32 s1, s5, s14
10385 ; GFX9-NEXT: s_xor_b64 s[4:5], s[0:1], s[14:15]
10386 ; GFX9-NEXT: v_readfirstlane_b32 s3, v0
10387 ; GFX9-NEXT: s_mul_i32 s1, s4, s2
10388 ; GFX9-NEXT: s_mul_hi_u32 s15, s4, s3
10389 ; GFX9-NEXT: s_mul_hi_u32 s0, s4, s2
10390 ; GFX9-NEXT: s_add_u32 s1, s15, s1
10391 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
10392 ; GFX9-NEXT: s_mul_hi_u32 s16, s5, s3
10393 ; GFX9-NEXT: s_mul_i32 s3, s5, s3
10394 ; GFX9-NEXT: s_add_u32 s1, s1, s3
10395 ; GFX9-NEXT: s_mul_hi_u32 s15, s5, s2
10396 ; GFX9-NEXT: s_addc_u32 s0, s0, s16
10397 ; GFX9-NEXT: s_addc_u32 s1, s15, 0
10398 ; GFX9-NEXT: s_mul_i32 s2, s5, s2
10399 ; GFX9-NEXT: s_add_u32 s0, s0, s2
10400 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
10401 ; GFX9-NEXT: s_mul_i32 s1, s12, s1
10402 ; GFX9-NEXT: s_mul_hi_u32 s2, s12, s0
10403 ; GFX9-NEXT: s_add_i32 s1, s2, s1
10404 ; GFX9-NEXT: s_mul_i32 s2, s13, s0
10405 ; GFX9-NEXT: s_mul_i32 s0, s12, s0
10406 ; GFX9-NEXT: s_add_i32 s15, s1, s2
10407 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
10408 ; GFX9-NEXT: s_sub_i32 s1, s5, s15
10409 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, s4, v0
10410 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10411 ; GFX9-NEXT: s_subb_u32 s4, s1, s13
10412 ; GFX9-NEXT: v_subrev_co_u32_e64 v1, s[0:1], s12, v0
10413 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10414 ; GFX9-NEXT: s_subb_u32 s16, s4, 0
10415 ; GFX9-NEXT: s_cmp_ge_u32 s16, s13
10416 ; GFX9-NEXT: s_cselect_b32 s17, -1, 0
10417 ; GFX9-NEXT: v_cmp_le_u32_e64 s[2:3], s12, v1
10418 ; GFX9-NEXT: s_cmp_eq_u32 s16, s13
10419 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, -1, s[2:3]
10420 ; GFX9-NEXT: v_mov_b32_e32 v3, s17
10421 ; GFX9-NEXT: s_cselect_b64 s[2:3], -1, 0
10422 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10423 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v3, v2, s[2:3]
10424 ; GFX9-NEXT: s_subb_u32 s2, s4, s13
10425 ; GFX9-NEXT: v_subrev_co_u32_e64 v3, s[0:1], s12, v1
10426 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10427 ; GFX9-NEXT: s_subb_u32 s2, s2, 0
10428 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v2
10429 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, v3, s[0:1]
10430 ; GFX9-NEXT: v_mov_b32_e32 v2, s16
10431 ; GFX9-NEXT: v_mov_b32_e32 v3, s2
10432 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10433 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v2, v3, s[0:1]
10434 ; GFX9-NEXT: s_subb_u32 s0, s5, s15
10435 ; GFX9-NEXT: s_cmp_ge_u32 s0, s13
10436 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
10437 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s12, v0
10438 ; GFX9-NEXT: s_cmp_eq_u32 s0, s13
10439 ; GFX9-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
10440 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
10441 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
10442 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
10443 ; GFX9-NEXT: v_mov_b32_e32 v5, s0
10444 ; GFX9-NEXT: s_ashr_i32 s0, s11, 31
10445 ; GFX9-NEXT: s_add_u32 s2, s10, s0
10446 ; GFX9-NEXT: s_mov_b32 s1, s0
10447 ; GFX9-NEXT: s_addc_u32 s3, s11, s0
10448 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
10449 ; GFX9-NEXT: s_xor_b64 s[4:5], s[2:3], s[0:1]
10450 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
10451 ; GFX9-NEXT: v_cvt_f32_u32_e32 v1, s4
10452 ; GFX9-NEXT: v_cvt_f32_u32_e32 v3, s5
10453 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v5, v2, vcc
10454 ; GFX9-NEXT: v_xor_b32_e32 v0, s14, v0
10455 ; GFX9-NEXT: v_xor_b32_e32 v2, s14, v2
10456 ; GFX9-NEXT: v_mac_f32_e32 v1, 0x4f800000, v3
10457 ; GFX9-NEXT: v_rcp_f32_e32 v3, v1
10458 ; GFX9-NEXT: v_mov_b32_e32 v5, s14
10459 ; GFX9-NEXT: v_subrev_co_u32_e32 v0, vcc, s14, v0
10460 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v2, v5, vcc
10461 ; GFX9-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v3
10462 ; GFX9-NEXT: v_mul_f32_e32 v3, 0x2f800000, v2
10463 ; GFX9-NEXT: v_trunc_f32_e32 v3, v3
10464 ; GFX9-NEXT: v_mac_f32_e32 v2, 0xcf800000, v3
10465 ; GFX9-NEXT: v_cvt_u32_f32_e32 v2, v2
10466 ; GFX9-NEXT: v_cvt_u32_f32_e32 v3, v3
10467 ; GFX9-NEXT: s_sub_u32 s0, 0, s4
10468 ; GFX9-NEXT: s_subb_u32 s1, 0, s5
10469 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
10470 ; GFX9-NEXT: v_readfirstlane_b32 s11, v3
10471 ; GFX9-NEXT: s_mul_hi_u32 s10, s0, s2
10472 ; GFX9-NEXT: s_mul_i32 s12, s0, s11
10473 ; GFX9-NEXT: s_mul_i32 s3, s1, s2
10474 ; GFX9-NEXT: s_add_i32 s10, s10, s12
10475 ; GFX9-NEXT: s_add_i32 s10, s10, s3
10476 ; GFX9-NEXT: s_mul_i32 s13, s0, s2
10477 ; GFX9-NEXT: s_mul_hi_u32 s3, s2, s10
10478 ; GFX9-NEXT: s_mul_i32 s12, s2, s10
10479 ; GFX9-NEXT: s_mul_hi_u32 s2, s2, s13
10480 ; GFX9-NEXT: s_add_u32 s2, s2, s12
10481 ; GFX9-NEXT: s_addc_u32 s3, 0, s3
10482 ; GFX9-NEXT: s_mul_hi_u32 s14, s11, s13
10483 ; GFX9-NEXT: s_mul_i32 s13, s11, s13
10484 ; GFX9-NEXT: s_add_u32 s2, s2, s13
10485 ; GFX9-NEXT: s_mul_hi_u32 s12, s11, s10
10486 ; GFX9-NEXT: s_addc_u32 s2, s3, s14
10487 ; GFX9-NEXT: s_addc_u32 s3, s12, 0
10488 ; GFX9-NEXT: s_mul_i32 s10, s11, s10
10489 ; GFX9-NEXT: s_add_u32 s2, s2, s10
10490 ; GFX9-NEXT: s_addc_u32 s3, 0, s3
10491 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s2, v2
10492 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10493 ; GFX9-NEXT: s_addc_u32 s2, s11, s3
10494 ; GFX9-NEXT: v_readfirstlane_b32 s10, v2
10495 ; GFX9-NEXT: s_mul_i32 s3, s0, s2
10496 ; GFX9-NEXT: s_mul_hi_u32 s11, s0, s10
10497 ; GFX9-NEXT: s_add_i32 s3, s11, s3
10498 ; GFX9-NEXT: s_mul_i32 s1, s1, s10
10499 ; GFX9-NEXT: s_add_i32 s3, s3, s1
10500 ; GFX9-NEXT: s_mul_i32 s0, s0, s10
10501 ; GFX9-NEXT: s_mul_hi_u32 s11, s2, s0
10502 ; GFX9-NEXT: s_mul_i32 s12, s2, s0
10503 ; GFX9-NEXT: s_mul_i32 s14, s10, s3
10504 ; GFX9-NEXT: s_mul_hi_u32 s0, s10, s0
10505 ; GFX9-NEXT: s_mul_hi_u32 s13, s10, s3
10506 ; GFX9-NEXT: s_add_u32 s0, s0, s14
10507 ; GFX9-NEXT: s_addc_u32 s10, 0, s13
10508 ; GFX9-NEXT: s_add_u32 s0, s0, s12
10509 ; GFX9-NEXT: s_mul_hi_u32 s1, s2, s3
10510 ; GFX9-NEXT: s_addc_u32 s0, s10, s11
10511 ; GFX9-NEXT: s_addc_u32 s1, s1, 0
10512 ; GFX9-NEXT: s_mul_i32 s3, s2, s3
10513 ; GFX9-NEXT: s_add_u32 s0, s0, s3
10514 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
10515 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s0, v2
10516 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10517 ; GFX9-NEXT: s_addc_u32 s2, s2, s1
10518 ; GFX9-NEXT: s_ashr_i32 s10, s7, 31
10519 ; GFX9-NEXT: s_add_u32 s0, s6, s10
10520 ; GFX9-NEXT: s_mov_b32 s11, s10
10521 ; GFX9-NEXT: s_addc_u32 s1, s7, s10
10522 ; GFX9-NEXT: s_xor_b64 s[6:7], s[0:1], s[10:11]
10523 ; GFX9-NEXT: v_readfirstlane_b32 s3, v2
10524 ; GFX9-NEXT: s_mul_i32 s1, s6, s2
10525 ; GFX9-NEXT: s_mul_hi_u32 s11, s6, s3
10526 ; GFX9-NEXT: s_mul_hi_u32 s0, s6, s2
10527 ; GFX9-NEXT: s_add_u32 s1, s11, s1
10528 ; GFX9-NEXT: s_addc_u32 s0, 0, s0
10529 ; GFX9-NEXT: s_mul_hi_u32 s12, s7, s3
10530 ; GFX9-NEXT: s_mul_i32 s3, s7, s3
10531 ; GFX9-NEXT: s_add_u32 s1, s1, s3
10532 ; GFX9-NEXT: s_mul_hi_u32 s11, s7, s2
10533 ; GFX9-NEXT: s_addc_u32 s0, s0, s12
10534 ; GFX9-NEXT: s_addc_u32 s1, s11, 0
10535 ; GFX9-NEXT: s_mul_i32 s2, s7, s2
10536 ; GFX9-NEXT: s_add_u32 s0, s0, s2
10537 ; GFX9-NEXT: s_addc_u32 s1, 0, s1
10538 ; GFX9-NEXT: s_mul_i32 s1, s4, s1
10539 ; GFX9-NEXT: s_mul_hi_u32 s2, s4, s0
10540 ; GFX9-NEXT: s_add_i32 s1, s2, s1
10541 ; GFX9-NEXT: s_mul_i32 s2, s5, s0
10542 ; GFX9-NEXT: s_mul_i32 s0, s4, s0
10543 ; GFX9-NEXT: s_add_i32 s11, s1, s2
10544 ; GFX9-NEXT: v_mov_b32_e32 v2, s0
10545 ; GFX9-NEXT: s_sub_i32 s1, s7, s11
10546 ; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, s6, v2
10547 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10548 ; GFX9-NEXT: s_subb_u32 s6, s1, s5
10549 ; GFX9-NEXT: v_subrev_co_u32_e64 v3, s[0:1], s4, v2
10550 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10551 ; GFX9-NEXT: s_subb_u32 s12, s6, 0
10552 ; GFX9-NEXT: s_cmp_ge_u32 s12, s5
10553 ; GFX9-NEXT: s_cselect_b32 s13, -1, 0
10554 ; GFX9-NEXT: v_cmp_le_u32_e64 s[2:3], s4, v3
10555 ; GFX9-NEXT: s_cmp_eq_u32 s12, s5
10556 ; GFX9-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[2:3]
10557 ; GFX9-NEXT: v_mov_b32_e32 v6, s13
10558 ; GFX9-NEXT: s_cselect_b64 s[2:3], -1, 0
10559 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10560 ; GFX9-NEXT: v_cndmask_b32_e64 v5, v6, v5, s[2:3]
10561 ; GFX9-NEXT: s_subb_u32 s2, s6, s5
10562 ; GFX9-NEXT: v_subrev_co_u32_e64 v6, s[0:1], s4, v3
10563 ; GFX9-NEXT: s_cmp_lg_u64 s[0:1], 0
10564 ; GFX9-NEXT: s_subb_u32 s2, s2, 0
10565 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v5
10566 ; GFX9-NEXT: v_cndmask_b32_e64 v3, v3, v6, s[0:1]
10567 ; GFX9-NEXT: v_mov_b32_e32 v5, s12
10568 ; GFX9-NEXT: v_mov_b32_e32 v6, s2
10569 ; GFX9-NEXT: s_cmp_lg_u64 vcc, 0
10570 ; GFX9-NEXT: v_cndmask_b32_e64 v5, v5, v6, s[0:1]
10571 ; GFX9-NEXT: s_subb_u32 s0, s7, s11
10572 ; GFX9-NEXT: s_cmp_ge_u32 s0, s5
10573 ; GFX9-NEXT: s_cselect_b32 s1, -1, 0
10574 ; GFX9-NEXT: v_cmp_le_u32_e32 vcc, s4, v2
10575 ; GFX9-NEXT: s_cmp_eq_u32 s0, s5
10576 ; GFX9-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
10577 ; GFX9-NEXT: v_mov_b32_e32 v7, s1
10578 ; GFX9-NEXT: s_cselect_b64 vcc, -1, 0
10579 ; GFX9-NEXT: v_cndmask_b32_e32 v6, v7, v6, vcc
10580 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v6
10581 ; GFX9-NEXT: v_mov_b32_e32 v7, s0
10582 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v2, v3, vcc
10583 ; GFX9-NEXT: v_cndmask_b32_e32 v5, v7, v5, vcc
10584 ; GFX9-NEXT: v_xor_b32_e32 v2, s10, v2
10585 ; GFX9-NEXT: v_xor_b32_e32 v3, s10, v5
10586 ; GFX9-NEXT: v_mov_b32_e32 v5, s10
10587 ; GFX9-NEXT: v_subrev_co_u32_e32 v2, vcc, s10, v2
10588 ; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v3, v5, vcc
10589 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
10590 ; GFX9-NEXT: global_store_dwordx4 v4, v[0:3], s[8:9]
10591 ; GFX9-NEXT: s_endpgm
10592 %shl.y = shl <2 x i64> <i64 4096, i64 4096>, %y
10593 %r = srem <2 x i64> %x, %shl.y
10594 store <2 x i64> %r, ptr addrspace(1) %out
10598 define <2 x i32> @v_sdiv_i32_exact(<2 x i32> %num) {
10599 ; CHECK-LABEL: @v_sdiv_i32_exact(
10600 ; CHECK: %1 = extractelement <2 x i32> %num, i64 0
10601 ; CHECK-NEXT: %2 = sdiv exact i32 %1, 4096
10602 ; CHECK-NEXT: %3 = insertelement <2 x i32> poison, i32 %2, i64 0
10603 ; CHECK-NEXT: %4 = extractelement <2 x i32> %num, i64 1
10604 ; CHECK-NEXT: %5 = sdiv exact i32 %4, 1024
10605 ; CHECK-NEXT: %6 = insertelement <2 x i32> %3, i32 %5, i64 1
10606 ; CHECK-NEXT: ret <2 x i32> %6
10608 ; GFX6-LABEL: v_sdiv_i32_exact:
10610 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10611 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 12, v0
10612 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 10, v1
10613 ; GFX6-NEXT: s_setpc_b64 s[30:31]
10615 ; GFX9-LABEL: v_sdiv_i32_exact:
10617 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10618 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 12, v0
10619 ; GFX9-NEXT: v_ashrrev_i32_e32 v1, 10, v1
10620 ; GFX9-NEXT: s_setpc_b64 s[30:31]
10621 %result = sdiv exact <2 x i32> %num, <i32 4096, i32 1024>
10622 ret <2 x i32> %result
10625 define <2 x i64> @v_sdiv_i64_exact(<2 x i64> %num) {
10626 ; CHECK-LABEL: @v_sdiv_i64_exact(
10627 ; CHECK: %1 = extractelement <2 x i64> %num, i64 0
10628 ; CHECK-NEXT: %2 = sdiv exact i64 %1, 4096
10629 ; CHECK-NEXT: %3 = insertelement <2 x i64> poison, i64 %2, i64 0
10630 ; CHECK-NEXT: %4 = extractelement <2 x i64> %num, i64 1
10631 ; CHECK-NEXT: %5 = sdiv exact i64 %4, 1024
10632 ; CHECK-NEXT: %6 = insertelement <2 x i64> %3, i64 %5, i64 1
10633 ; CHECK-NEXT: ret <2 x i64> %6
10635 ; GFX6-LABEL: v_sdiv_i64_exact:
10637 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10638 ; GFX6-NEXT: v_ashr_i64 v[0:1], v[0:1], 12
10639 ; GFX6-NEXT: v_ashr_i64 v[2:3], v[2:3], 10
10640 ; GFX6-NEXT: s_setpc_b64 s[30:31]
10642 ; GFX9-LABEL: v_sdiv_i64_exact:
10644 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10645 ; GFX9-NEXT: v_ashrrev_i64 v[0:1], 12, v[0:1]
10646 ; GFX9-NEXT: v_ashrrev_i64 v[2:3], 10, v[2:3]
10647 ; GFX9-NEXT: s_setpc_b64 s[30:31]
10648 %result = sdiv exact <2 x i64> %num, <i64 4096, i64 1024>
10649 ret <2 x i64> %result
10652 define <2 x i32> @v_udiv_i32_exact(<2 x i32> %num) {
10653 ; CHECK-LABEL: @v_udiv_i32_exact(
10654 ; CHECK: %1 = extractelement <2 x i32> %num, i64 0
10655 ; CHECK-NEXT: %2 = udiv exact i32 %1, 4096
10656 ; CHECK-NEXT: %3 = insertelement <2 x i32> poison, i32 %2, i64 0
10657 ; CHECK-NEXT: %4 = extractelement <2 x i32> %num, i64 1
10658 ; CHECK-NEXT: %5 = udiv exact i32 %4, 1024
10659 ; CHECK-NEXT: %6 = insertelement <2 x i32> %3, i32 %5, i64 1
10660 ; CHECK-NEXT: ret <2 x i32> %6
10662 ; GFX6-LABEL: v_udiv_i32_exact:
10664 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10665 ; GFX6-NEXT: v_lshrrev_b32_e32 v0, 12, v0
10666 ; GFX6-NEXT: v_lshrrev_b32_e32 v1, 10, v1
10667 ; GFX6-NEXT: s_setpc_b64 s[30:31]
10669 ; GFX9-LABEL: v_udiv_i32_exact:
10671 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10672 ; GFX9-NEXT: v_lshrrev_b32_e32 v0, 12, v0
10673 ; GFX9-NEXT: v_lshrrev_b32_e32 v1, 10, v1
10674 ; GFX9-NEXT: s_setpc_b64 s[30:31]
10675 %result = udiv exact <2 x i32> %num, <i32 4096, i32 1024>
10676 ret <2 x i32> %result
10679 define <2 x i64> @v_udiv_i64_exact(<2 x i64> %num) {
10680 ; CHECK-LABEL: @v_udiv_i64_exact(
10681 ; CHECK: %1 = extractelement <2 x i64> %num, i64 0
10682 ; CHECK-NEXT: %2 = udiv exact i64 %1, 4096
10683 ; CHECK-NEXT: %3 = insertelement <2 x i64> poison, i64 %2, i64 0
10684 ; CHECK-NEXT: %4 = extractelement <2 x i64> %num, i64 1
10685 ; CHECK-NEXT: %5 = udiv exact i64 %4, 1024
10686 ; CHECK-NEXT: %6 = insertelement <2 x i64> %3, i64 %5, i64 1
10687 ; CHECK-NEXT: ret <2 x i64> %6
10689 ; GFX6-LABEL: v_udiv_i64_exact:
10691 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10692 ; GFX6-NEXT: v_lshr_b64 v[0:1], v[0:1], 12
10693 ; GFX6-NEXT: v_lshr_b64 v[2:3], v[2:3], 10
10694 ; GFX6-NEXT: s_setpc_b64 s[30:31]
10696 ; GFX9-LABEL: v_udiv_i64_exact:
10698 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10699 ; GFX9-NEXT: v_lshrrev_b64 v[0:1], 12, v[0:1]
10700 ; GFX9-NEXT: v_lshrrev_b64 v[2:3], 10, v[2:3]
10701 ; GFX9-NEXT: s_setpc_b64 s[30:31]
10702 %result = udiv exact <2 x i64> %num, <i64 4096, i64 1024>
10703 ret <2 x i64> %result