1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn -mcpu=gfx600 -amdgpu-bypass-slow-div=0 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3 ; RUN: llc -mtriple=amdgcn -mcpu=gfx600 -amdgpu-bypass-slow-div=0 -amdgpu-codegenprepare-expand-div64 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN-IR %s
5 define amdgpu_kernel void @s_test_urem_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
6 ; GCN-LABEL: s_test_urem_i64:
8 ; GCN-NEXT: s_load_dwordx2 s[12:13], s[2:3], 0xd
9 ; GCN-NEXT: s_load_dwordx4 s[8:11], s[2:3], 0x9
10 ; GCN-NEXT: s_mov_b32 s7, 0xf000
11 ; GCN-NEXT: s_mov_b32 s6, -1
12 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
13 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s12
14 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s13
15 ; GCN-NEXT: s_sub_u32 s0, 0, s12
16 ; GCN-NEXT: s_subb_u32 s1, 0, s13
17 ; GCN-NEXT: s_mov_b32 s4, s8
18 ; GCN-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
19 ; GCN-NEXT: v_rcp_f32_e32 v0, v0
20 ; GCN-NEXT: s_mov_b32 s5, s9
21 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
22 ; GCN-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
23 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
24 ; GCN-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
25 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
26 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
27 ; GCN-NEXT: v_mul_lo_u32 v2, s0, v1
28 ; GCN-NEXT: v_mul_hi_u32 v3, s0, v0
29 ; GCN-NEXT: v_mul_lo_u32 v5, s1, v0
30 ; GCN-NEXT: v_mul_lo_u32 v4, s0, v0
31 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
32 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v5
33 ; GCN-NEXT: v_mul_hi_u32 v3, v0, v4
34 ; GCN-NEXT: v_mul_lo_u32 v5, v0, v2
35 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v2
36 ; GCN-NEXT: v_mul_hi_u32 v6, v1, v4
37 ; GCN-NEXT: v_mul_lo_u32 v4, v1, v4
38 ; GCN-NEXT: v_mul_hi_u32 v8, v1, v2
39 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
40 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
41 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
42 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
43 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
44 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
45 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
46 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
47 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
48 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
49 ; GCN-NEXT: v_mul_lo_u32 v2, s0, v1
50 ; GCN-NEXT: v_mul_hi_u32 v3, s0, v0
51 ; GCN-NEXT: v_mul_lo_u32 v4, s1, v0
52 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
53 ; GCN-NEXT: v_mul_lo_u32 v3, s0, v0
54 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
55 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v2
56 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v3
57 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v2
58 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v3
59 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v3
60 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v2
61 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
62 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
63 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
64 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v6, v3
65 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
66 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
67 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
68 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
69 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
70 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
71 ; GCN-NEXT: v_mul_lo_u32 v2, s10, v1
72 ; GCN-NEXT: v_mul_hi_u32 v3, s10, v0
73 ; GCN-NEXT: v_mul_hi_u32 v4, s10, v1
74 ; GCN-NEXT: v_mul_hi_u32 v5, s11, v1
75 ; GCN-NEXT: v_mul_lo_u32 v1, s11, v1
76 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
77 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
78 ; GCN-NEXT: v_mul_lo_u32 v4, s11, v0
79 ; GCN-NEXT: v_mul_hi_u32 v0, s11, v0
80 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
81 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
82 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
83 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
84 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
85 ; GCN-NEXT: v_mul_lo_u32 v1, s12, v1
86 ; GCN-NEXT: v_mul_hi_u32 v2, s12, v0
87 ; GCN-NEXT: v_mul_lo_u32 v3, s13, v0
88 ; GCN-NEXT: v_mul_lo_u32 v0, s12, v0
89 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v2
90 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v3, v1
91 ; GCN-NEXT: v_sub_i32_e32 v2, vcc, s11, v1
92 ; GCN-NEXT: v_mov_b32_e32 v3, s13
93 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, s10, v0
94 ; GCN-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc
95 ; GCN-NEXT: v_subrev_i32_e64 v4, s[0:1], s12, v0
96 ; GCN-NEXT: v_subbrev_u32_e64 v5, s[2:3], 0, v2, s[0:1]
97 ; GCN-NEXT: v_cmp_le_u32_e64 s[2:3], s13, v5
98 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[2:3]
99 ; GCN-NEXT: v_cmp_le_u32_e64 s[2:3], s12, v4
100 ; GCN-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, s[0:1]
101 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[2:3]
102 ; GCN-NEXT: v_cmp_eq_u32_e64 s[2:3], s13, v5
103 ; GCN-NEXT: v_subrev_i32_e64 v3, s[0:1], s12, v4
104 ; GCN-NEXT: v_cndmask_b32_e64 v6, v6, v7, s[2:3]
105 ; GCN-NEXT: v_subbrev_u32_e64 v2, s[0:1], 0, v2, s[0:1]
106 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
107 ; GCN-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[0:1]
108 ; GCN-NEXT: v_mov_b32_e32 v4, s11
109 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v4, v1, vcc
110 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s13, v1
111 ; GCN-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
112 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s12, v0
113 ; GCN-NEXT: v_cndmask_b32_e64 v2, v5, v2, s[0:1]
114 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
115 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s13, v1
116 ; GCN-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
117 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
118 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
119 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
120 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
123 ; GCN-IR-LABEL: s_test_urem_i64:
124 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
125 ; GCN-IR-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0xd
126 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
127 ; GCN-IR-NEXT: s_mov_b64 s[6:7], 0
128 ; GCN-IR-NEXT: s_mov_b32 s11, 0
129 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
130 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[8:9], s[4:5], 0
131 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[12:13], s[2:3], 0
132 ; GCN-IR-NEXT: s_flbit_i32_b64 s10, s[4:5]
133 ; GCN-IR-NEXT: s_flbit_i32_b64 s18, s[2:3]
134 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[8:9], s[12:13]
135 ; GCN-IR-NEXT: s_sub_u32 s12, s10, s18
136 ; GCN-IR-NEXT: s_subb_u32 s13, 0, 0
137 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[14:15], s[12:13], 63
138 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[16:17], s[12:13], 63
139 ; GCN-IR-NEXT: s_or_b64 s[14:15], s[8:9], s[14:15]
140 ; GCN-IR-NEXT: s_and_b64 s[8:9], s[14:15], exec
141 ; GCN-IR-NEXT: s_cselect_b32 s9, 0, s3
142 ; GCN-IR-NEXT: s_cselect_b32 s8, 0, s2
143 ; GCN-IR-NEXT: s_or_b64 s[14:15], s[14:15], s[16:17]
144 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[14:15]
145 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_5
146 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
147 ; GCN-IR-NEXT: s_add_u32 s14, s12, 1
148 ; GCN-IR-NEXT: s_addc_u32 s15, s13, 0
149 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[8:9], s[14:15], 0
150 ; GCN-IR-NEXT: s_sub_i32 s12, 63, s12
151 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[8:9]
152 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[2:3], s12
153 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_4
154 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
155 ; GCN-IR-NEXT: s_lshr_b64 s[12:13], s[2:3], s14
156 ; GCN-IR-NEXT: s_add_u32 s16, s4, -1
157 ; GCN-IR-NEXT: s_addc_u32 s17, s5, -1
158 ; GCN-IR-NEXT: s_not_b64 s[6:7], s[10:11]
159 ; GCN-IR-NEXT: s_add_u32 s10, s6, s18
160 ; GCN-IR-NEXT: s_addc_u32 s11, s7, 0
161 ; GCN-IR-NEXT: s_mov_b64 s[14:15], 0
162 ; GCN-IR-NEXT: s_mov_b32 s7, 0
163 ; GCN-IR-NEXT: .LBB0_3: ; %udiv-do-while
164 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
165 ; GCN-IR-NEXT: s_lshl_b64 s[12:13], s[12:13], 1
166 ; GCN-IR-NEXT: s_lshr_b32 s6, s9, 31
167 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[8:9], 1
168 ; GCN-IR-NEXT: s_or_b64 s[12:13], s[12:13], s[6:7]
169 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[14:15], s[8:9]
170 ; GCN-IR-NEXT: s_sub_u32 s6, s16, s12
171 ; GCN-IR-NEXT: s_subb_u32 s6, s17, s13
172 ; GCN-IR-NEXT: s_ashr_i32 s14, s6, 31
173 ; GCN-IR-NEXT: s_mov_b32 s15, s14
174 ; GCN-IR-NEXT: s_and_b32 s6, s14, 1
175 ; GCN-IR-NEXT: s_and_b64 s[14:15], s[14:15], s[4:5]
176 ; GCN-IR-NEXT: s_sub_u32 s12, s12, s14
177 ; GCN-IR-NEXT: s_subb_u32 s13, s13, s15
178 ; GCN-IR-NEXT: s_add_u32 s10, s10, 1
179 ; GCN-IR-NEXT: s_addc_u32 s11, s11, 0
180 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[18:19], s[10:11], 0
181 ; GCN-IR-NEXT: s_mov_b64 s[14:15], s[6:7]
182 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[18:19]
183 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_3
184 ; GCN-IR-NEXT: .LBB0_4: ; %Flow7
185 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[8:9], 1
186 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[6:7], s[8:9]
187 ; GCN-IR-NEXT: .LBB0_5: ; %udiv-end
188 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s8
189 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s4, v0
190 ; GCN-IR-NEXT: s_mov_b32 s12, s0
191 ; GCN-IR-NEXT: s_mul_i32 s0, s4, s9
192 ; GCN-IR-NEXT: v_mov_b32_e32 v2, s3
193 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, s0, v0
194 ; GCN-IR-NEXT: s_mul_i32 s0, s5, s8
195 ; GCN-IR-NEXT: v_add_i32_e32 v1, vcc, s0, v0
196 ; GCN-IR-NEXT: s_mul_i32 s0, s4, s8
197 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s0
198 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, s2, v0
199 ; GCN-IR-NEXT: s_mov_b32 s15, 0xf000
200 ; GCN-IR-NEXT: s_mov_b32 s14, -1
201 ; GCN-IR-NEXT: s_mov_b32 s13, s1
202 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, v2, v1, vcc
203 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[12:15], 0
204 ; GCN-IR-NEXT: s_endpgm
205 %result = urem i64 %x, %y
206 store i64 %result, ptr addrspace(1) %out
210 define i64 @v_test_urem_i64(i64 %x, i64 %y) {
211 ; GCN-LABEL: v_test_urem_i64:
213 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
214 ; GCN-NEXT: v_cvt_f32_u32_e32 v4, v2
215 ; GCN-NEXT: v_cvt_f32_u32_e32 v5, v3
216 ; GCN-NEXT: v_sub_i32_e32 v6, vcc, 0, v2
217 ; GCN-NEXT: v_subb_u32_e32 v7, vcc, 0, v3, vcc
218 ; GCN-NEXT: v_madmk_f32 v4, v5, 0x4f800000, v4
219 ; GCN-NEXT: v_rcp_f32_e32 v4, v4
220 ; GCN-NEXT: v_mul_f32_e32 v4, 0x5f7ffffc, v4
221 ; GCN-NEXT: v_mul_f32_e32 v5, 0x2f800000, v4
222 ; GCN-NEXT: v_trunc_f32_e32 v5, v5
223 ; GCN-NEXT: v_madmk_f32 v4, v5, 0xcf800000, v4
224 ; GCN-NEXT: v_cvt_u32_f32_e32 v5, v5
225 ; GCN-NEXT: v_cvt_u32_f32_e32 v4, v4
226 ; GCN-NEXT: v_mul_lo_u32 v8, v6, v5
227 ; GCN-NEXT: v_mul_hi_u32 v9, v6, v4
228 ; GCN-NEXT: v_mul_lo_u32 v10, v7, v4
229 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
230 ; GCN-NEXT: v_mul_lo_u32 v9, v6, v4
231 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v8, v10
232 ; GCN-NEXT: v_mul_lo_u32 v10, v4, v8
233 ; GCN-NEXT: v_mul_hi_u32 v11, v4, v9
234 ; GCN-NEXT: v_mul_hi_u32 v12, v4, v8
235 ; GCN-NEXT: v_mul_hi_u32 v13, v5, v8
236 ; GCN-NEXT: v_mul_lo_u32 v8, v5, v8
237 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v11, v10
238 ; GCN-NEXT: v_addc_u32_e32 v11, vcc, 0, v12, vcc
239 ; GCN-NEXT: v_mul_lo_u32 v12, v5, v9
240 ; GCN-NEXT: v_mul_hi_u32 v9, v5, v9
241 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v10, v12
242 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, v11, v9, vcc
243 ; GCN-NEXT: v_addc_u32_e32 v10, vcc, 0, v13, vcc
244 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
245 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
246 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v8
247 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, v5, v9, vcc
248 ; GCN-NEXT: v_mul_lo_u32 v8, v6, v5
249 ; GCN-NEXT: v_mul_hi_u32 v9, v6, v4
250 ; GCN-NEXT: v_mul_lo_u32 v7, v7, v4
251 ; GCN-NEXT: v_mul_lo_u32 v6, v6, v4
252 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
253 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v8, v7
254 ; GCN-NEXT: v_mul_lo_u32 v10, v4, v7
255 ; GCN-NEXT: v_mul_hi_u32 v11, v4, v6
256 ; GCN-NEXT: v_mul_hi_u32 v12, v4, v7
257 ; GCN-NEXT: v_mul_hi_u32 v9, v5, v6
258 ; GCN-NEXT: v_mul_lo_u32 v6, v5, v6
259 ; GCN-NEXT: v_mul_hi_u32 v8, v5, v7
260 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v11, v10
261 ; GCN-NEXT: v_addc_u32_e32 v11, vcc, 0, v12, vcc
262 ; GCN-NEXT: v_mul_lo_u32 v7, v5, v7
263 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v10, v6
264 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, v11, v9, vcc
265 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v8, vcc
266 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v7
267 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
268 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v6
269 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, v5, v7, vcc
270 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v5
271 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v4
272 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v5
273 ; GCN-NEXT: v_mul_hi_u32 v9, v1, v5
274 ; GCN-NEXT: v_mul_lo_u32 v5, v1, v5
275 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
276 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
277 ; GCN-NEXT: v_mul_lo_u32 v8, v1, v4
278 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v4
279 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v8
280 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v7, v4, vcc
281 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, 0, v9, vcc
282 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v5
283 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
284 ; GCN-NEXT: v_mul_lo_u32 v5, v2, v5
285 ; GCN-NEXT: v_mul_hi_u32 v6, v2, v4
286 ; GCN-NEXT: v_mul_lo_u32 v7, v3, v4
287 ; GCN-NEXT: v_mul_lo_u32 v4, v2, v4
288 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v6, v5
289 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v5, v7
290 ; GCN-NEXT: v_sub_i32_e32 v6, vcc, v1, v5
291 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, v0, v4
292 ; GCN-NEXT: v_subb_u32_e64 v4, s[4:5], v6, v3, vcc
293 ; GCN-NEXT: v_sub_i32_e64 v6, s[4:5], v0, v2
294 ; GCN-NEXT: v_subbrev_u32_e64 v7, s[6:7], 0, v4, s[4:5]
295 ; GCN-NEXT: v_cmp_ge_u32_e64 s[6:7], v7, v3
296 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[6:7]
297 ; GCN-NEXT: v_cmp_ge_u32_e64 s[6:7], v6, v2
298 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v1, v5, vcc
299 ; GCN-NEXT: v_cndmask_b32_e64 v9, 0, -1, s[6:7]
300 ; GCN-NEXT: v_cmp_eq_u32_e64 s[6:7], v7, v3
301 ; GCN-NEXT: v_subb_u32_e64 v4, s[4:5], v4, v3, s[4:5]
302 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v1, v3
303 ; GCN-NEXT: v_cndmask_b32_e64 v8, v8, v9, s[6:7]
304 ; GCN-NEXT: v_sub_i32_e64 v9, s[4:5], v6, v2
305 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
306 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v0, v2
307 ; GCN-NEXT: v_subbrev_u32_e64 v4, s[4:5], 0, v4, s[4:5]
308 ; GCN-NEXT: v_cndmask_b32_e64 v2, 0, -1, vcc
309 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, v1, v3
310 ; GCN-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, v8
311 ; GCN-NEXT: v_cndmask_b32_e32 v2, v5, v2, vcc
312 ; GCN-NEXT: v_cndmask_b32_e64 v6, v6, v9, s[4:5]
313 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
314 ; GCN-NEXT: v_cndmask_b32_e64 v2, v7, v4, s[4:5]
315 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
316 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
317 ; GCN-NEXT: s_setpc_b64 s[30:31]
319 ; GCN-IR-LABEL: v_test_urem_i64:
320 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
321 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
322 ; GCN-IR-NEXT: v_ffbh_u32_e32 v4, v2
323 ; GCN-IR-NEXT: v_add_i32_e64 v4, s[6:7], 32, v4
324 ; GCN-IR-NEXT: v_ffbh_u32_e32 v5, v3
325 ; GCN-IR-NEXT: v_min_u32_e32 v12, v4, v5
326 ; GCN-IR-NEXT: v_ffbh_u32_e32 v4, v0
327 ; GCN-IR-NEXT: v_add_i32_e64 v4, s[6:7], 32, v4
328 ; GCN-IR-NEXT: v_ffbh_u32_e32 v5, v1
329 ; GCN-IR-NEXT: v_min_u32_e32 v13, v4, v5
330 ; GCN-IR-NEXT: v_sub_i32_e64 v4, s[6:7], v12, v13
331 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3]
332 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], 0, v[0:1]
333 ; GCN-IR-NEXT: v_subb_u32_e64 v5, s[6:7], 0, 0, s[6:7]
334 ; GCN-IR-NEXT: v_cmp_lt_u64_e64 s[6:7], 63, v[4:5]
335 ; GCN-IR-NEXT: s_or_b64 s[4:5], vcc, s[4:5]
336 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[6:7]
337 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 63, v[4:5]
338 ; GCN-IR-NEXT: s_xor_b64 s[6:7], s[4:5], -1
339 ; GCN-IR-NEXT: v_cndmask_b32_e64 v7, v1, 0, s[4:5]
340 ; GCN-IR-NEXT: v_cndmask_b32_e64 v6, v0, 0, s[4:5]
341 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[6:7], vcc
342 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
343 ; GCN-IR-NEXT: s_cbranch_execz .LBB1_6
344 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
345 ; GCN-IR-NEXT: v_add_i32_e32 v8, vcc, 1, v4
346 ; GCN-IR-NEXT: v_addc_u32_e32 v9, vcc, 0, v5, vcc
347 ; GCN-IR-NEXT: v_sub_i32_e64 v4, s[4:5], 63, v4
348 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[8:9]
349 ; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[0:1], v4
350 ; GCN-IR-NEXT: v_mov_b32_e32 v6, 0
351 ; GCN-IR-NEXT: v_mov_b32_e32 v7, 0
352 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc
353 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[4:5]
354 ; GCN-IR-NEXT: s_cbranch_execz .LBB1_5
355 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
356 ; GCN-IR-NEXT: v_add_i32_e32 v14, vcc, -1, v2
357 ; GCN-IR-NEXT: v_addc_u32_e32 v15, vcc, -1, v3, vcc
358 ; GCN-IR-NEXT: v_not_b32_e32 v7, v12
359 ; GCN-IR-NEXT: v_lshr_b64 v[10:11], v[0:1], v8
360 ; GCN-IR-NEXT: v_not_b32_e32 v6, 0
361 ; GCN-IR-NEXT: v_add_i32_e32 v8, vcc, v7, v13
362 ; GCN-IR-NEXT: v_mov_b32_e32 v12, 0
363 ; GCN-IR-NEXT: v_addc_u32_e32 v9, vcc, 0, v6, vcc
364 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
365 ; GCN-IR-NEXT: v_mov_b32_e32 v13, 0
366 ; GCN-IR-NEXT: v_mov_b32_e32 v7, 0
367 ; GCN-IR-NEXT: .LBB1_3: ; %udiv-do-while
368 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
369 ; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[10:11], 1
370 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v5
371 ; GCN-IR-NEXT: v_or_b32_e32 v10, v10, v6
372 ; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[4:5], 1
373 ; GCN-IR-NEXT: v_sub_i32_e32 v6, vcc, v14, v10
374 ; GCN-IR-NEXT: v_subb_u32_e32 v6, vcc, v15, v11, vcc
375 ; GCN-IR-NEXT: v_or_b32_e32 v4, v12, v4
376 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v12, 31, v6
377 ; GCN-IR-NEXT: v_add_i32_e32 v8, vcc, 1, v8
378 ; GCN-IR-NEXT: v_or_b32_e32 v5, v13, v5
379 ; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v12
380 ; GCN-IR-NEXT: v_and_b32_e32 v13, v12, v3
381 ; GCN-IR-NEXT: v_and_b32_e32 v12, v12, v2
382 ; GCN-IR-NEXT: v_addc_u32_e32 v9, vcc, 0, v9, vcc
383 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[8:9]
384 ; GCN-IR-NEXT: v_sub_i32_e64 v10, s[4:5], v10, v12
385 ; GCN-IR-NEXT: v_subb_u32_e64 v11, s[4:5], v11, v13, s[4:5]
386 ; GCN-IR-NEXT: v_mov_b32_e32 v13, v7
387 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
388 ; GCN-IR-NEXT: v_mov_b32_e32 v12, v6
389 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
390 ; GCN-IR-NEXT: s_cbranch_execnz .LBB1_3
391 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
392 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
393 ; GCN-IR-NEXT: .LBB1_5: ; %Flow4
394 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
395 ; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[4:5], 1
396 ; GCN-IR-NEXT: v_or_b32_e32 v7, v7, v5
397 ; GCN-IR-NEXT: v_or_b32_e32 v6, v6, v4
398 ; GCN-IR-NEXT: .LBB1_6: ; %Flow5
399 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
400 ; GCN-IR-NEXT: v_mul_lo_u32 v4, v2, v7
401 ; GCN-IR-NEXT: v_mul_hi_u32 v5, v2, v6
402 ; GCN-IR-NEXT: v_mul_lo_u32 v3, v3, v6
403 ; GCN-IR-NEXT: v_mul_lo_u32 v2, v2, v6
404 ; GCN-IR-NEXT: v_add_i32_e32 v4, vcc, v5, v4
405 ; GCN-IR-NEXT: v_add_i32_e32 v3, vcc, v4, v3
406 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
407 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, v1, v3, vcc
408 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
409 %result = urem i64 %x, %y
413 define amdgpu_kernel void @s_test_urem31_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
414 ; GCN-LABEL: s_test_urem31_i64:
416 ; GCN-NEXT: s_load_dword s0, s[2:3], 0xe
417 ; GCN-NEXT: s_mov_b32 s7, 0xf000
418 ; GCN-NEXT: s_mov_b32 s6, -1
419 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
420 ; GCN-NEXT: s_lshr_b32 s8, s0, 1
421 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s8
422 ; GCN-NEXT: s_sub_i32 s0, 0, s8
423 ; GCN-NEXT: v_rcp_iflag_f32_e32 v0, v0
424 ; GCN-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
425 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
426 ; GCN-NEXT: v_mul_lo_u32 v1, s0, v0
427 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
428 ; GCN-NEXT: v_mul_hi_u32 v1, v0, v1
429 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
430 ; GCN-NEXT: s_lshr_b32 s2, s3, 1
431 ; GCN-NEXT: s_mov_b32 s4, s0
432 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
433 ; GCN-NEXT: v_mul_hi_u32 v0, s2, v0
434 ; GCN-NEXT: s_mov_b32 s5, s1
435 ; GCN-NEXT: v_mov_b32_e32 v1, 0
436 ; GCN-NEXT: v_readfirstlane_b32 s0, v0
437 ; GCN-NEXT: s_mul_i32 s0, s0, s8
438 ; GCN-NEXT: s_sub_i32 s0, s2, s0
439 ; GCN-NEXT: s_sub_i32 s1, s0, s8
440 ; GCN-NEXT: s_cmp_ge_u32 s0, s8
441 ; GCN-NEXT: s_cselect_b32 s0, s1, s0
442 ; GCN-NEXT: s_sub_i32 s1, s0, s8
443 ; GCN-NEXT: s_cmp_ge_u32 s0, s8
444 ; GCN-NEXT: s_cselect_b32 s0, s1, s0
445 ; GCN-NEXT: v_mov_b32_e32 v0, s0
446 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
449 ; GCN-IR-LABEL: s_test_urem31_i64:
451 ; GCN-IR-NEXT: s_load_dword s0, s[2:3], 0xe
452 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
453 ; GCN-IR-NEXT: s_mov_b32 s6, -1
454 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
455 ; GCN-IR-NEXT: s_lshr_b32 s8, s0, 1
456 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s8
457 ; GCN-IR-NEXT: s_sub_i32 s0, 0, s8
458 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v0, v0
459 ; GCN-IR-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
460 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v0, v0
461 ; GCN-IR-NEXT: v_mul_lo_u32 v1, s0, v0
462 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
463 ; GCN-IR-NEXT: v_mul_hi_u32 v1, v0, v1
464 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
465 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 1
466 ; GCN-IR-NEXT: s_mov_b32 s4, s0
467 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v0, v1
468 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s2, v0
469 ; GCN-IR-NEXT: s_mov_b32 s5, s1
470 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
471 ; GCN-IR-NEXT: v_readfirstlane_b32 s0, v0
472 ; GCN-IR-NEXT: s_mul_i32 s0, s0, s8
473 ; GCN-IR-NEXT: s_sub_i32 s0, s2, s0
474 ; GCN-IR-NEXT: s_sub_i32 s1, s0, s8
475 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s8
476 ; GCN-IR-NEXT: s_cselect_b32 s0, s1, s0
477 ; GCN-IR-NEXT: s_sub_i32 s1, s0, s8
478 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s8
479 ; GCN-IR-NEXT: s_cselect_b32 s0, s1, s0
480 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s0
481 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
482 ; GCN-IR-NEXT: s_endpgm
485 %result = urem i64 %1, %2
486 store i64 %result, ptr addrspace(1) %out
490 define amdgpu_kernel void @s_test_urem31_v2i64(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
491 ; GCN-LABEL: s_test_urem31_v2i64:
493 ; GCN-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
494 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
495 ; GCN-NEXT: s_mov_b32 s6, -1
496 ; GCN-NEXT: s_lshr_b32 s0, s9, 1
497 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s0
498 ; GCN-NEXT: s_sub_i32 s1, 0, s0
499 ; GCN-NEXT: s_lshr_b32 s4, s5, 1
500 ; GCN-NEXT: s_lshr_b32 s8, s7, 1
501 ; GCN-NEXT: v_rcp_iflag_f32_e32 v0, v0
502 ; GCN-NEXT: s_mov_b32 s7, 0xf000
503 ; GCN-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
504 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
505 ; GCN-NEXT: v_mul_lo_u32 v1, s1, v0
506 ; GCN-NEXT: s_lshr_b32 s1, s11, 1
507 ; GCN-NEXT: v_cvt_f32_u32_e32 v2, s1
508 ; GCN-NEXT: v_mul_hi_u32 v1, v0, v1
509 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v2
510 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
511 ; GCN-NEXT: v_mul_hi_u32 v0, s4, v0
512 ; GCN-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
513 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
514 ; GCN-NEXT: v_readfirstlane_b32 s5, v0
515 ; GCN-NEXT: s_mul_i32 s5, s5, s0
516 ; GCN-NEXT: s_sub_i32 s4, s4, s5
517 ; GCN-NEXT: s_sub_i32 s5, s4, s0
518 ; GCN-NEXT: s_cmp_ge_u32 s4, s0
519 ; GCN-NEXT: s_cselect_b32 s4, s5, s4
520 ; GCN-NEXT: s_sub_i32 s5, s4, s0
521 ; GCN-NEXT: s_cmp_ge_u32 s4, s0
522 ; GCN-NEXT: s_cselect_b32 s0, s5, s4
523 ; GCN-NEXT: s_sub_i32 s4, 0, s1
524 ; GCN-NEXT: v_mul_lo_u32 v0, s4, v1
525 ; GCN-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0x9
526 ; GCN-NEXT: v_mul_hi_u32 v0, v1, v0
527 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0
528 ; GCN-NEXT: v_mul_hi_u32 v2, s8, v0
529 ; GCN-NEXT: v_mov_b32_e32 v0, s0
530 ; GCN-NEXT: v_mov_b32_e32 v1, 0
531 ; GCN-NEXT: v_mov_b32_e32 v3, v1
532 ; GCN-NEXT: v_readfirstlane_b32 s0, v2
533 ; GCN-NEXT: s_mul_i32 s0, s0, s1
534 ; GCN-NEXT: s_sub_i32 s0, s8, s0
535 ; GCN-NEXT: s_sub_i32 s2, s0, s1
536 ; GCN-NEXT: s_cmp_ge_u32 s0, s1
537 ; GCN-NEXT: s_cselect_b32 s0, s2, s0
538 ; GCN-NEXT: s_sub_i32 s2, s0, s1
539 ; GCN-NEXT: s_cmp_ge_u32 s0, s1
540 ; GCN-NEXT: s_cselect_b32 s0, s2, s0
541 ; GCN-NEXT: v_mov_b32_e32 v2, s0
542 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
543 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
546 ; GCN-IR-LABEL: s_test_urem31_v2i64:
548 ; GCN-IR-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
549 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
550 ; GCN-IR-NEXT: s_mov_b32 s6, -1
551 ; GCN-IR-NEXT: s_lshr_b32 s0, s9, 1
552 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s0
553 ; GCN-IR-NEXT: s_sub_i32 s1, 0, s0
554 ; GCN-IR-NEXT: s_lshr_b32 s4, s5, 1
555 ; GCN-IR-NEXT: s_lshr_b32 s8, s7, 1
556 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v0, v0
557 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
558 ; GCN-IR-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
559 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v0, v0
560 ; GCN-IR-NEXT: v_mul_lo_u32 v1, s1, v0
561 ; GCN-IR-NEXT: s_lshr_b32 s1, s11, 1
562 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v2, s1
563 ; GCN-IR-NEXT: v_mul_hi_u32 v1, v0, v1
564 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v2
565 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v0, v1
566 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s4, v0
567 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
568 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v1, v1
569 ; GCN-IR-NEXT: v_readfirstlane_b32 s5, v0
570 ; GCN-IR-NEXT: s_mul_i32 s5, s5, s0
571 ; GCN-IR-NEXT: s_sub_i32 s4, s4, s5
572 ; GCN-IR-NEXT: s_sub_i32 s5, s4, s0
573 ; GCN-IR-NEXT: s_cmp_ge_u32 s4, s0
574 ; GCN-IR-NEXT: s_cselect_b32 s4, s5, s4
575 ; GCN-IR-NEXT: s_sub_i32 s5, s4, s0
576 ; GCN-IR-NEXT: s_cmp_ge_u32 s4, s0
577 ; GCN-IR-NEXT: s_cselect_b32 s0, s5, s4
578 ; GCN-IR-NEXT: s_sub_i32 s4, 0, s1
579 ; GCN-IR-NEXT: v_mul_lo_u32 v0, s4, v1
580 ; GCN-IR-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0x9
581 ; GCN-IR-NEXT: v_mul_hi_u32 v0, v1, v0
582 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v1, v0
583 ; GCN-IR-NEXT: v_mul_hi_u32 v2, s8, v0
584 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s0
585 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
586 ; GCN-IR-NEXT: v_mov_b32_e32 v3, v1
587 ; GCN-IR-NEXT: v_readfirstlane_b32 s0, v2
588 ; GCN-IR-NEXT: s_mul_i32 s0, s0, s1
589 ; GCN-IR-NEXT: s_sub_i32 s0, s8, s0
590 ; GCN-IR-NEXT: s_sub_i32 s2, s0, s1
591 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s1
592 ; GCN-IR-NEXT: s_cselect_b32 s0, s2, s0
593 ; GCN-IR-NEXT: s_sub_i32 s2, s0, s1
594 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s1
595 ; GCN-IR-NEXT: s_cselect_b32 s0, s2, s0
596 ; GCN-IR-NEXT: v_mov_b32_e32 v2, s0
597 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
598 ; GCN-IR-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
599 ; GCN-IR-NEXT: s_endpgm
600 %1 = lshr <2 x i64> %x, <i64 33, i64 33>
601 %2 = lshr <2 x i64> %y, <i64 33, i64 33>
602 %result = urem <2 x i64> %1, %2
603 store <2 x i64> %result, ptr addrspace(1) %out
607 define amdgpu_kernel void @s_test_urem24_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
608 ; GCN-LABEL: s_test_urem24_i64:
610 ; GCN-NEXT: s_load_dword s4, s[2:3], 0xe
611 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
612 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
613 ; GCN-NEXT: s_mov_b32 s2, -1
614 ; GCN-NEXT: s_lshr_b32 s4, s4, 8
615 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s4
616 ; GCN-NEXT: s_lshr_b32 s5, s3, 8
617 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s5
618 ; GCN-NEXT: s_mov_b32 s3, 0xf000
619 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
620 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
621 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
622 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
623 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
624 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
625 ; GCN-NEXT: v_mov_b32_e32 v1, 0
626 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
627 ; GCN-NEXT: v_mul_lo_u32 v0, v0, s4
628 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, s5, v0
629 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
630 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
633 ; GCN-IR-LABEL: s_test_urem24_i64:
635 ; GCN-IR-NEXT: s_load_dword s4, s[2:3], 0xe
636 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
637 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
638 ; GCN-IR-NEXT: s_mov_b32 s2, -1
639 ; GCN-IR-NEXT: s_lshr_b32 s4, s4, 8
640 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s4
641 ; GCN-IR-NEXT: s_lshr_b32 s5, s3, 8
642 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, s5
643 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
644 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
645 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
646 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
647 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
648 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
649 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
650 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
651 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
652 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v0, s4
653 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, s5, v0
654 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
655 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
656 ; GCN-IR-NEXT: s_endpgm
659 %result = urem i64 %1, %2
660 store i64 %result, ptr addrspace(1) %out
664 define amdgpu_kernel void @s_test_urem23_64_v2i64(ptr addrspace(1) %out, <2 x i64> %x, <2 x i64> %y) {
665 ; GCN-LABEL: s_test_urem23_64_v2i64:
667 ; GCN-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
668 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
669 ; GCN-NEXT: s_mov_b32 s6, -1
670 ; GCN-NEXT: s_lshr_b32 s0, s9, 1
671 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s0
672 ; GCN-NEXT: s_sub_i32 s1, 0, s0
673 ; GCN-NEXT: s_lshr_b32 s4, s5, 1
674 ; GCN-NEXT: s_lshr_b32 s8, s7, 9
675 ; GCN-NEXT: v_rcp_iflag_f32_e32 v0, v0
676 ; GCN-NEXT: s_mov_b32 s7, 0xf000
677 ; GCN-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
678 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
679 ; GCN-NEXT: v_mul_lo_u32 v1, s1, v0
680 ; GCN-NEXT: s_lshr_b32 s1, s11, 9
681 ; GCN-NEXT: v_cvt_f32_u32_e32 v2, s1
682 ; GCN-NEXT: v_mul_hi_u32 v1, v0, v1
683 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v2
684 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
685 ; GCN-NEXT: v_mul_hi_u32 v0, s4, v0
686 ; GCN-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
687 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
688 ; GCN-NEXT: v_readfirstlane_b32 s5, v0
689 ; GCN-NEXT: s_mul_i32 s5, s5, s0
690 ; GCN-NEXT: s_sub_i32 s4, s4, s5
691 ; GCN-NEXT: s_sub_i32 s5, s4, s0
692 ; GCN-NEXT: s_cmp_ge_u32 s4, s0
693 ; GCN-NEXT: s_cselect_b32 s4, s5, s4
694 ; GCN-NEXT: s_sub_i32 s5, s4, s0
695 ; GCN-NEXT: s_cmp_ge_u32 s4, s0
696 ; GCN-NEXT: s_cselect_b32 s0, s5, s4
697 ; GCN-NEXT: s_sub_i32 s4, 0, s1
698 ; GCN-NEXT: v_mul_lo_u32 v0, s4, v1
699 ; GCN-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0x9
700 ; GCN-NEXT: v_mul_hi_u32 v0, v1, v0
701 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0
702 ; GCN-NEXT: v_mul_hi_u32 v2, s8, v0
703 ; GCN-NEXT: v_mov_b32_e32 v0, s0
704 ; GCN-NEXT: v_mov_b32_e32 v1, 0
705 ; GCN-NEXT: v_mov_b32_e32 v3, v1
706 ; GCN-NEXT: v_readfirstlane_b32 s0, v2
707 ; GCN-NEXT: s_mul_i32 s0, s0, s1
708 ; GCN-NEXT: s_sub_i32 s0, s8, s0
709 ; GCN-NEXT: s_sub_i32 s2, s0, s1
710 ; GCN-NEXT: s_cmp_ge_u32 s0, s1
711 ; GCN-NEXT: s_cselect_b32 s0, s2, s0
712 ; GCN-NEXT: s_sub_i32 s2, s0, s1
713 ; GCN-NEXT: s_cmp_ge_u32 s0, s1
714 ; GCN-NEXT: s_cselect_b32 s0, s2, s0
715 ; GCN-NEXT: v_mov_b32_e32 v2, s0
716 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
717 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
720 ; GCN-IR-LABEL: s_test_urem23_64_v2i64:
722 ; GCN-IR-NEXT: s_load_dwordx8 s[4:11], s[2:3], 0xd
723 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
724 ; GCN-IR-NEXT: s_mov_b32 s6, -1
725 ; GCN-IR-NEXT: s_lshr_b32 s0, s9, 1
726 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s0
727 ; GCN-IR-NEXT: s_sub_i32 s1, 0, s0
728 ; GCN-IR-NEXT: s_lshr_b32 s4, s5, 1
729 ; GCN-IR-NEXT: s_lshr_b32 s8, s7, 9
730 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v0, v0
731 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
732 ; GCN-IR-NEXT: v_mul_f32_e32 v0, 0x4f7ffffe, v0
733 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v0, v0
734 ; GCN-IR-NEXT: v_mul_lo_u32 v1, s1, v0
735 ; GCN-IR-NEXT: s_lshr_b32 s1, s11, 9
736 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v2, s1
737 ; GCN-IR-NEXT: v_mul_hi_u32 v1, v0, v1
738 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v2
739 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v0, v1
740 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s4, v0
741 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x4f7ffffe, v2
742 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v1, v1
743 ; GCN-IR-NEXT: v_readfirstlane_b32 s5, v0
744 ; GCN-IR-NEXT: s_mul_i32 s5, s5, s0
745 ; GCN-IR-NEXT: s_sub_i32 s4, s4, s5
746 ; GCN-IR-NEXT: s_sub_i32 s5, s4, s0
747 ; GCN-IR-NEXT: s_cmp_ge_u32 s4, s0
748 ; GCN-IR-NEXT: s_cselect_b32 s4, s5, s4
749 ; GCN-IR-NEXT: s_sub_i32 s5, s4, s0
750 ; GCN-IR-NEXT: s_cmp_ge_u32 s4, s0
751 ; GCN-IR-NEXT: s_cselect_b32 s0, s5, s4
752 ; GCN-IR-NEXT: s_sub_i32 s4, 0, s1
753 ; GCN-IR-NEXT: v_mul_lo_u32 v0, s4, v1
754 ; GCN-IR-NEXT: s_load_dwordx2 s[4:5], s[2:3], 0x9
755 ; GCN-IR-NEXT: v_mul_hi_u32 v0, v1, v0
756 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v1, v0
757 ; GCN-IR-NEXT: v_mul_hi_u32 v2, s8, v0
758 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s0
759 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
760 ; GCN-IR-NEXT: v_mov_b32_e32 v3, v1
761 ; GCN-IR-NEXT: v_readfirstlane_b32 s0, v2
762 ; GCN-IR-NEXT: s_mul_i32 s0, s0, s1
763 ; GCN-IR-NEXT: s_sub_i32 s0, s8, s0
764 ; GCN-IR-NEXT: s_sub_i32 s2, s0, s1
765 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s1
766 ; GCN-IR-NEXT: s_cselect_b32 s0, s2, s0
767 ; GCN-IR-NEXT: s_sub_i32 s2, s0, s1
768 ; GCN-IR-NEXT: s_cmp_ge_u32 s0, s1
769 ; GCN-IR-NEXT: s_cselect_b32 s0, s2, s0
770 ; GCN-IR-NEXT: v_mov_b32_e32 v2, s0
771 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
772 ; GCN-IR-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
773 ; GCN-IR-NEXT: s_endpgm
774 %1 = lshr <2 x i64> %x, <i64 33, i64 41>
775 %2 = lshr <2 x i64> %y, <i64 33, i64 41>
776 %result = urem <2 x i64> %1, %2
777 store <2 x i64> %result, ptr addrspace(1) %out
781 define amdgpu_kernel void @s_test_urem_k_num_i64(ptr addrspace(1) %out, i64 %x) {
782 ; GCN-LABEL: s_test_urem_k_num_i64:
784 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
785 ; GCN-NEXT: s_mov_b32 s11, 0xf000
786 ; GCN-NEXT: s_mov_b32 s10, -1
787 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
788 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s6
789 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s7
790 ; GCN-NEXT: s_sub_u32 s0, 0, s6
791 ; GCN-NEXT: s_subb_u32 s1, 0, s7
792 ; GCN-NEXT: s_mov_b32 s8, s4
793 ; GCN-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
794 ; GCN-NEXT: v_rcp_f32_e32 v0, v0
795 ; GCN-NEXT: s_mov_b32 s9, s5
796 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
797 ; GCN-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
798 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
799 ; GCN-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
800 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
801 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
802 ; GCN-NEXT: v_mul_lo_u32 v2, s0, v1
803 ; GCN-NEXT: v_mul_hi_u32 v3, s0, v0
804 ; GCN-NEXT: v_mul_lo_u32 v5, s1, v0
805 ; GCN-NEXT: v_mul_lo_u32 v4, s0, v0
806 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
807 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v5
808 ; GCN-NEXT: v_mul_hi_u32 v3, v0, v4
809 ; GCN-NEXT: v_mul_lo_u32 v5, v0, v2
810 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v2
811 ; GCN-NEXT: v_mul_hi_u32 v6, v1, v4
812 ; GCN-NEXT: v_mul_lo_u32 v4, v1, v4
813 ; GCN-NEXT: v_mul_hi_u32 v8, v1, v2
814 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
815 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
816 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
817 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
818 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
819 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
820 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
821 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
822 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
823 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
824 ; GCN-NEXT: v_mul_lo_u32 v2, s0, v1
825 ; GCN-NEXT: v_mul_hi_u32 v3, s0, v0
826 ; GCN-NEXT: v_mul_lo_u32 v4, s1, v0
827 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
828 ; GCN-NEXT: v_mul_lo_u32 v3, s0, v0
829 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
830 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v2
831 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v3
832 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v2
833 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v3
834 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v3
835 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v2
836 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
837 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
838 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
839 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v6, v3
840 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
841 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
842 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
843 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
844 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
845 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
846 ; GCN-NEXT: v_mul_lo_u32 v2, v1, 24
847 ; GCN-NEXT: v_mul_hi_u32 v0, v0, 24
848 ; GCN-NEXT: v_mul_hi_u32 v1, v1, 24
849 ; GCN-NEXT: v_mov_b32_e32 v3, s7
850 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
851 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v1, vcc
852 ; GCN-NEXT: v_mul_lo_u32 v1, s7, v0
853 ; GCN-NEXT: v_mul_hi_u32 v2, s6, v0
854 ; GCN-NEXT: v_mul_lo_u32 v0, s6, v0
855 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v2
856 ; GCN-NEXT: v_sub_i32_e32 v2, vcc, 0, v1
857 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, 24, v0
858 ; GCN-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc
859 ; GCN-NEXT: v_subrev_i32_e64 v4, s[0:1], s6, v0
860 ; GCN-NEXT: v_subbrev_u32_e64 v5, s[2:3], 0, v2, s[0:1]
861 ; GCN-NEXT: v_cmp_le_u32_e64 s[2:3], s7, v5
862 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[2:3]
863 ; GCN-NEXT: v_cmp_le_u32_e64 s[2:3], s6, v4
864 ; GCN-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, s[0:1]
865 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[2:3]
866 ; GCN-NEXT: v_cmp_eq_u32_e64 s[2:3], s7, v5
867 ; GCN-NEXT: v_subrev_i32_e64 v3, s[0:1], s6, v4
868 ; GCN-NEXT: v_cndmask_b32_e64 v6, v6, v7, s[2:3]
869 ; GCN-NEXT: v_subbrev_u32_e64 v2, s[0:1], 0, v2, s[0:1]
870 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, 0, v1, vcc
871 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6
872 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s7, v1
873 ; GCN-NEXT: v_cndmask_b32_e64 v3, v4, v3, s[0:1]
874 ; GCN-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
875 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s6, v0
876 ; GCN-NEXT: v_cndmask_b32_e64 v2, v5, v2, s[0:1]
877 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
878 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s7, v1
879 ; GCN-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
880 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
881 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc
882 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
883 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[8:11], 0
886 ; GCN-IR-LABEL: s_test_urem_k_num_i64:
887 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
888 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
889 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0
890 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
891 ; GCN-IR-NEXT: s_flbit_i32_b64 s12, s[2:3]
892 ; GCN-IR-NEXT: s_add_u32 s8, s12, 0xffffffc5
893 ; GCN-IR-NEXT: s_addc_u32 s9, 0, -1
894 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[2:3], 0
895 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[10:11], s[8:9], 63
896 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[14:15], s[8:9], 63
897 ; GCN-IR-NEXT: s_or_b64 s[10:11], s[6:7], s[10:11]
898 ; GCN-IR-NEXT: s_and_b64 s[6:7], s[10:11], exec
899 ; GCN-IR-NEXT: s_cselect_b32 s6, 0, 24
900 ; GCN-IR-NEXT: s_or_b64 s[10:11], s[10:11], s[14:15]
901 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[10:11]
902 ; GCN-IR-NEXT: s_mov_b32 s7, 0
903 ; GCN-IR-NEXT: s_cbranch_vccz .LBB6_5
904 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
905 ; GCN-IR-NEXT: s_add_u32 s10, s8, 1
906 ; GCN-IR-NEXT: s_addc_u32 s11, s9, 0
907 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[10:11], 0
908 ; GCN-IR-NEXT: s_sub_i32 s8, 63, s8
909 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[6:7]
910 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], 24, s8
911 ; GCN-IR-NEXT: s_cbranch_vccz .LBB6_4
912 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
913 ; GCN-IR-NEXT: s_lshr_b64 s[10:11], 24, s10
914 ; GCN-IR-NEXT: s_add_u32 s14, s2, -1
915 ; GCN-IR-NEXT: s_addc_u32 s15, s3, -1
916 ; GCN-IR-NEXT: s_sub_u32 s8, 58, s12
917 ; GCN-IR-NEXT: s_subb_u32 s9, 0, 0
918 ; GCN-IR-NEXT: s_mov_b64 s[12:13], 0
919 ; GCN-IR-NEXT: s_mov_b32 s5, 0
920 ; GCN-IR-NEXT: .LBB6_3: ; %udiv-do-while
921 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
922 ; GCN-IR-NEXT: s_lshl_b64 s[10:11], s[10:11], 1
923 ; GCN-IR-NEXT: s_lshr_b32 s4, s7, 31
924 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
925 ; GCN-IR-NEXT: s_or_b64 s[10:11], s[10:11], s[4:5]
926 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[12:13], s[6:7]
927 ; GCN-IR-NEXT: s_sub_u32 s4, s14, s10
928 ; GCN-IR-NEXT: s_subb_u32 s4, s15, s11
929 ; GCN-IR-NEXT: s_ashr_i32 s12, s4, 31
930 ; GCN-IR-NEXT: s_mov_b32 s13, s12
931 ; GCN-IR-NEXT: s_and_b32 s4, s12, 1
932 ; GCN-IR-NEXT: s_and_b64 s[12:13], s[12:13], s[2:3]
933 ; GCN-IR-NEXT: s_sub_u32 s10, s10, s12
934 ; GCN-IR-NEXT: s_subb_u32 s11, s11, s13
935 ; GCN-IR-NEXT: s_add_u32 s8, s8, 1
936 ; GCN-IR-NEXT: s_addc_u32 s9, s9, 0
937 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[16:17], s[8:9], 0
938 ; GCN-IR-NEXT: s_mov_b64 s[12:13], s[4:5]
939 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[16:17]
940 ; GCN-IR-NEXT: s_cbranch_vccz .LBB6_3
941 ; GCN-IR-NEXT: .LBB6_4: ; %Flow6
942 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
943 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[6:7]
944 ; GCN-IR-NEXT: .LBB6_5: ; %udiv-end
945 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s6
946 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s2, v0
947 ; GCN-IR-NEXT: s_mov_b32 s8, s0
948 ; GCN-IR-NEXT: s_mul_i32 s0, s2, s7
949 ; GCN-IR-NEXT: s_mov_b32 s11, 0xf000
950 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, s0, v0
951 ; GCN-IR-NEXT: s_mul_i32 s0, s3, s6
952 ; GCN-IR-NEXT: v_add_i32_e32 v1, vcc, s0, v0
953 ; GCN-IR-NEXT: s_mul_i32 s0, s2, s6
954 ; GCN-IR-NEXT: v_sub_i32_e64 v0, vcc, 24, s0
955 ; GCN-IR-NEXT: s_mov_b32 s10, -1
956 ; GCN-IR-NEXT: s_mov_b32 s9, s1
957 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, 0, v1, vcc
958 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[8:11], 0
959 ; GCN-IR-NEXT: s_endpgm
960 %result = urem i64 24, %x
961 store i64 %result, ptr addrspace(1) %out
965 define amdgpu_kernel void @s_test_urem_k_den_i64(ptr addrspace(1) %out, i64 %x) {
966 ; GCN-LABEL: s_test_urem_k_den_i64:
968 ; GCN-NEXT: s_add_u32 s0, 0, 0xaaaa0000
969 ; GCN-NEXT: v_not_b32_e32 v0, 23
970 ; GCN-NEXT: v_mul_hi_u32 v0, s0, v0
971 ; GCN-NEXT: s_addc_u32 s1, 0, 42
972 ; GCN-NEXT: s_add_i32 s1, s1, 0xaaaaa80
973 ; GCN-NEXT: s_mul_i32 s8, s0, 0xffffffe8
974 ; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s0, v0
975 ; GCN-NEXT: s_mul_i32 s9, s1, 0xffffffe8
976 ; GCN-NEXT: v_mov_b32_e32 v1, s8
977 ; GCN-NEXT: v_add_i32_e32 v0, vcc, s9, v0
978 ; GCN-NEXT: v_mul_hi_u32 v2, s1, v1
979 ; GCN-NEXT: v_mul_lo_u32 v3, s0, v0
980 ; GCN-NEXT: v_mul_hi_u32 v1, s0, v1
981 ; GCN-NEXT: v_mul_hi_u32 v4, s0, v0
982 ; GCN-NEXT: s_mul_i32 s8, s1, s8
983 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[2:3], 0x9
984 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3
985 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
986 ; GCN-NEXT: v_mul_hi_u32 v4, s1, v0
987 ; GCN-NEXT: v_mul_lo_u32 v0, s1, v0
988 ; GCN-NEXT: v_add_i32_e32 v1, vcc, s8, v1
989 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
990 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v4, vcc
991 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0
992 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
993 ; GCN-NEXT: v_mov_b32_e32 v2, s1
994 ; GCN-NEXT: v_add_i32_e32 v0, vcc, s0, v0
995 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v2, v1, vcc
996 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
997 ; GCN-NEXT: v_mul_lo_u32 v2, s6, v1
998 ; GCN-NEXT: v_mul_hi_u32 v3, s6, v0
999 ; GCN-NEXT: v_mul_hi_u32 v4, s6, v1
1000 ; GCN-NEXT: v_mul_hi_u32 v5, s7, v1
1001 ; GCN-NEXT: v_mul_lo_u32 v1, s7, v1
1002 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
1003 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
1004 ; GCN-NEXT: v_mul_lo_u32 v4, s7, v0
1005 ; GCN-NEXT: v_mul_hi_u32 v0, s7, v0
1006 ; GCN-NEXT: s_mov_b32 s3, 0xf000
1007 ; GCN-NEXT: s_mov_b32 s2, -1
1008 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
1009 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
1010 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
1011 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1012 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
1013 ; GCN-NEXT: v_mul_lo_u32 v1, v1, 24
1014 ; GCN-NEXT: v_mul_hi_u32 v2, v0, 24
1015 ; GCN-NEXT: v_mul_lo_u32 v0, v0, 24
1016 ; GCN-NEXT: s_mov_b32 s0, s4
1017 ; GCN-NEXT: s_mov_b32 s1, s5
1018 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v2
1019 ; GCN-NEXT: v_mov_b32_e32 v2, s7
1020 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, s6, v0
1021 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v2, v1, vcc
1022 ; GCN-NEXT: v_subrev_i32_e32 v2, vcc, 24, v0
1023 ; GCN-NEXT: v_subbrev_u32_e32 v3, vcc, 0, v1, vcc
1024 ; GCN-NEXT: v_subrev_i32_e32 v4, vcc, 24, v2
1025 ; GCN-NEXT: v_subbrev_u32_e32 v5, vcc, 0, v3, vcc
1026 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 23, v2
1027 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
1028 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v3
1029 ; GCN-NEXT: v_cndmask_b32_e32 v6, -1, v6, vcc
1030 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v6
1031 ; GCN-NEXT: v_cndmask_b32_e32 v3, v3, v5, vcc
1032 ; GCN-NEXT: v_cndmask_b32_e32 v2, v2, v4, vcc
1033 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 23, v0
1034 ; GCN-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
1035 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v1
1036 ; GCN-NEXT: v_cndmask_b32_e32 v4, -1, v4, vcc
1037 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
1038 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
1039 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
1040 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1041 ; GCN-NEXT: s_endpgm
1043 ; GCN-IR-LABEL: s_test_urem_k_den_i64:
1044 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1045 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
1046 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1047 ; GCN-IR-NEXT: s_flbit_i32_b64 s12, s[2:3]
1048 ; GCN-IR-NEXT: s_sub_u32 s8, 59, s12
1049 ; GCN-IR-NEXT: s_subb_u32 s9, 0, 0
1050 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], s[2:3], 0
1051 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[6:7], s[8:9], 63
1052 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[10:11], s[8:9], 63
1053 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[6:7]
1054 ; GCN-IR-NEXT: s_and_b64 s[6:7], s[4:5], exec
1055 ; GCN-IR-NEXT: s_cselect_b32 s7, 0, s3
1056 ; GCN-IR-NEXT: s_cselect_b32 s6, 0, s2
1057 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[10:11]
1058 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[4:5]
1059 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0
1060 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_5
1061 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1062 ; GCN-IR-NEXT: s_add_u32 s10, s8, 1
1063 ; GCN-IR-NEXT: s_addc_u32 s11, s9, 0
1064 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[10:11], 0
1065 ; GCN-IR-NEXT: s_sub_i32 s8, 63, s8
1066 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[6:7]
1067 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[2:3], s8
1068 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_4
1069 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1070 ; GCN-IR-NEXT: s_lshr_b64 s[10:11], s[2:3], s10
1071 ; GCN-IR-NEXT: s_add_u32 s8, s12, 0xffffffc4
1072 ; GCN-IR-NEXT: s_addc_u32 s9, 0, -1
1073 ; GCN-IR-NEXT: s_mov_b64 s[12:13], 0
1074 ; GCN-IR-NEXT: s_mov_b32 s5, 0
1075 ; GCN-IR-NEXT: .LBB7_3: ; %udiv-do-while
1076 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1077 ; GCN-IR-NEXT: s_lshl_b64 s[10:11], s[10:11], 1
1078 ; GCN-IR-NEXT: s_lshr_b32 s4, s7, 31
1079 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
1080 ; GCN-IR-NEXT: s_or_b64 s[10:11], s[10:11], s[4:5]
1081 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[12:13], s[6:7]
1082 ; GCN-IR-NEXT: s_sub_u32 s4, 23, s10
1083 ; GCN-IR-NEXT: s_subb_u32 s4, 0, s11
1084 ; GCN-IR-NEXT: s_ashr_i32 s12, s4, 31
1085 ; GCN-IR-NEXT: s_and_b32 s4, s12, 1
1086 ; GCN-IR-NEXT: s_and_b32 s12, s12, 24
1087 ; GCN-IR-NEXT: s_sub_u32 s10, s10, s12
1088 ; GCN-IR-NEXT: s_subb_u32 s11, s11, 0
1089 ; GCN-IR-NEXT: s_add_u32 s8, s8, 1
1090 ; GCN-IR-NEXT: s_addc_u32 s9, s9, 0
1091 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[14:15], s[8:9], 0
1092 ; GCN-IR-NEXT: s_mov_b64 s[12:13], s[4:5]
1093 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[14:15]
1094 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_3
1095 ; GCN-IR-NEXT: .LBB7_4: ; %Flow6
1096 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
1097 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[6:7]
1098 ; GCN-IR-NEXT: .LBB7_5: ; %udiv-end
1099 ; GCN-IR-NEXT: v_mul_hi_u32 v0, s6, 24
1100 ; GCN-IR-NEXT: s_mov_b32 s8, s0
1101 ; GCN-IR-NEXT: s_mul_i32 s0, s7, 24
1102 ; GCN-IR-NEXT: v_mov_b32_e32 v2, s3
1103 ; GCN-IR-NEXT: v_add_i32_e32 v1, vcc, s0, v0
1104 ; GCN-IR-NEXT: s_mul_i32 s0, s6, 24
1105 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s0
1106 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, s2, v0
1107 ; GCN-IR-NEXT: s_mov_b32 s11, 0xf000
1108 ; GCN-IR-NEXT: s_mov_b32 s10, -1
1109 ; GCN-IR-NEXT: s_mov_b32 s9, s1
1110 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, v2, v1, vcc
1111 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[8:11], 0
1112 ; GCN-IR-NEXT: s_endpgm
1113 %result = urem i64 %x, 24
1114 store i64 %result, ptr addrspace(1) %out
1118 ; FIXME: Constant bus violation
1119 ; define i64 @v_test_urem_k_num_i64(i64 %x) {
1120 ; %result = urem i64 24, %x
1124 define i64 @v_test_urem_pow2_k_num_i64(i64 %x) {
1125 ; GCN-LABEL: v_test_urem_pow2_k_num_i64:
1127 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1128 ; GCN-NEXT: v_cvt_f32_u32_e32 v2, v0
1129 ; GCN-NEXT: v_cvt_f32_u32_e32 v3, v1
1130 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, 0, v0
1131 ; GCN-NEXT: v_subb_u32_e32 v5, vcc, 0, v1, vcc
1132 ; GCN-NEXT: v_madmk_f32 v2, v3, 0x4f800000, v2
1133 ; GCN-NEXT: v_rcp_f32_e32 v2, v2
1134 ; GCN-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v2
1135 ; GCN-NEXT: v_mul_f32_e32 v3, 0x2f800000, v2
1136 ; GCN-NEXT: v_trunc_f32_e32 v3, v3
1137 ; GCN-NEXT: v_madmk_f32 v2, v3, 0xcf800000, v2
1138 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v3
1139 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v2
1140 ; GCN-NEXT: v_mul_lo_u32 v6, v4, v3
1141 ; GCN-NEXT: v_mul_hi_u32 v7, v4, v2
1142 ; GCN-NEXT: v_mul_lo_u32 v8, v5, v2
1143 ; GCN-NEXT: v_mul_lo_u32 v9, v4, v2
1144 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1145 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v8
1146 ; GCN-NEXT: v_mul_hi_u32 v7, v2, v9
1147 ; GCN-NEXT: v_mul_lo_u32 v8, v2, v6
1148 ; GCN-NEXT: v_mul_hi_u32 v10, v2, v6
1149 ; GCN-NEXT: v_mul_hi_u32 v11, v3, v6
1150 ; GCN-NEXT: v_mul_lo_u32 v6, v3, v6
1151 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v7, v8
1152 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v10, vcc
1153 ; GCN-NEXT: v_mul_lo_u32 v10, v3, v9
1154 ; GCN-NEXT: v_mul_hi_u32 v9, v3, v9
1155 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v7, v10
1156 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, v8, v9, vcc
1157 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v11, vcc
1158 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1159 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
1160 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v6
1161 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v3, v7, vcc
1162 ; GCN-NEXT: v_mul_lo_u32 v6, v4, v3
1163 ; GCN-NEXT: v_mul_hi_u32 v7, v4, v2
1164 ; GCN-NEXT: v_mul_lo_u32 v5, v5, v2
1165 ; GCN-NEXT: v_mul_lo_u32 v4, v4, v2
1166 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1167 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v6, v5
1168 ; GCN-NEXT: v_mul_lo_u32 v8, v2, v5
1169 ; GCN-NEXT: v_mul_hi_u32 v9, v2, v4
1170 ; GCN-NEXT: v_mul_hi_u32 v10, v2, v5
1171 ; GCN-NEXT: v_mul_hi_u32 v7, v3, v4
1172 ; GCN-NEXT: v_mul_lo_u32 v4, v3, v4
1173 ; GCN-NEXT: v_mul_hi_u32 v6, v3, v5
1174 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
1175 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
1176 ; GCN-NEXT: v_mul_lo_u32 v5, v3, v5
1177 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v8, v4
1178 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v9, v7, vcc
1179 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
1180 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v5
1181 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
1182 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
1183 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v3, v5, vcc
1184 ; GCN-NEXT: v_lshrrev_b32_e32 v2, 17, v2
1185 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v2
1186 ; GCN-NEXT: v_mul_hi_u32 v4, v0, v2
1187 ; GCN-NEXT: v_mul_lo_u32 v2, v0, v2
1188 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3
1189 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, 0, v3
1190 ; GCN-NEXT: v_sub_i32_e32 v2, vcc, 0x8000, v2
1191 ; GCN-NEXT: v_subb_u32_e64 v4, s[4:5], v4, v1, vcc
1192 ; GCN-NEXT: v_sub_i32_e64 v5, s[4:5], v2, v0
1193 ; GCN-NEXT: v_subbrev_u32_e64 v6, s[6:7], 0, v4, s[4:5]
1194 ; GCN-NEXT: v_cmp_ge_u32_e64 s[6:7], v6, v1
1195 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[6:7]
1196 ; GCN-NEXT: v_cmp_ge_u32_e64 s[6:7], v5, v0
1197 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[6:7]
1198 ; GCN-NEXT: v_cmp_eq_u32_e64 s[6:7], v6, v1
1199 ; GCN-NEXT: v_subb_u32_e64 v4, s[4:5], v4, v1, s[4:5]
1200 ; GCN-NEXT: v_cndmask_b32_e64 v7, v7, v8, s[6:7]
1201 ; GCN-NEXT: v_sub_i32_e64 v8, s[4:5], v5, v0
1202 ; GCN-NEXT: v_subb_u32_e32 v3, vcc, 0, v3, vcc
1203 ; GCN-NEXT: v_subbrev_u32_e64 v4, s[4:5], 0, v4, s[4:5]
1204 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v3, v1
1205 ; GCN-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, v7
1206 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, vcc
1207 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v2, v0
1208 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
1209 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, v3, v1
1210 ; GCN-NEXT: v_cndmask_b32_e32 v0, v7, v0, vcc
1211 ; GCN-NEXT: v_cndmask_b32_e64 v5, v5, v8, s[4:5]
1212 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
1213 ; GCN-NEXT: v_cndmask_b32_e64 v1, v6, v4, s[4:5]
1214 ; GCN-NEXT: v_cndmask_b32_e32 v0, v2, v5, vcc
1215 ; GCN-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
1216 ; GCN-NEXT: s_setpc_b64 s[30:31]
1218 ; GCN-IR-LABEL: v_test_urem_pow2_k_num_i64:
1219 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1220 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1221 ; GCN-IR-NEXT: v_ffbh_u32_e32 v2, v0
1222 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, 32, v2
1223 ; GCN-IR-NEXT: v_ffbh_u32_e32 v3, v1
1224 ; GCN-IR-NEXT: v_min_u32_e32 v10, v2, v3
1225 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, 0xffffffd0, v10
1226 ; GCN-IR-NEXT: v_addc_u32_e64 v3, s[6:7], 0, -1, vcc
1227 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], 0, v[0:1]
1228 ; GCN-IR-NEXT: v_cmp_lt_u64_e32 vcc, 63, v[2:3]
1229 ; GCN-IR-NEXT: v_cmp_ne_u64_e64 s[6:7], 63, v[2:3]
1230 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0x8000
1231 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], vcc
1232 ; GCN-IR-NEXT: v_cndmask_b32_e64 v4, v4, 0, s[4:5]
1233 ; GCN-IR-NEXT: s_xor_b64 s[4:5], s[4:5], -1
1234 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1235 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
1236 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
1237 ; GCN-IR-NEXT: s_cbranch_execz .LBB8_6
1238 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1239 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 1, v2
1240 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 63, v2
1241 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, 0, v3, vcc
1242 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0x8000
1243 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[6:7]
1244 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], s[4:5], v2
1245 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0
1246 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1247 ; GCN-IR-NEXT: s_and_saveexec_b64 s[8:9], vcc
1248 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[8:9]
1249 ; GCN-IR-NEXT: s_cbranch_execz .LBB8_5
1250 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1251 ; GCN-IR-NEXT: v_add_i32_e32 v12, vcc, -1, v0
1252 ; GCN-IR-NEXT: v_addc_u32_e32 v13, vcc, -1, v1, vcc
1253 ; GCN-IR-NEXT: v_lshr_b64 v[8:9], s[4:5], v6
1254 ; GCN-IR-NEXT: v_sub_i32_e32 v6, vcc, 47, v10
1255 ; GCN-IR-NEXT: v_mov_b32_e32 v10, 0
1256 ; GCN-IR-NEXT: v_subb_u32_e64 v7, s[4:5], 0, 0, vcc
1257 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1258 ; GCN-IR-NEXT: v_mov_b32_e32 v11, 0
1259 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1260 ; GCN-IR-NEXT: .LBB8_3: ; %udiv-do-while
1261 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1262 ; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1
1263 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v3
1264 ; GCN-IR-NEXT: v_or_b32_e32 v8, v8, v4
1265 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1266 ; GCN-IR-NEXT: v_sub_i32_e32 v4, vcc, v12, v8
1267 ; GCN-IR-NEXT: v_subb_u32_e32 v4, vcc, v13, v9, vcc
1268 ; GCN-IR-NEXT: v_or_b32_e32 v2, v10, v2
1269 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v4
1270 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 1, v6
1271 ; GCN-IR-NEXT: v_or_b32_e32 v3, v11, v3
1272 ; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v10
1273 ; GCN-IR-NEXT: v_and_b32_e32 v11, v10, v1
1274 ; GCN-IR-NEXT: v_and_b32_e32 v10, v10, v0
1275 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, 0, v7, vcc
1276 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[6:7]
1277 ; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v8, v10
1278 ; GCN-IR-NEXT: v_subb_u32_e64 v9, s[4:5], v9, v11, s[4:5]
1279 ; GCN-IR-NEXT: v_mov_b32_e32 v11, v5
1280 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
1281 ; GCN-IR-NEXT: v_mov_b32_e32 v10, v4
1282 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
1283 ; GCN-IR-NEXT: s_cbranch_execnz .LBB8_3
1284 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
1285 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
1286 ; GCN-IR-NEXT: .LBB8_5: ; %Flow4
1287 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
1288 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1289 ; GCN-IR-NEXT: v_or_b32_e32 v5, v5, v3
1290 ; GCN-IR-NEXT: v_or_b32_e32 v4, v4, v2
1291 ; GCN-IR-NEXT: .LBB8_6: ; %Flow5
1292 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
1293 ; GCN-IR-NEXT: v_mul_lo_u32 v2, v0, v5
1294 ; GCN-IR-NEXT: v_mul_hi_u32 v3, v0, v4
1295 ; GCN-IR-NEXT: v_mul_lo_u32 v1, v1, v4
1296 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v0, v4
1297 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, v3, v2
1298 ; GCN-IR-NEXT: v_add_i32_e32 v1, vcc, v2, v1
1299 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, 0x8000, v0
1300 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, 0, v1, vcc
1301 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1302 %result = urem i64 32768, %x
1306 define i64 @v_test_urem_pow2_k_den_i64(i64 %x) {
1307 ; GCN-LABEL: v_test_urem_pow2_k_den_i64:
1309 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1310 ; GCN-NEXT: v_and_b32_e32 v0, 0x7fff, v0
1311 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1312 ; GCN-NEXT: s_setpc_b64 s[30:31]
1314 ; GCN-IR-LABEL: v_test_urem_pow2_k_den_i64:
1315 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1316 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1317 ; GCN-IR-NEXT: v_ffbh_u32_e32 v2, v0
1318 ; GCN-IR-NEXT: v_add_i32_e64 v2, s[4:5], 32, v2
1319 ; GCN-IR-NEXT: v_ffbh_u32_e32 v3, v1
1320 ; GCN-IR-NEXT: v_min_u32_e32 v10, v2, v3
1321 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 48, v10
1322 ; GCN-IR-NEXT: v_subb_u32_e64 v3, s[4:5], 0, 0, s[4:5]
1323 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
1324 ; GCN-IR-NEXT: v_cmp_lt_u64_e64 s[4:5], 63, v[2:3]
1325 ; GCN-IR-NEXT: s_or_b64 s[4:5], vcc, s[4:5]
1326 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 63, v[2:3]
1327 ; GCN-IR-NEXT: s_xor_b64 s[6:7], s[4:5], -1
1328 ; GCN-IR-NEXT: v_cndmask_b32_e64 v5, v1, 0, s[4:5]
1329 ; GCN-IR-NEXT: v_cndmask_b32_e64 v4, v0, 0, s[4:5]
1330 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[6:7], vcc
1331 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
1332 ; GCN-IR-NEXT: s_cbranch_execz .LBB9_6
1333 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1334 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 1, v2
1335 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, 0, v3, vcc
1336 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 63, v2
1337 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[6:7]
1338 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[0:1], v2
1339 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0
1340 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1341 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc
1342 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[4:5]
1343 ; GCN-IR-NEXT: s_cbranch_execz .LBB9_5
1344 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1345 ; GCN-IR-NEXT: v_lshr_b64 v[8:9], v[0:1], v6
1346 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 0xffffffcf, v10
1347 ; GCN-IR-NEXT: v_mov_b32_e32 v10, 0
1348 ; GCN-IR-NEXT: v_addc_u32_e64 v7, s[4:5], 0, -1, vcc
1349 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1350 ; GCN-IR-NEXT: v_mov_b32_e32 v11, 0
1351 ; GCN-IR-NEXT: s_movk_i32 s12, 0x7fff
1352 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1353 ; GCN-IR-NEXT: .LBB9_3: ; %udiv-do-while
1354 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1355 ; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1
1356 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v3
1357 ; GCN-IR-NEXT: v_or_b32_e32 v8, v8, v4
1358 ; GCN-IR-NEXT: v_sub_i32_e32 v4, vcc, s12, v8
1359 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1360 ; GCN-IR-NEXT: v_subb_u32_e32 v4, vcc, 0, v9, vcc
1361 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 1, v6
1362 ; GCN-IR-NEXT: v_or_b32_e32 v2, v10, v2
1363 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v4
1364 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, 0, v7, vcc
1365 ; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v10
1366 ; GCN-IR-NEXT: v_and_b32_e32 v10, 0x8000, v10
1367 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[6:7]
1368 ; GCN-IR-NEXT: v_or_b32_e32 v3, v11, v3
1369 ; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v8, v10
1370 ; GCN-IR-NEXT: v_mov_b32_e32 v11, v5
1371 ; GCN-IR-NEXT: v_subbrev_u32_e64 v9, s[4:5], 0, v9, s[4:5]
1372 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
1373 ; GCN-IR-NEXT: v_mov_b32_e32 v10, v4
1374 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
1375 ; GCN-IR-NEXT: s_cbranch_execnz .LBB9_3
1376 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
1377 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
1378 ; GCN-IR-NEXT: .LBB9_5: ; %Flow4
1379 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
1380 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1381 ; GCN-IR-NEXT: v_or_b32_e32 v5, v5, v3
1382 ; GCN-IR-NEXT: v_or_b32_e32 v4, v4, v2
1383 ; GCN-IR-NEXT: .LBB9_6: ; %Flow5
1384 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
1385 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[4:5], 15
1386 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
1387 ; GCN-IR-NEXT: v_subb_u32_e32 v1, vcc, v1, v3, vcc
1388 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1389 %result = urem i64 %x, 32768
1393 define amdgpu_kernel void @s_test_urem24_k_num_i64(ptr addrspace(1) %out, i64 %x) {
1394 ; GCN-LABEL: s_test_urem24_k_num_i64:
1396 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
1397 ; GCN-NEXT: s_mov_b32 s5, 0x41c00000
1398 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
1399 ; GCN-NEXT: s_mov_b32 s2, -1
1400 ; GCN-NEXT: s_lshr_b32 s4, s3, 8
1401 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s4
1402 ; GCN-NEXT: s_mov_b32 s3, 0xf000
1403 ; GCN-NEXT: v_rcp_iflag_f32_e32 v1, v0
1404 ; GCN-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1405 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1406 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1407 ; GCN-NEXT: v_mad_f32 v1, -v1, v0, s5
1408 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1409 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1410 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1411 ; GCN-NEXT: v_mul_lo_u32 v0, v0, s4
1412 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, 24, v0
1413 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1414 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1415 ; GCN-NEXT: s_endpgm
1417 ; GCN-IR-LABEL: s_test_urem24_k_num_i64:
1419 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
1420 ; GCN-IR-NEXT: s_mov_b32 s5, 0x41c00000
1421 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1422 ; GCN-IR-NEXT: s_mov_b32 s2, -1
1423 ; GCN-IR-NEXT: s_lshr_b32 s4, s3, 8
1424 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s4
1425 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
1426 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v1, v0
1427 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1428 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1429 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1430 ; GCN-IR-NEXT: v_mad_f32 v1, -v1, v0, s5
1431 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1432 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1433 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1434 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v0, s4
1435 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, 24, v0
1436 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1437 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1438 ; GCN-IR-NEXT: s_endpgm
1439 %x.shr = lshr i64 %x, 40
1440 %result = urem i64 24, %x.shr
1441 store i64 %result, ptr addrspace(1) %out
1445 define amdgpu_kernel void @s_test_urem24_k_den_i64(ptr addrspace(1) %out, i64 %x) {
1446 ; GCN-LABEL: s_test_urem24_k_den_i64:
1448 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
1449 ; GCN-NEXT: s_movk_i32 s4, 0x5b7f
1450 ; GCN-NEXT: s_mov_b32 s7, 0xf000
1451 ; GCN-NEXT: s_mov_b32 s6, -1
1452 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
1453 ; GCN-NEXT: s_lshr_b32 s2, s3, 8
1454 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
1455 ; GCN-NEXT: s_mov_b32 s3, 0x46b6fe00
1456 ; GCN-NEXT: s_mov_b32 s5, s1
1457 ; GCN-NEXT: v_mul_f32_e32 v1, 0x38331158, v0
1458 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1459 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1460 ; GCN-NEXT: v_mad_f32 v0, -v1, s3, v0
1461 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s3
1462 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1463 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1464 ; GCN-NEXT: v_mul_lo_u32 v0, v0, s4
1465 ; GCN-NEXT: s_mov_b32 s4, s0
1466 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, s2, v0
1467 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1468 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
1469 ; GCN-NEXT: s_endpgm
1471 ; GCN-IR-LABEL: s_test_urem24_k_den_i64:
1473 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[2:3], 0x9
1474 ; GCN-IR-NEXT: s_movk_i32 s4, 0x5b7f
1475 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
1476 ; GCN-IR-NEXT: s_mov_b32 s6, -1
1477 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1478 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 8
1479 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
1480 ; GCN-IR-NEXT: s_mov_b32 s3, 0x46b6fe00
1481 ; GCN-IR-NEXT: s_mov_b32 s5, s1
1482 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x38331158, v0
1483 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1484 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1485 ; GCN-IR-NEXT: v_mad_f32 v0, -v1, s3, v0
1486 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s3
1487 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1488 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1489 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v0, s4
1490 ; GCN-IR-NEXT: s_mov_b32 s4, s0
1491 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, s2, v0
1492 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1493 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
1494 ; GCN-IR-NEXT: s_endpgm
1495 %x.shr = lshr i64 %x, 40
1496 %result = urem i64 %x.shr, 23423
1497 store i64 %result, ptr addrspace(1) %out
1501 define i64 @v_test_urem24_k_num_i64(i64 %x) {
1502 ; GCN-LABEL: v_test_urem24_k_num_i64:
1504 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1505 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1506 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, v0
1507 ; GCN-NEXT: s_mov_b32 s4, 0x41c00000
1508 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v1
1509 ; GCN-NEXT: v_mul_f32_e32 v2, 0x41c00000, v2
1510 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
1511 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
1512 ; GCN-NEXT: v_mad_f32 v2, -v2, v1, s4
1513 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v1
1514 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
1515 ; GCN-NEXT: v_mul_lo_u32 v0, v1, v0
1516 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1517 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, 24, v0
1518 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1519 ; GCN-NEXT: s_setpc_b64 s[30:31]
1521 ; GCN-IR-LABEL: v_test_urem24_k_num_i64:
1523 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1524 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1525 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, v0
1526 ; GCN-IR-NEXT: s_mov_b32 s4, 0x41c00000
1527 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v1
1528 ; GCN-IR-NEXT: v_mul_f32_e32 v2, 0x41c00000, v2
1529 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
1530 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
1531 ; GCN-IR-NEXT: v_mad_f32 v2, -v2, v1, s4
1532 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v1
1533 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
1534 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v1, v0
1535 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1536 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, 24, v0
1537 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1538 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1539 %x.shr = lshr i64 %x, 40
1540 %result = urem i64 24, %x.shr
1544 define i64 @v_test_urem24_pow2_k_num_i64(i64 %x) {
1545 ; GCN-LABEL: v_test_urem24_pow2_k_num_i64:
1547 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1548 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1549 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, v0
1550 ; GCN-NEXT: s_mov_b32 s4, 0x47000000
1551 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v1
1552 ; GCN-NEXT: v_mul_f32_e32 v2, 0x47000000, v2
1553 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
1554 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
1555 ; GCN-NEXT: v_mad_f32 v2, -v2, v1, s4
1556 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v1
1557 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
1558 ; GCN-NEXT: v_mul_lo_u32 v0, v1, v0
1559 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1560 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, 0x8000, v0
1561 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1562 ; GCN-NEXT: s_setpc_b64 s[30:31]
1564 ; GCN-IR-LABEL: v_test_urem24_pow2_k_num_i64:
1566 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1567 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1568 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, v0
1569 ; GCN-IR-NEXT: s_mov_b32 s4, 0x47000000
1570 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v1
1571 ; GCN-IR-NEXT: v_mul_f32_e32 v2, 0x47000000, v2
1572 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
1573 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
1574 ; GCN-IR-NEXT: v_mad_f32 v2, -v2, v1, s4
1575 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v2|, v1
1576 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
1577 ; GCN-IR-NEXT: v_mul_lo_u32 v0, v1, v0
1578 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1579 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, 0x8000, v0
1580 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1581 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1582 %x.shr = lshr i64 %x, 40
1583 %result = urem i64 32768, %x.shr
1587 define i64 @v_test_urem24_pow2_k_den_i64(i64 %x) {
1588 ; GCN-LABEL: v_test_urem24_pow2_k_den_i64:
1590 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1591 ; GCN-NEXT: v_bfe_u32 v0, v1, 8, 15
1592 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1593 ; GCN-NEXT: s_setpc_b64 s[30:31]
1595 ; GCN-IR-LABEL: v_test_urem24_pow2_k_den_i64:
1597 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1598 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1599 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, v0
1600 ; GCN-IR-NEXT: s_mov_b32 s4, 0x47000000
1601 ; GCN-IR-NEXT: v_mul_f32_e32 v2, 0x38000000, v1
1602 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
1603 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
1604 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, s4, v1
1605 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, s4
1606 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v3, vcc
1607 ; GCN-IR-NEXT: v_lshlrev_b32_e32 v1, 15, v1
1608 ; GCN-IR-NEXT: v_sub_i32_e32 v0, vcc, v0, v1
1609 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1610 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1611 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1612 %x.shr = lshr i64 %x, 40
1613 %result = urem i64 %x.shr, 32768