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