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_udiv_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
6 ; GCN-LABEL: s_test_udiv_i64:
8 ; GCN-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0xd
9 ; GCN-NEXT: s_load_dwordx4 s[0:3], 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, s8
14 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s9
15 ; GCN-NEXT: s_sub_u32 s4, 0, s8
16 ; GCN-NEXT: s_subb_u32 s5, 0, s9
17 ; GCN-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
18 ; GCN-NEXT: v_rcp_f32_e32 v0, v0
19 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
20 ; GCN-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
21 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
22 ; GCN-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
23 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
24 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
25 ; GCN-NEXT: v_mul_lo_u32 v2, s4, v1
26 ; GCN-NEXT: v_mul_hi_u32 v3, s4, v0
27 ; GCN-NEXT: v_mul_lo_u32 v5, s5, v0
28 ; GCN-NEXT: v_mul_lo_u32 v4, s4, v0
29 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
30 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v5
31 ; GCN-NEXT: v_mul_hi_u32 v3, v0, v4
32 ; GCN-NEXT: v_mul_lo_u32 v5, v0, v2
33 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v2
34 ; GCN-NEXT: v_mul_hi_u32 v6, v1, v4
35 ; GCN-NEXT: v_mul_lo_u32 v4, v1, v4
36 ; GCN-NEXT: v_mul_hi_u32 v8, v1, v2
37 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
38 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
39 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
40 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
41 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
42 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
43 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
44 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
45 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
46 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
47 ; GCN-NEXT: v_mul_lo_u32 v2, s4, v1
48 ; GCN-NEXT: v_mul_hi_u32 v3, s4, v0
49 ; GCN-NEXT: v_mul_lo_u32 v4, s5, v0
50 ; GCN-NEXT: s_mov_b32 s5, s1
51 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
52 ; GCN-NEXT: v_mul_lo_u32 v3, s4, v0
53 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
54 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v2
55 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v3
56 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v2
57 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v3
58 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v3
59 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v2
60 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
61 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
62 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
63 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v6, v3
64 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
65 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
66 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
67 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
68 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
69 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
70 ; GCN-NEXT: v_mul_lo_u32 v2, s2, v1
71 ; GCN-NEXT: v_mul_hi_u32 v3, s2, v0
72 ; GCN-NEXT: v_mul_hi_u32 v4, s2, v1
73 ; GCN-NEXT: v_mul_hi_u32 v5, s3, v1
74 ; GCN-NEXT: v_mul_lo_u32 v1, s3, v1
75 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
76 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
77 ; GCN-NEXT: v_mul_lo_u32 v4, s3, v0
78 ; GCN-NEXT: v_mul_hi_u32 v0, s3, v0
79 ; GCN-NEXT: s_mov_b32 s4, s0
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 v2, s8, v1
86 ; GCN-NEXT: v_mul_hi_u32 v3, s8, v0
87 ; GCN-NEXT: v_mul_lo_u32 v4, s9, v0
88 ; GCN-NEXT: v_mov_b32_e32 v5, s9
89 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
90 ; GCN-NEXT: v_mul_lo_u32 v3, s8, v0
91 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v4, v2
92 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, s3, v2
93 ; GCN-NEXT: v_sub_i32_e32 v3, vcc, s2, v3
94 ; GCN-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc
95 ; GCN-NEXT: v_subrev_i32_e64 v5, s[0:1], s8, v3
96 ; GCN-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1]
97 ; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s9, v4
98 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[0:1]
99 ; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s8, v5
100 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[0:1]
101 ; GCN-NEXT: v_cmp_eq_u32_e64 s[0:1], s9, v4
102 ; GCN-NEXT: v_cndmask_b32_e64 v4, v6, v5, s[0:1]
103 ; GCN-NEXT: v_add_i32_e64 v5, s[0:1], 1, v0
104 ; GCN-NEXT: v_addc_u32_e64 v6, s[0:1], 0, v1, s[0:1]
105 ; GCN-NEXT: v_add_i32_e64 v7, s[0:1], 2, v0
106 ; GCN-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v1, s[0:1]
107 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v4
108 ; GCN-NEXT: v_cndmask_b32_e64 v4, v5, v7, s[0:1]
109 ; GCN-NEXT: v_cndmask_b32_e64 v5, v6, v8, s[0:1]
110 ; GCN-NEXT: v_mov_b32_e32 v6, s3
111 ; GCN-NEXT: v_subb_u32_e32 v2, vcc, v6, v2, vcc
112 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s9, v2
113 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
114 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s8, v3
115 ; GCN-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc
116 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s9, v2
117 ; GCN-NEXT: v_cndmask_b32_e32 v2, v6, v3, vcc
118 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
119 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc
120 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
121 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
124 ; GCN-IR-LABEL: s_test_udiv_i64:
125 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
126 ; GCN-IR-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
127 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
128 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
129 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[4:5], 0
130 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[8:9], s[2:3], 0
131 ; GCN-IR-NEXT: s_flbit_i32_b32 s10, s4
132 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[6:7], s[8:9]
133 ; GCN-IR-NEXT: s_flbit_i32_b32 s6, s2
134 ; GCN-IR-NEXT: s_flbit_i32_b32 s11, s5
135 ; GCN-IR-NEXT: s_add_i32 s10, s10, 32
136 ; GCN-IR-NEXT: s_add_i32 s6, s6, 32
137 ; GCN-IR-NEXT: s_flbit_i32_b32 s7, s3
138 ; GCN-IR-NEXT: s_min_u32 s10, s10, s11
139 ; GCN-IR-NEXT: s_min_u32 s14, s6, s7
140 ; GCN-IR-NEXT: s_sub_u32 s12, s10, s14
141 ; GCN-IR-NEXT: s_subb_u32 s13, 0, 0
142 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[16:17], s[12:13], 63
143 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[18:19], s[12:13], 63
144 ; GCN-IR-NEXT: s_or_b64 s[16:17], s[8:9], s[16:17]
145 ; GCN-IR-NEXT: s_and_b64 s[8:9], s[16:17], exec
146 ; GCN-IR-NEXT: s_cselect_b32 s9, 0, s3
147 ; GCN-IR-NEXT: s_cselect_b32 s8, 0, s2
148 ; GCN-IR-NEXT: s_or_b64 s[16:17], s[16:17], s[18:19]
149 ; GCN-IR-NEXT: s_mov_b64 s[6:7], 0
150 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[16:17]
151 ; GCN-IR-NEXT: s_mov_b32 s11, 0
152 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_5
153 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
154 ; GCN-IR-NEXT: s_add_u32 s16, s12, 1
155 ; GCN-IR-NEXT: s_addc_u32 s17, s13, 0
156 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[8:9], s[16:17], 0
157 ; GCN-IR-NEXT: s_sub_i32 s12, 63, s12
158 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[8:9]
159 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[2:3], s12
160 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_4
161 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
162 ; GCN-IR-NEXT: s_lshr_b64 s[12:13], s[2:3], s16
163 ; GCN-IR-NEXT: s_add_u32 s15, s4, -1
164 ; GCN-IR-NEXT: s_addc_u32 s16, s5, -1
165 ; GCN-IR-NEXT: s_not_b64 s[2:3], s[10:11]
166 ; GCN-IR-NEXT: s_add_u32 s2, s2, s14
167 ; GCN-IR-NEXT: s_addc_u32 s3, s3, 0
168 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
169 ; GCN-IR-NEXT: s_mov_b32 s7, 0
170 ; GCN-IR-NEXT: .LBB0_3: ; %udiv-do-while
171 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
172 ; GCN-IR-NEXT: s_lshl_b64 s[12:13], s[12:13], 1
173 ; GCN-IR-NEXT: s_lshr_b32 s6, s9, 31
174 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[8:9], 1
175 ; GCN-IR-NEXT: s_or_b64 s[12:13], s[12:13], s[6:7]
176 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[10:11], s[8:9]
177 ; GCN-IR-NEXT: s_sub_u32 s6, s15, s12
178 ; GCN-IR-NEXT: s_subb_u32 s6, s16, s13
179 ; GCN-IR-NEXT: s_ashr_i32 s10, s6, 31
180 ; GCN-IR-NEXT: s_mov_b32 s11, s10
181 ; GCN-IR-NEXT: s_and_b32 s6, s10, 1
182 ; GCN-IR-NEXT: s_and_b64 s[10:11], s[10:11], s[4:5]
183 ; GCN-IR-NEXT: s_sub_u32 s12, s12, s10
184 ; GCN-IR-NEXT: s_subb_u32 s13, s13, s11
185 ; GCN-IR-NEXT: s_add_u32 s2, s2, 1
186 ; GCN-IR-NEXT: s_addc_u32 s3, s3, 0
187 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[18:19], s[2:3], 0
188 ; GCN-IR-NEXT: s_mov_b64 s[10:11], s[6:7]
189 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[18:19]
190 ; GCN-IR-NEXT: s_cbranch_vccz .LBB0_3
191 ; GCN-IR-NEXT: .LBB0_4: ; %Flow7
192 ; GCN-IR-NEXT: s_lshl_b64 s[2:3], s[8:9], 1
193 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[6:7], s[2:3]
194 ; GCN-IR-NEXT: .LBB0_5: ; %udiv-end
195 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s8
196 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
197 ; GCN-IR-NEXT: s_mov_b32 s2, -1
198 ; GCN-IR-NEXT: v_mov_b32_e32 v1, s9
199 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
200 ; GCN-IR-NEXT: s_endpgm
201 %result = udiv i64 %x, %y
202 store i64 %result, ptr addrspace(1) %out
206 define i64 @v_test_udiv_i64(i64 %x, i64 %y) {
207 ; GCN-LABEL: v_test_udiv_i64:
209 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
210 ; GCN-NEXT: v_cvt_f32_u32_e32 v4, v2
211 ; GCN-NEXT: v_cvt_f32_u32_e32 v5, v3
212 ; GCN-NEXT: v_sub_i32_e32 v6, vcc, 0, v2
213 ; GCN-NEXT: v_subb_u32_e32 v7, vcc, 0, v3, vcc
214 ; GCN-NEXT: v_madmk_f32 v4, v5, 0x4f800000, v4
215 ; GCN-NEXT: v_rcp_f32_e32 v4, v4
216 ; GCN-NEXT: v_mul_f32_e32 v4, 0x5f7ffffc, v4
217 ; GCN-NEXT: v_mul_f32_e32 v5, 0x2f800000, v4
218 ; GCN-NEXT: v_trunc_f32_e32 v5, v5
219 ; GCN-NEXT: v_madmk_f32 v4, v5, 0xcf800000, v4
220 ; GCN-NEXT: v_cvt_u32_f32_e32 v5, v5
221 ; GCN-NEXT: v_cvt_u32_f32_e32 v4, v4
222 ; GCN-NEXT: v_mul_lo_u32 v8, v6, v5
223 ; GCN-NEXT: v_mul_hi_u32 v9, v6, v4
224 ; GCN-NEXT: v_mul_lo_u32 v10, v7, v4
225 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
226 ; GCN-NEXT: v_mul_lo_u32 v9, v6, v4
227 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v8, v10
228 ; GCN-NEXT: v_mul_lo_u32 v10, v4, v8
229 ; GCN-NEXT: v_mul_hi_u32 v11, v4, v9
230 ; GCN-NEXT: v_mul_hi_u32 v12, v4, v8
231 ; GCN-NEXT: v_mul_hi_u32 v13, v5, v8
232 ; GCN-NEXT: v_mul_lo_u32 v8, v5, v8
233 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v11, v10
234 ; GCN-NEXT: v_addc_u32_e32 v11, vcc, 0, v12, vcc
235 ; GCN-NEXT: v_mul_lo_u32 v12, v5, v9
236 ; GCN-NEXT: v_mul_hi_u32 v9, v5, v9
237 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v10, v12
238 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, v11, v9, vcc
239 ; GCN-NEXT: v_addc_u32_e32 v10, vcc, 0, v13, vcc
240 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
241 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
242 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v8
243 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, v5, v9, vcc
244 ; GCN-NEXT: v_mul_lo_u32 v8, v6, v5
245 ; GCN-NEXT: v_mul_hi_u32 v9, v6, v4
246 ; GCN-NEXT: v_mul_lo_u32 v7, v7, v4
247 ; GCN-NEXT: v_mul_lo_u32 v6, v6, v4
248 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
249 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v8, v7
250 ; GCN-NEXT: v_mul_lo_u32 v10, v4, v7
251 ; GCN-NEXT: v_mul_hi_u32 v11, v4, v6
252 ; GCN-NEXT: v_mul_hi_u32 v12, v4, v7
253 ; GCN-NEXT: v_mul_hi_u32 v9, v5, v6
254 ; GCN-NEXT: v_mul_lo_u32 v6, v5, v6
255 ; GCN-NEXT: v_mul_hi_u32 v8, v5, v7
256 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v11, v10
257 ; GCN-NEXT: v_addc_u32_e32 v11, vcc, 0, v12, vcc
258 ; GCN-NEXT: v_mul_lo_u32 v7, v5, v7
259 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v10, v6
260 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, v11, v9, vcc
261 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v8, vcc
262 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v7
263 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
264 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v6
265 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, v5, v7, vcc
266 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v5
267 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v4
268 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v5
269 ; GCN-NEXT: v_mul_hi_u32 v9, v1, v5
270 ; GCN-NEXT: v_mul_lo_u32 v5, v1, v5
271 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
272 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
273 ; GCN-NEXT: v_mul_lo_u32 v8, v1, v4
274 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v4
275 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v8
276 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v7, v4, vcc
277 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, 0, v9, vcc
278 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v5
279 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
280 ; GCN-NEXT: v_mul_lo_u32 v6, v2, v5
281 ; GCN-NEXT: v_mul_hi_u32 v7, v2, v4
282 ; GCN-NEXT: v_mul_lo_u32 v8, v3, v4
283 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
284 ; GCN-NEXT: v_mul_lo_u32 v7, v2, v4
285 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v8
286 ; GCN-NEXT: v_sub_i32_e32 v8, vcc, v1, v6
287 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, v0, v7
288 ; GCN-NEXT: v_subb_u32_e64 v7, s[4:5], v8, v3, vcc
289 ; GCN-NEXT: v_sub_i32_e64 v8, s[4:5], v0, v2
290 ; GCN-NEXT: v_subbrev_u32_e64 v7, s[4:5], 0, v7, s[4:5]
291 ; GCN-NEXT: v_cmp_ge_u32_e64 s[4:5], v7, v3
292 ; GCN-NEXT: v_cndmask_b32_e64 v9, 0, -1, s[4:5]
293 ; GCN-NEXT: v_cmp_ge_u32_e64 s[4:5], v8, v2
294 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[4:5]
295 ; GCN-NEXT: v_cmp_eq_u32_e64 s[4:5], v7, v3
296 ; GCN-NEXT: v_cndmask_b32_e64 v7, v9, v8, s[4:5]
297 ; GCN-NEXT: v_add_i32_e64 v8, s[4:5], 2, v4
298 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v1, v6, vcc
299 ; GCN-NEXT: v_addc_u32_e64 v9, s[4:5], 0, v5, s[4:5]
300 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v1, v3
301 ; GCN-NEXT: v_add_i32_e64 v10, s[4:5], 1, v4
302 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
303 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v0, v2
304 ; GCN-NEXT: v_addc_u32_e64 v11, s[4:5], 0, v5, s[4:5]
305 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
306 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, v1, v3
307 ; GCN-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, v7
308 ; GCN-NEXT: v_cndmask_b32_e32 v0, v6, v0, vcc
309 ; GCN-NEXT: v_cndmask_b32_e64 v7, v10, v8, s[4:5]
310 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
311 ; GCN-NEXT: v_cndmask_b32_e64 v1, v11, v9, s[4:5]
312 ; GCN-NEXT: v_cndmask_b32_e32 v0, v4, v7, vcc
313 ; GCN-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
314 ; GCN-NEXT: s_setpc_b64 s[30:31]
316 ; GCN-IR-LABEL: v_test_udiv_i64:
317 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
318 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
319 ; GCN-IR-NEXT: v_ffbh_u32_e32 v4, v2
320 ; GCN-IR-NEXT: v_add_i32_e64 v4, s[6:7], 32, v4
321 ; GCN-IR-NEXT: v_ffbh_u32_e32 v5, v3
322 ; GCN-IR-NEXT: v_min_u32_e32 v8, v4, v5
323 ; GCN-IR-NEXT: v_ffbh_u32_e32 v4, v0
324 ; GCN-IR-NEXT: v_add_i32_e64 v4, s[6:7], 32, v4
325 ; GCN-IR-NEXT: v_ffbh_u32_e32 v5, v1
326 ; GCN-IR-NEXT: v_min_u32_e32 v9, v4, v5
327 ; GCN-IR-NEXT: v_sub_i32_e64 v6, s[6:7], v8, v9
328 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3]
329 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], 0, v[0:1]
330 ; GCN-IR-NEXT: v_subb_u32_e64 v7, s[6:7], 0, 0, s[6:7]
331 ; GCN-IR-NEXT: v_cmp_lt_u64_e64 s[6:7], 63, v[6:7]
332 ; GCN-IR-NEXT: s_or_b64 s[4:5], vcc, s[4:5]
333 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[6:7]
334 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 63, v[6:7]
335 ; GCN-IR-NEXT: s_xor_b64 s[6:7], s[4:5], -1
336 ; GCN-IR-NEXT: v_cndmask_b32_e64 v4, v1, 0, s[4:5]
337 ; GCN-IR-NEXT: v_cndmask_b32_e64 v5, v0, 0, s[4:5]
338 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[6:7], vcc
339 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
340 ; GCN-IR-NEXT: s_cbranch_execz .LBB1_6
341 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
342 ; GCN-IR-NEXT: v_add_i32_e32 v10, vcc, 1, v6
343 ; GCN-IR-NEXT: v_addc_u32_e32 v11, vcc, 0, v7, vcc
344 ; GCN-IR-NEXT: v_sub_i32_e64 v4, s[4:5], 63, v6
345 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[10:11]
346 ; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[0:1], v4
347 ; GCN-IR-NEXT: v_mov_b32_e32 v6, 0
348 ; GCN-IR-NEXT: v_mov_b32_e32 v7, 0
349 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc
350 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[4:5]
351 ; GCN-IR-NEXT: s_cbranch_execz .LBB1_5
352 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
353 ; GCN-IR-NEXT: v_add_i32_e32 v12, vcc, -1, v2
354 ; GCN-IR-NEXT: v_lshr_b64 v[10:11], v[0:1], v10
355 ; GCN-IR-NEXT: v_addc_u32_e32 v13, vcc, -1, v3, vcc
356 ; GCN-IR-NEXT: v_not_b32_e32 v0, v8
357 ; GCN-IR-NEXT: v_not_b32_e32 v1, 0
358 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, v0, v9
359 ; GCN-IR-NEXT: v_mov_b32_e32 v8, 0
360 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
361 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
362 ; GCN-IR-NEXT: v_mov_b32_e32 v9, 0
363 ; GCN-IR-NEXT: v_mov_b32_e32 v7, 0
364 ; GCN-IR-NEXT: .LBB1_3: ; %udiv-do-while
365 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
366 ; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[10:11], 1
367 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v5
368 ; GCN-IR-NEXT: v_or_b32_e32 v10, v10, v6
369 ; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[4:5], 1
370 ; GCN-IR-NEXT: v_sub_i32_e32 v6, vcc, v12, v10
371 ; GCN-IR-NEXT: v_subb_u32_e32 v6, vcc, v13, v11, vcc
372 ; GCN-IR-NEXT: v_or_b32_e32 v4, v8, v4
373 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v8, 31, v6
374 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, 1, v0
375 ; GCN-IR-NEXT: v_or_b32_e32 v5, v9, v5
376 ; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v8
377 ; GCN-IR-NEXT: v_and_b32_e32 v9, v8, v3
378 ; GCN-IR-NEXT: v_and_b32_e32 v8, v8, v2
379 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
380 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
381 ; GCN-IR-NEXT: v_sub_i32_e64 v10, s[4:5], v10, v8
382 ; GCN-IR-NEXT: v_subb_u32_e64 v11, s[4:5], v11, v9, s[4:5]
383 ; GCN-IR-NEXT: v_mov_b32_e32 v9, v7
384 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
385 ; GCN-IR-NEXT: v_mov_b32_e32 v8, v6
386 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
387 ; GCN-IR-NEXT: s_cbranch_execnz .LBB1_3
388 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
389 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
390 ; GCN-IR-NEXT: .LBB1_5: ; %Flow4
391 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
392 ; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[4:5], 1
393 ; GCN-IR-NEXT: v_or_b32_e32 v4, v7, v1
394 ; GCN-IR-NEXT: v_or_b32_e32 v5, v6, v0
395 ; GCN-IR-NEXT: .LBB1_6: ; %Flow5
396 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
397 ; GCN-IR-NEXT: v_mov_b32_e32 v0, v5
398 ; GCN-IR-NEXT: v_mov_b32_e32 v1, v4
399 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
400 %result = udiv i64 %x, %y
404 define amdgpu_kernel void @s_test_udiv24_64(ptr addrspace(1) %out, i64 %x, i64 %y) {
405 ; GCN-LABEL: s_test_udiv24_64:
407 ; GCN-NEXT: s_load_dword s4, s[0:1], 0xe
408 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
409 ; GCN-NEXT: s_mov_b32 s7, 0xf000
410 ; GCN-NEXT: s_mov_b32 s6, -1
411 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
412 ; GCN-NEXT: s_lshr_b32 s2, s4, 8
413 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
414 ; GCN-NEXT: s_lshr_b32 s2, s3, 8
415 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s2
416 ; GCN-NEXT: s_mov_b32 s4, s0
417 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
418 ; GCN-NEXT: s_mov_b32 s5, s1
419 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
420 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
421 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
422 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
423 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
424 ; GCN-NEXT: v_mov_b32_e32 v1, 0
425 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
426 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
427 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
430 ; GCN-IR-LABEL: s_test_udiv24_64:
432 ; GCN-IR-NEXT: s_load_dword s4, s[0:1], 0xe
433 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
434 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
435 ; GCN-IR-NEXT: s_mov_b32 s6, -1
436 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
437 ; GCN-IR-NEXT: s_lshr_b32 s2, s4, 8
438 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
439 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 8
440 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, s2
441 ; GCN-IR-NEXT: s_mov_b32 s4, s0
442 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
443 ; GCN-IR-NEXT: s_mov_b32 s5, s1
444 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
445 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
446 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
447 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
448 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
449 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
450 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
451 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
452 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
453 ; GCN-IR-NEXT: s_endpgm
456 %result = udiv i64 %1, %2
457 store i64 %result, ptr addrspace(1) %out
461 define i64 @v_test_udiv24_i64(i64 %x, i64 %y) {
462 ; GCN-LABEL: v_test_udiv24_i64:
464 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
465 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v3
466 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, v0
467 ; GCN-NEXT: v_lshrrev_b32_e32 v1, 8, v1
468 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, v1
469 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
470 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
471 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
472 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
473 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
474 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
475 ; GCN-NEXT: v_mov_b32_e32 v1, 0
476 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
477 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
478 ; GCN-NEXT: s_setpc_b64 s[30:31]
480 ; GCN-IR-LABEL: v_test_udiv24_i64:
482 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
483 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v3
484 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, v0
485 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v1, 8, v1
486 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, v1
487 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
488 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
489 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
490 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
491 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
492 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
493 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
494 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
495 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
496 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
499 %result = udiv i64 %1, %2
503 define amdgpu_kernel void @s_test_udiv32_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
504 ; GCN-LABEL: s_test_udiv32_i64:
506 ; GCN-NEXT: s_load_dword s4, s[0:1], 0xe
507 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
508 ; GCN-NEXT: s_mov_b32 s7, 0xf000
509 ; GCN-NEXT: s_mov_b32 s6, -1
510 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
511 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s4
512 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s3
513 ; GCN-NEXT: s_mov_b32 s4, s0
514 ; GCN-NEXT: s_mov_b32 s5, s1
515 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
516 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
517 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
518 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
519 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
520 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
521 ; GCN-NEXT: v_mov_b32_e32 v1, 0
522 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
523 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
526 ; GCN-IR-LABEL: s_test_udiv32_i64:
528 ; GCN-IR-NEXT: s_load_dword s4, s[0:1], 0xe
529 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
530 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
531 ; GCN-IR-NEXT: s_mov_b32 s6, -1
532 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
533 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s4
534 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, s3
535 ; GCN-IR-NEXT: s_mov_b32 s4, s0
536 ; GCN-IR-NEXT: s_mov_b32 s5, s1
537 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
538 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
539 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
540 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
541 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
542 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
543 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
544 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
545 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
546 ; GCN-IR-NEXT: s_endpgm
549 %result = udiv i64 %1, %2
550 store i64 %result, ptr addrspace(1) %out
554 define amdgpu_kernel void @s_test_udiv31_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
555 ; GCN-LABEL: s_test_udiv31_i64:
557 ; GCN-NEXT: s_load_dword s4, s[0:1], 0xe
558 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
559 ; GCN-NEXT: s_mov_b32 s7, 0xf000
560 ; GCN-NEXT: s_mov_b32 s6, -1
561 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
562 ; GCN-NEXT: s_lshr_b32 s2, s4, 1
563 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
564 ; GCN-NEXT: s_lshr_b32 s2, s3, 1
565 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s2
566 ; GCN-NEXT: s_mov_b32 s4, s0
567 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
568 ; GCN-NEXT: s_mov_b32 s5, s1
569 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
570 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
571 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
572 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
573 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
574 ; GCN-NEXT: v_mov_b32_e32 v1, 0
575 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
576 ; GCN-NEXT: v_and_b32_e32 v0, 0x7fffffff, v0
577 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
580 ; GCN-IR-LABEL: s_test_udiv31_i64:
582 ; GCN-IR-NEXT: s_load_dword s4, s[0:1], 0xe
583 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
584 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
585 ; GCN-IR-NEXT: s_mov_b32 s6, -1
586 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
587 ; GCN-IR-NEXT: s_lshr_b32 s2, s4, 1
588 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
589 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 1
590 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, s2
591 ; GCN-IR-NEXT: s_mov_b32 s4, s0
592 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
593 ; GCN-IR-NEXT: s_mov_b32 s5, s1
594 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
595 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
596 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
597 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
598 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
599 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
600 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
601 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0x7fffffff, v0
602 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
603 ; GCN-IR-NEXT: s_endpgm
606 %result = udiv i64 %1, %2
607 store i64 %result, ptr addrspace(1) %out
611 define amdgpu_kernel void @s_test_udiv23_i64(ptr addrspace(1) %out, i64 %x, i64 %y) {
612 ; GCN-LABEL: s_test_udiv23_i64:
614 ; GCN-NEXT: s_load_dword s4, s[0:1], 0xe
615 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
616 ; GCN-NEXT: s_mov_b32 s7, 0xf000
617 ; GCN-NEXT: s_mov_b32 s6, -1
618 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
619 ; GCN-NEXT: s_lshr_b32 s2, s4, 9
620 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
621 ; GCN-NEXT: s_lshr_b32 s2, s3, 9
622 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s2
623 ; GCN-NEXT: s_mov_b32 s4, s0
624 ; GCN-NEXT: v_rcp_iflag_f32_e32 v2, v0
625 ; GCN-NEXT: s_mov_b32 s5, s1
626 ; GCN-NEXT: v_mul_f32_e32 v2, v1, v2
627 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
628 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v2
629 ; GCN-NEXT: v_mad_f32 v1, -v2, v0, v1
630 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
631 ; GCN-NEXT: v_mov_b32_e32 v1, 0
632 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
633 ; GCN-NEXT: v_and_b32_e32 v0, 0x7fffff, v0
634 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
637 ; GCN-IR-LABEL: s_test_udiv23_i64:
639 ; GCN-IR-NEXT: s_load_dword s4, s[0:1], 0xe
640 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
641 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
642 ; GCN-IR-NEXT: s_mov_b32 s6, -1
643 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
644 ; GCN-IR-NEXT: s_lshr_b32 s2, s4, 9
645 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
646 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 9
647 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v1, s2
648 ; GCN-IR-NEXT: s_mov_b32 s4, s0
649 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v2, v0
650 ; GCN-IR-NEXT: s_mov_b32 s5, s1
651 ; GCN-IR-NEXT: v_mul_f32_e32 v2, v1, v2
652 ; GCN-IR-NEXT: v_trunc_f32_e32 v2, v2
653 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v3, v2
654 ; GCN-IR-NEXT: v_mad_f32 v1, -v2, v0, v1
655 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
656 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
657 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v3, vcc
658 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0x7fffff, v0
659 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
660 ; GCN-IR-NEXT: s_endpgm
663 %result = udiv i64 %1, %2
664 store i64 %result, ptr addrspace(1) %out
668 define amdgpu_kernel void @s_test_udiv24_i48(ptr addrspace(1) %out, i48 %x, i48 %y) {
669 ; GCN-LABEL: s_test_udiv24_i48:
671 ; GCN-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
672 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
673 ; GCN-NEXT: v_mov_b32_e32 v2, 0x4f800000
674 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
675 ; GCN-NEXT: s_and_b32 s0, s2, 0xff000000
676 ; GCN-NEXT: s_and_b32 s1, s3, 0xffff
677 ; GCN-NEXT: v_mov_b32_e32 v0, s0
678 ; GCN-NEXT: v_alignbit_b32 v0, s1, v0, 24
679 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, v0
680 ; GCN-NEXT: s_and_b32 s7, s7, 0xffff
681 ; GCN-NEXT: s_and_b32 s6, s6, 0xff000000
682 ; GCN-NEXT: s_lshr_b64 s[0:1], s[0:1], 24
683 ; GCN-NEXT: v_mac_f32_e32 v1, 0, v2
684 ; GCN-NEXT: v_rcp_f32_e32 v1, v1
685 ; GCN-NEXT: s_sub_u32 s8, 0, s0
686 ; GCN-NEXT: s_subb_u32 s9, 0, s1
687 ; GCN-NEXT: s_mov_b32 s3, 0xf000
688 ; GCN-NEXT: v_mul_f32_e32 v1, 0x5f7ffffc, v1
689 ; GCN-NEXT: v_mul_f32_e32 v2, 0x2f800000, v1
690 ; GCN-NEXT: v_trunc_f32_e32 v2, v2
691 ; GCN-NEXT: v_madmk_f32 v1, v2, 0xcf800000, v1
692 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v2
693 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
694 ; GCN-NEXT: s_mov_b32 s2, -1
695 ; GCN-NEXT: s_mov_b32 s0, s4
696 ; GCN-NEXT: v_mul_lo_u32 v3, s8, v2
697 ; GCN-NEXT: v_mul_hi_u32 v4, s8, v1
698 ; GCN-NEXT: v_mul_lo_u32 v5, s9, v1
699 ; GCN-NEXT: v_mul_lo_u32 v6, s8, v1
700 ; GCN-NEXT: s_mov_b32 s1, s5
701 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
702 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
703 ; GCN-NEXT: v_mul_lo_u32 v4, v1, v3
704 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v6
705 ; GCN-NEXT: v_mul_hi_u32 v7, v1, v3
706 ; GCN-NEXT: v_mul_hi_u32 v8, v2, v3
707 ; GCN-NEXT: v_mul_lo_u32 v3, v2, v3
708 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v5, v4
709 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
710 ; GCN-NEXT: v_mul_lo_u32 v7, v2, v6
711 ; GCN-NEXT: v_mul_hi_u32 v6, v2, v6
712 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v7
713 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v5, v6, vcc
714 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v8, vcc
715 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3
716 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v5, vcc
717 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3
718 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v2, v4, vcc
719 ; GCN-NEXT: v_mul_lo_u32 v3, s8, v2
720 ; GCN-NEXT: v_mul_hi_u32 v4, s8, v1
721 ; GCN-NEXT: v_mul_lo_u32 v5, s9, v1
722 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
723 ; GCN-NEXT: v_mul_lo_u32 v4, s8, v1
724 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
725 ; GCN-NEXT: v_mul_lo_u32 v7, v1, v3
726 ; GCN-NEXT: v_mul_hi_u32 v8, v1, v4
727 ; GCN-NEXT: v_mul_hi_u32 v9, v1, v3
728 ; GCN-NEXT: v_mul_hi_u32 v6, v2, v4
729 ; GCN-NEXT: v_mul_lo_u32 v4, v2, v4
730 ; GCN-NEXT: v_mul_hi_u32 v5, v2, v3
731 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v8, v7
732 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v9, vcc
733 ; GCN-NEXT: v_mul_lo_u32 v3, v2, v3
734 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v7, v4
735 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v8, v6, vcc
736 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v5, vcc
737 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3
738 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v5, vcc
739 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3
740 ; GCN-NEXT: v_mov_b32_e32 v3, s6
741 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v2, v4, vcc
742 ; GCN-NEXT: v_alignbit_b32 v3, s7, v3, 24
743 ; GCN-NEXT: v_mul_lo_u32 v4, v3, v2
744 ; GCN-NEXT: v_mul_hi_u32 v1, v3, v1
745 ; GCN-NEXT: v_mul_hi_u32 v2, v3, v2
746 ; GCN-NEXT: v_mov_b32_e32 v5, 0
747 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v4
748 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
749 ; GCN-NEXT: v_add_i32_e32 v1, vcc, 0, v1
750 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
751 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
752 ; GCN-NEXT: v_add_i32_e32 v1, vcc, 0, v1
753 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
754 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v2
755 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v1
756 ; GCN-NEXT: v_add_i32_e32 v4, vcc, 1, v1
757 ; GCN-NEXT: v_mul_lo_u32 v10, v0, v1
758 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v2, vcc
759 ; GCN-NEXT: v_add_i32_e32 v8, vcc, 2, v1
760 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, 0, v2, vcc
761 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v7
762 ; GCN-NEXT: v_sub_i32_e32 v3, vcc, v3, v10
763 ; GCN-NEXT: v_subb_u32_e32 v6, vcc, 0, v6, vcc
764 ; GCN-NEXT: v_sub_i32_e32 v7, vcc, v3, v0
765 ; GCN-NEXT: v_subbrev_u32_e32 v10, vcc, 0, v6, vcc
766 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v7, v0
767 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, vcc
768 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v10
769 ; GCN-NEXT: v_cndmask_b32_e32 v7, -1, v7, vcc
770 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v7
771 ; GCN-NEXT: v_cndmask_b32_e32 v5, v5, v9, vcc
772 ; GCN-NEXT: v_cndmask_b32_e32 v4, v4, v8, vcc
773 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v3, v0
774 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
775 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v6
776 ; GCN-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc
777 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
778 ; GCN-NEXT: v_cndmask_b32_e32 v0, v1, v4, vcc
779 ; GCN-NEXT: v_cndmask_b32_e32 v1, v2, v5, vcc
780 ; GCN-NEXT: buffer_store_short v1, off, s[0:3], 0 offset:4
781 ; GCN-NEXT: buffer_store_dword v0, off, s[0:3], 0
784 ; GCN-IR-LABEL: s_test_udiv24_i48:
785 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
786 ; GCN-IR-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
787 ; GCN-IR-NEXT: s_mov_b32 s11, 0
788 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
789 ; GCN-IR-NEXT: s_and_b32 s3, s5, 0xffff
790 ; GCN-IR-NEXT: s_and_b32 s2, s4, 0xff000000
791 ; GCN-IR-NEXT: s_and_b32 s5, s7, 0xffff
792 ; GCN-IR-NEXT: s_and_b32 s4, s6, 0xff000000
793 ; GCN-IR-NEXT: s_lshr_b64 s[8:9], s[2:3], 24
794 ; GCN-IR-NEXT: s_lshr_b64 s[2:3], s[4:5], 24
795 ; GCN-IR-NEXT: s_and_b32 s9, s9, 0xffff
796 ; GCN-IR-NEXT: s_and_b32 s3, s3, 0xffff
797 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], s[2:3], 0
798 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[8:9], 0
799 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[6:7]
800 ; GCN-IR-NEXT: s_flbit_i32_b32 s4, s2
801 ; GCN-IR-NEXT: s_add_i32 s4, s4, 32
802 ; GCN-IR-NEXT: s_flbit_i32_b32 s5, s3
803 ; GCN-IR-NEXT: s_min_u32 s10, s4, s5
804 ; GCN-IR-NEXT: s_flbit_i32_b32 s4, s8
805 ; GCN-IR-NEXT: s_add_i32 s4, s4, 32
806 ; GCN-IR-NEXT: s_flbit_i32_b32 s5, s9
807 ; GCN-IR-NEXT: s_min_u32 s14, s4, s5
808 ; GCN-IR-NEXT: s_sub_u32 s12, s10, s14
809 ; GCN-IR-NEXT: s_subb_u32 s13, 0, 0
810 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[16:17], s[12:13], 63
811 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[18:19], s[12:13], 63
812 ; GCN-IR-NEXT: s_or_b64 s[16:17], s[6:7], s[16:17]
813 ; GCN-IR-NEXT: s_and_b64 s[6:7], s[16:17], exec
814 ; GCN-IR-NEXT: s_cselect_b32 s7, 0, s9
815 ; GCN-IR-NEXT: s_cselect_b32 s6, 0, s8
816 ; GCN-IR-NEXT: s_or_b64 s[16:17], s[16:17], s[18:19]
817 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0
818 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[16:17]
819 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_5
820 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
821 ; GCN-IR-NEXT: s_add_u32 s16, s12, 1
822 ; GCN-IR-NEXT: s_addc_u32 s17, s13, 0
823 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[16:17], 0
824 ; GCN-IR-NEXT: s_sub_i32 s12, 63, s12
825 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[6:7]
826 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[8:9], s12
827 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_4
828 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
829 ; GCN-IR-NEXT: s_lshr_b64 s[12:13], s[8:9], s16
830 ; GCN-IR-NEXT: s_add_u32 s15, s2, -1
831 ; GCN-IR-NEXT: s_addc_u32 s16, s3, -1
832 ; GCN-IR-NEXT: s_not_b64 s[4:5], s[10:11]
833 ; GCN-IR-NEXT: s_add_u32 s8, s4, s14
834 ; GCN-IR-NEXT: s_addc_u32 s9, s5, 0
835 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
836 ; GCN-IR-NEXT: s_mov_b32 s5, 0
837 ; GCN-IR-NEXT: .LBB7_3: ; %udiv-do-while
838 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
839 ; GCN-IR-NEXT: s_lshl_b64 s[12:13], s[12:13], 1
840 ; GCN-IR-NEXT: s_lshr_b32 s4, s7, 31
841 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
842 ; GCN-IR-NEXT: s_or_b64 s[12:13], s[12:13], s[4:5]
843 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[10:11], s[6:7]
844 ; GCN-IR-NEXT: s_sub_u32 s4, s15, s12
845 ; GCN-IR-NEXT: s_subb_u32 s4, s16, s13
846 ; GCN-IR-NEXT: s_ashr_i32 s10, s4, 31
847 ; GCN-IR-NEXT: s_mov_b32 s11, s10
848 ; GCN-IR-NEXT: s_and_b32 s4, s10, 1
849 ; GCN-IR-NEXT: s_and_b64 s[10:11], s[10:11], s[2:3]
850 ; GCN-IR-NEXT: s_sub_u32 s12, s12, s10
851 ; GCN-IR-NEXT: s_subb_u32 s13, s13, s11
852 ; GCN-IR-NEXT: s_add_u32 s8, s8, 1
853 ; GCN-IR-NEXT: s_addc_u32 s9, s9, 0
854 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[18:19], s[8:9], 0
855 ; GCN-IR-NEXT: s_mov_b64 s[10:11], s[4:5]
856 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[18:19]
857 ; GCN-IR-NEXT: s_cbranch_vccz .LBB7_3
858 ; GCN-IR-NEXT: .LBB7_4: ; %Flow4
859 ; GCN-IR-NEXT: s_lshl_b64 s[2:3], s[6:7], 1
860 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[2:3]
861 ; GCN-IR-NEXT: .LBB7_5: ; %udiv-end
862 ; GCN-IR-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
863 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
864 ; GCN-IR-NEXT: s_mov_b32 s2, -1
865 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s7
866 ; GCN-IR-NEXT: v_mov_b32_e32 v1, s6
867 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
868 ; GCN-IR-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:4
869 ; GCN-IR-NEXT: buffer_store_dword v1, off, s[0:3], 0
870 ; GCN-IR-NEXT: s_endpgm
873 %result = udiv i48 %1, %2
874 store i48 %result, ptr addrspace(1) %out
878 define amdgpu_kernel void @s_test_udiv_k_num_i64(ptr addrspace(1) %out, i64 %x) {
879 ; GCN-LABEL: s_test_udiv_k_num_i64:
881 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
882 ; GCN-NEXT: s_mov_b32 s7, 0xf000
883 ; GCN-NEXT: s_mov_b32 s6, -1
884 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
885 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
886 ; GCN-NEXT: v_cvt_f32_u32_e32 v1, s3
887 ; GCN-NEXT: s_sub_u32 s4, 0, s2
888 ; GCN-NEXT: s_subb_u32 s5, 0, s3
889 ; GCN-NEXT: v_madmk_f32 v0, v1, 0x4f800000, v0
890 ; GCN-NEXT: v_rcp_f32_e32 v0, v0
891 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0
892 ; GCN-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0
893 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
894 ; GCN-NEXT: v_madmk_f32 v0, v1, 0xcf800000, v0
895 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1
896 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0
897 ; GCN-NEXT: v_mul_lo_u32 v2, s4, v1
898 ; GCN-NEXT: v_mul_hi_u32 v3, s4, v0
899 ; GCN-NEXT: v_mul_lo_u32 v5, s5, v0
900 ; GCN-NEXT: v_mul_lo_u32 v4, s4, v0
901 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
902 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v5
903 ; GCN-NEXT: v_mul_hi_u32 v3, v0, v4
904 ; GCN-NEXT: v_mul_lo_u32 v5, v0, v2
905 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v2
906 ; GCN-NEXT: v_mul_hi_u32 v6, v1, v4
907 ; GCN-NEXT: v_mul_lo_u32 v4, v1, v4
908 ; GCN-NEXT: v_mul_hi_u32 v8, v1, v2
909 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
910 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v7, vcc
911 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
912 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v4
913 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v6, vcc
914 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v8, vcc
915 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
916 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
917 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
918 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
919 ; GCN-NEXT: v_mul_lo_u32 v2, s4, v1
920 ; GCN-NEXT: v_mul_hi_u32 v3, s4, v0
921 ; GCN-NEXT: v_mul_lo_u32 v4, s5, v0
922 ; GCN-NEXT: s_mov_b32 s5, s1
923 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
924 ; GCN-NEXT: v_mul_lo_u32 v3, s4, v0
925 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
926 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v2
927 ; GCN-NEXT: v_mul_hi_u32 v7, v0, v3
928 ; GCN-NEXT: v_mul_hi_u32 v8, v0, v2
929 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v3
930 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v3
931 ; GCN-NEXT: v_mul_hi_u32 v4, v1, v2
932 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
933 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
934 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2
935 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v6, v3
936 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v5, vcc
937 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v4, vcc
938 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
939 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
940 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
941 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v1, v3, vcc
942 ; GCN-NEXT: v_mul_lo_u32 v2, v1, 24
943 ; GCN-NEXT: v_mul_hi_u32 v0, v0, 24
944 ; GCN-NEXT: v_mul_hi_u32 v1, v1, 24
945 ; GCN-NEXT: v_mov_b32_e32 v4, s3
946 ; GCN-NEXT: s_mov_b32 s4, s0
947 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2
948 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v1, vcc
949 ; GCN-NEXT: v_mul_lo_u32 v1, s3, v0
950 ; GCN-NEXT: v_mul_hi_u32 v2, s2, v0
951 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v2
952 ; GCN-NEXT: v_mul_lo_u32 v2, s2, v0
953 ; GCN-NEXT: v_sub_i32_e32 v3, vcc, 0, v1
954 ; GCN-NEXT: v_sub_i32_e32 v2, vcc, 24, v2
955 ; GCN-NEXT: v_subb_u32_e64 v3, s[0:1], v3, v4, vcc
956 ; GCN-NEXT: v_subrev_i32_e64 v4, s[0:1], s2, v2
957 ; GCN-NEXT: v_subbrev_u32_e64 v3, s[0:1], 0, v3, s[0:1]
958 ; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s3, v3
959 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, s[0:1]
960 ; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s2, v4
961 ; GCN-NEXT: v_cndmask_b32_e64 v4, 0, -1, s[0:1]
962 ; GCN-NEXT: v_cmp_eq_u32_e64 s[0:1], s3, v3
963 ; GCN-NEXT: v_cndmask_b32_e64 v3, v5, v4, s[0:1]
964 ; GCN-NEXT: v_add_i32_e64 v4, s[0:1], 1, v0
965 ; GCN-NEXT: v_addc_u32_e64 v5, s[0:1], 0, 0, s[0:1]
966 ; GCN-NEXT: v_add_i32_e64 v6, s[0:1], 2, v0
967 ; GCN-NEXT: v_addc_u32_e64 v7, s[0:1], 0, 0, s[0:1]
968 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, 0, v1, vcc
969 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v3
970 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s3, v1
971 ; GCN-NEXT: v_cndmask_b32_e64 v3, v4, v6, s[0:1]
972 ; GCN-NEXT: v_cndmask_b32_e64 v4, v5, v7, s[0:1]
973 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
974 ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s2, v2
975 ; GCN-NEXT: v_cndmask_b32_e64 v2, 0, -1, vcc
976 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s3, v1
977 ; GCN-NEXT: v_cndmask_b32_e32 v1, v5, v2, vcc
978 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v1
979 ; GCN-NEXT: v_cndmask_b32_e32 v1, 0, v4, vcc
980 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
981 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
984 ; GCN-IR-LABEL: s_test_udiv_k_num_i64:
985 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
986 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
987 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0
988 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
989 ; GCN-IR-NEXT: s_flbit_i32_b32 s8, s2
990 ; GCN-IR-NEXT: s_flbit_i32_b32 s9, s3
991 ; GCN-IR-NEXT: s_add_i32 s8, s8, 32
992 ; GCN-IR-NEXT: s_min_u32 s8, s8, s9
993 ; GCN-IR-NEXT: s_add_u32 s10, s8, 0xffffffc5
994 ; GCN-IR-NEXT: s_addc_u32 s11, 0, -1
995 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[2:3], 0
996 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[12:13], s[10:11], 63
997 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[14:15], s[10:11], 63
998 ; GCN-IR-NEXT: s_or_b64 s[12:13], s[6:7], s[12:13]
999 ; GCN-IR-NEXT: s_and_b64 s[6:7], s[12:13], exec
1000 ; GCN-IR-NEXT: s_cselect_b32 s6, 0, 24
1001 ; GCN-IR-NEXT: s_or_b64 s[12:13], s[12:13], s[14:15]
1002 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[12:13]
1003 ; GCN-IR-NEXT: s_mov_b32 s7, 0
1004 ; GCN-IR-NEXT: s_cbranch_vccz .LBB8_5
1005 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1006 ; GCN-IR-NEXT: s_add_u32 s12, s10, 1
1007 ; GCN-IR-NEXT: s_addc_u32 s13, s11, 0
1008 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[12:13], 0
1009 ; GCN-IR-NEXT: s_sub_i32 s9, 63, s10
1010 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[6:7]
1011 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], 24, s9
1012 ; GCN-IR-NEXT: s_cbranch_vccz .LBB8_4
1013 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1014 ; GCN-IR-NEXT: s_lshr_b64 s[10:11], 24, s12
1015 ; GCN-IR-NEXT: s_add_u32 s14, s2, -1
1016 ; GCN-IR-NEXT: s_addc_u32 s15, s3, -1
1017 ; GCN-IR-NEXT: s_sub_u32 s8, 58, s8
1018 ; GCN-IR-NEXT: s_subb_u32 s9, 0, 0
1019 ; GCN-IR-NEXT: s_mov_b64 s[12:13], 0
1020 ; GCN-IR-NEXT: s_mov_b32 s5, 0
1021 ; GCN-IR-NEXT: .LBB8_3: ; %udiv-do-while
1022 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1023 ; GCN-IR-NEXT: s_lshl_b64 s[10:11], s[10:11], 1
1024 ; GCN-IR-NEXT: s_lshr_b32 s4, s7, 31
1025 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
1026 ; GCN-IR-NEXT: s_or_b64 s[10:11], s[10:11], s[4:5]
1027 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[12:13], s[6:7]
1028 ; GCN-IR-NEXT: s_sub_u32 s4, s14, s10
1029 ; GCN-IR-NEXT: s_subb_u32 s4, s15, s11
1030 ; GCN-IR-NEXT: s_ashr_i32 s12, s4, 31
1031 ; GCN-IR-NEXT: s_mov_b32 s13, s12
1032 ; GCN-IR-NEXT: s_and_b32 s4, s12, 1
1033 ; GCN-IR-NEXT: s_and_b64 s[12:13], s[12:13], s[2:3]
1034 ; GCN-IR-NEXT: s_sub_u32 s10, s10, s12
1035 ; GCN-IR-NEXT: s_subb_u32 s11, s11, s13
1036 ; GCN-IR-NEXT: s_add_u32 s8, s8, 1
1037 ; GCN-IR-NEXT: s_addc_u32 s9, s9, 0
1038 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[16:17], s[8:9], 0
1039 ; GCN-IR-NEXT: s_mov_b64 s[12:13], s[4:5]
1040 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[16:17]
1041 ; GCN-IR-NEXT: s_cbranch_vccz .LBB8_3
1042 ; GCN-IR-NEXT: .LBB8_4: ; %Flow6
1043 ; GCN-IR-NEXT: s_lshl_b64 s[2:3], s[6:7], 1
1044 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[2:3]
1045 ; GCN-IR-NEXT: .LBB8_5: ; %udiv-end
1046 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s6
1047 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
1048 ; GCN-IR-NEXT: s_mov_b32 s2, -1
1049 ; GCN-IR-NEXT: v_mov_b32_e32 v1, s7
1050 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1051 ; GCN-IR-NEXT: s_endpgm
1052 %result = udiv i64 24, %x
1053 store i64 %result, ptr addrspace(1) %out
1057 ; define i64 @v_test_udiv_k_num_i64(i64 %x) {
1058 ; %result = udiv i64 24, %x
1062 define i64 @v_test_udiv_pow2_k_num_i64(i64 %x) {
1063 ; GCN-LABEL: v_test_udiv_pow2_k_num_i64:
1065 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1066 ; GCN-NEXT: v_cvt_f32_u32_e32 v2, v0
1067 ; GCN-NEXT: v_cvt_f32_u32_e32 v3, v1
1068 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, 0, v0
1069 ; GCN-NEXT: v_subb_u32_e32 v5, vcc, 0, v1, vcc
1070 ; GCN-NEXT: v_madmk_f32 v2, v3, 0x4f800000, v2
1071 ; GCN-NEXT: v_rcp_f32_e32 v2, v2
1072 ; GCN-NEXT: v_mul_f32_e32 v2, 0x5f7ffffc, v2
1073 ; GCN-NEXT: v_mul_f32_e32 v3, 0x2f800000, v2
1074 ; GCN-NEXT: v_trunc_f32_e32 v3, v3
1075 ; GCN-NEXT: v_madmk_f32 v2, v3, 0xcf800000, v2
1076 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v3
1077 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v2
1078 ; GCN-NEXT: v_mul_lo_u32 v6, v4, v3
1079 ; GCN-NEXT: v_mul_hi_u32 v7, v4, v2
1080 ; GCN-NEXT: v_mul_lo_u32 v8, v5, v2
1081 ; GCN-NEXT: v_mul_lo_u32 v9, v4, v2
1082 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1083 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v8
1084 ; GCN-NEXT: v_mul_hi_u32 v7, v2, v9
1085 ; GCN-NEXT: v_mul_lo_u32 v8, v2, v6
1086 ; GCN-NEXT: v_mul_hi_u32 v10, v2, v6
1087 ; GCN-NEXT: v_mul_hi_u32 v11, v3, v6
1088 ; GCN-NEXT: v_mul_lo_u32 v6, v3, v6
1089 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v7, v8
1090 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v10, vcc
1091 ; GCN-NEXT: v_mul_lo_u32 v10, v3, v9
1092 ; GCN-NEXT: v_mul_hi_u32 v9, v3, v9
1093 ; GCN-NEXT: v_add_i32_e32 v7, vcc, v7, v10
1094 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, v8, v9, vcc
1095 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v11, vcc
1096 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1097 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v8, vcc
1098 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v6
1099 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v3, v7, vcc
1100 ; GCN-NEXT: v_mul_lo_u32 v6, v4, v3
1101 ; GCN-NEXT: v_mul_hi_u32 v7, v4, v2
1102 ; GCN-NEXT: v_mul_lo_u32 v5, v5, v2
1103 ; GCN-NEXT: v_mul_lo_u32 v4, v4, v2
1104 ; GCN-NEXT: v_add_i32_e32 v6, vcc, v7, v6
1105 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v6, v5
1106 ; GCN-NEXT: v_mul_lo_u32 v8, v2, v5
1107 ; GCN-NEXT: v_mul_hi_u32 v9, v2, v4
1108 ; GCN-NEXT: v_mul_hi_u32 v10, v2, v5
1109 ; GCN-NEXT: v_mul_hi_u32 v7, v3, v4
1110 ; GCN-NEXT: v_mul_lo_u32 v4, v3, v4
1111 ; GCN-NEXT: v_mul_hi_u32 v6, v3, v5
1112 ; GCN-NEXT: v_add_i32_e32 v8, vcc, v9, v8
1113 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, 0, v10, vcc
1114 ; GCN-NEXT: v_mul_lo_u32 v5, v3, v5
1115 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v8, v4
1116 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v9, v7, vcc
1117 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
1118 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v5
1119 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
1120 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
1121 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v3, v5, vcc
1122 ; GCN-NEXT: v_lshrrev_b32_e32 v2, 17, v2
1123 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v2
1124 ; GCN-NEXT: v_mul_hi_u32 v4, v0, v2
1125 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3
1126 ; GCN-NEXT: v_mul_lo_u32 v4, v0, v2
1127 ; GCN-NEXT: v_sub_i32_e32 v5, vcc, 0, v3
1128 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, 0x8000, v4
1129 ; GCN-NEXT: v_subb_u32_e64 v5, s[4:5], v5, v1, vcc
1130 ; GCN-NEXT: v_sub_i32_e64 v6, s[4:5], v4, v0
1131 ; GCN-NEXT: v_subbrev_u32_e64 v5, s[4:5], 0, v5, s[4:5]
1132 ; GCN-NEXT: v_cmp_ge_u32_e64 s[4:5], v5, v1
1133 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[4:5]
1134 ; GCN-NEXT: v_cmp_ge_u32_e64 s[4:5], v6, v0
1135 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, s[4:5]
1136 ; GCN-NEXT: v_cmp_eq_u32_e64 s[4:5], v5, v1
1137 ; GCN-NEXT: v_cndmask_b32_e64 v5, v7, v6, s[4:5]
1138 ; GCN-NEXT: v_add_i32_e64 v6, s[4:5], 2, v2
1139 ; GCN-NEXT: v_addc_u32_e64 v7, s[4:5], 0, 0, s[4:5]
1140 ; GCN-NEXT: v_add_i32_e64 v8, s[4:5], 1, v2
1141 ; GCN-NEXT: v_addc_u32_e64 v9, s[4:5], 0, 0, s[4:5]
1142 ; GCN-NEXT: v_subb_u32_e32 v3, vcc, 0, v3, vcc
1143 ; GCN-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, v5
1144 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v3, v1
1145 ; GCN-NEXT: v_cndmask_b32_e64 v5, v8, v6, s[4:5]
1146 ; GCN-NEXT: v_cndmask_b32_e64 v6, 0, -1, vcc
1147 ; GCN-NEXT: v_cmp_ge_u32_e32 vcc, v4, v0
1148 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
1149 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, v3, v1
1150 ; GCN-NEXT: v_cndmask_b32_e32 v0, v6, v0, vcc
1151 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
1152 ; GCN-NEXT: v_cndmask_b32_e64 v1, v9, v7, s[4:5]
1153 ; GCN-NEXT: v_cndmask_b32_e32 v0, v2, v5, vcc
1154 ; GCN-NEXT: v_cndmask_b32_e32 v1, 0, v1, vcc
1155 ; GCN-NEXT: s_setpc_b64 s[30:31]
1157 ; GCN-IR-LABEL: v_test_udiv_pow2_k_num_i64:
1158 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1159 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1160 ; GCN-IR-NEXT: v_ffbh_u32_e32 v2, v0
1161 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, 32, v2
1162 ; GCN-IR-NEXT: v_ffbh_u32_e32 v3, v1
1163 ; GCN-IR-NEXT: v_min_u32_e32 v6, v2, v3
1164 ; GCN-IR-NEXT: v_add_i32_e32 v4, vcc, 0xffffffd0, v6
1165 ; GCN-IR-NEXT: v_addc_u32_e64 v5, s[6:7], 0, -1, vcc
1166 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], 0, v[0:1]
1167 ; GCN-IR-NEXT: v_cmp_lt_u64_e32 vcc, 63, v[4:5]
1168 ; GCN-IR-NEXT: v_cmp_ne_u64_e64 s[6:7], 63, v[4:5]
1169 ; GCN-IR-NEXT: v_mov_b32_e32 v3, 0x8000
1170 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], vcc
1171 ; GCN-IR-NEXT: v_cndmask_b32_e64 v3, v3, 0, s[4:5]
1172 ; GCN-IR-NEXT: s_xor_b64 s[4:5], s[4:5], -1
1173 ; GCN-IR-NEXT: v_mov_b32_e32 v2, 0
1174 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[4:5], s[6:7]
1175 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
1176 ; GCN-IR-NEXT: s_cbranch_execz .LBB9_6
1177 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1178 ; GCN-IR-NEXT: v_add_i32_e32 v7, vcc, 1, v4
1179 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 63, v4
1180 ; GCN-IR-NEXT: v_addc_u32_e32 v8, vcc, 0, v5, vcc
1181 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0x8000
1182 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[7:8]
1183 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], s[4:5], v2
1184 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0
1185 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1186 ; GCN-IR-NEXT: s_and_saveexec_b64 s[8:9], vcc
1187 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[8:9]
1188 ; GCN-IR-NEXT: s_cbranch_execz .LBB9_5
1189 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1190 ; GCN-IR-NEXT: v_add_i32_e32 v12, vcc, -1, v0
1191 ; GCN-IR-NEXT: v_addc_u32_e32 v13, vcc, -1, v1, vcc
1192 ; GCN-IR-NEXT: v_lshr_b64 v[8:9], s[4:5], v7
1193 ; GCN-IR-NEXT: v_sub_i32_e32 v6, vcc, 47, v6
1194 ; GCN-IR-NEXT: v_mov_b32_e32 v10, 0
1195 ; GCN-IR-NEXT: v_subb_u32_e64 v7, s[4:5], 0, 0, vcc
1196 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1197 ; GCN-IR-NEXT: v_mov_b32_e32 v11, 0
1198 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1199 ; GCN-IR-NEXT: .LBB9_3: ; %udiv-do-while
1200 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1201 ; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1
1202 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v3
1203 ; GCN-IR-NEXT: v_or_b32_e32 v8, v8, v4
1204 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1205 ; GCN-IR-NEXT: v_sub_i32_e32 v4, vcc, v12, v8
1206 ; GCN-IR-NEXT: v_subb_u32_e32 v4, vcc, v13, v9, vcc
1207 ; GCN-IR-NEXT: v_or_b32_e32 v2, v10, v2
1208 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v4
1209 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, 1, v6
1210 ; GCN-IR-NEXT: v_or_b32_e32 v3, v11, v3
1211 ; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v10
1212 ; GCN-IR-NEXT: v_and_b32_e32 v11, v10, v1
1213 ; GCN-IR-NEXT: v_and_b32_e32 v10, v10, v0
1214 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, 0, v7, vcc
1215 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[6:7]
1216 ; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v8, v10
1217 ; GCN-IR-NEXT: v_subb_u32_e64 v9, s[4:5], v9, v11, s[4:5]
1218 ; GCN-IR-NEXT: v_mov_b32_e32 v11, v5
1219 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
1220 ; GCN-IR-NEXT: v_mov_b32_e32 v10, v4
1221 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
1222 ; GCN-IR-NEXT: s_cbranch_execnz .LBB9_3
1223 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
1224 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
1225 ; GCN-IR-NEXT: .LBB9_5: ; %Flow4
1226 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
1227 ; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[2:3], 1
1228 ; GCN-IR-NEXT: v_or_b32_e32 v2, v5, v1
1229 ; GCN-IR-NEXT: v_or_b32_e32 v3, v4, v0
1230 ; GCN-IR-NEXT: .LBB9_6: ; %Flow5
1231 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
1232 ; GCN-IR-NEXT: v_mov_b32_e32 v0, v3
1233 ; GCN-IR-NEXT: v_mov_b32_e32 v1, v2
1234 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1235 %result = udiv i64 32768, %x
1239 define i64 @v_test_udiv_pow2_k_den_i64(i64 %x) {
1240 ; GCN-LABEL: v_test_udiv_pow2_k_den_i64:
1242 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1243 ; GCN-NEXT: v_alignbit_b32 v0, v1, v0, 15
1244 ; GCN-NEXT: v_lshrrev_b32_e32 v1, 15, v1
1245 ; GCN-NEXT: s_setpc_b64 s[30:31]
1247 ; GCN-IR-LABEL: v_test_udiv_pow2_k_den_i64:
1248 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1249 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1250 ; GCN-IR-NEXT: v_ffbh_u32_e32 v2, v0
1251 ; GCN-IR-NEXT: v_add_i32_e64 v2, s[4:5], 32, v2
1252 ; GCN-IR-NEXT: v_ffbh_u32_e32 v3, v1
1253 ; GCN-IR-NEXT: v_min_u32_e32 v6, v2, v3
1254 ; GCN-IR-NEXT: v_sub_i32_e64 v4, s[4:5], 48, v6
1255 ; GCN-IR-NEXT: v_subb_u32_e64 v5, s[4:5], 0, 0, s[4:5]
1256 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
1257 ; GCN-IR-NEXT: v_cmp_lt_u64_e64 s[4:5], 63, v[4:5]
1258 ; GCN-IR-NEXT: s_or_b64 s[4:5], vcc, s[4:5]
1259 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 63, v[4:5]
1260 ; GCN-IR-NEXT: s_xor_b64 s[6:7], s[4:5], -1
1261 ; GCN-IR-NEXT: v_cndmask_b32_e64 v2, v1, 0, s[4:5]
1262 ; GCN-IR-NEXT: v_cndmask_b32_e64 v3, v0, 0, s[4:5]
1263 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[6:7], vcc
1264 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
1265 ; GCN-IR-NEXT: s_cbranch_execz .LBB10_6
1266 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1267 ; GCN-IR-NEXT: v_add_i32_e32 v7, vcc, 1, v4
1268 ; GCN-IR-NEXT: v_addc_u32_e32 v8, vcc, 0, v5, vcc
1269 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 63, v4
1270 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[7:8]
1271 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[0:1], v2
1272 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0
1273 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1274 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc
1275 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[4:5]
1276 ; GCN-IR-NEXT: s_cbranch_execz .LBB10_5
1277 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1278 ; GCN-IR-NEXT: v_lshr_b64 v[7:8], v[0:1], v7
1279 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, 0xffffffcf, v6
1280 ; GCN-IR-NEXT: v_mov_b32_e32 v9, 0
1281 ; GCN-IR-NEXT: v_addc_u32_e64 v1, s[4:5], 0, -1, vcc
1282 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1283 ; GCN-IR-NEXT: v_mov_b32_e32 v10, 0
1284 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1285 ; GCN-IR-NEXT: s_movk_i32 s12, 0x7fff
1286 ; GCN-IR-NEXT: .LBB10_3: ; %udiv-do-while
1287 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1288 ; GCN-IR-NEXT: v_lshl_b64 v[7:8], v[7:8], 1
1289 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v3
1290 ; GCN-IR-NEXT: v_or_b32_e32 v6, v7, v4
1291 ; GCN-IR-NEXT: v_sub_i32_e32 v4, vcc, s12, v6
1292 ; GCN-IR-NEXT: v_subb_u32_e32 v4, vcc, 0, v8, vcc
1293 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, 1, v0
1294 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1295 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v7, 31, v4
1296 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
1297 ; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v7
1298 ; GCN-IR-NEXT: v_and_b32_e32 v7, 0x8000, v7
1299 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
1300 ; GCN-IR-NEXT: v_or_b32_e32 v3, v10, v3
1301 ; GCN-IR-NEXT: v_or_b32_e32 v2, v9, v2
1302 ; GCN-IR-NEXT: v_sub_i32_e64 v7, s[4:5], v6, v7
1303 ; GCN-IR-NEXT: v_mov_b32_e32 v10, v5
1304 ; GCN-IR-NEXT: v_subbrev_u32_e64 v8, s[4:5], 0, v8, s[4:5]
1305 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
1306 ; GCN-IR-NEXT: v_mov_b32_e32 v9, v4
1307 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
1308 ; GCN-IR-NEXT: s_cbranch_execnz .LBB10_3
1309 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
1310 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
1311 ; GCN-IR-NEXT: .LBB10_5: ; %Flow4
1312 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
1313 ; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[2:3], 1
1314 ; GCN-IR-NEXT: v_or_b32_e32 v2, v5, v1
1315 ; GCN-IR-NEXT: v_or_b32_e32 v3, v4, v0
1316 ; GCN-IR-NEXT: .LBB10_6: ; %Flow5
1317 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
1318 ; GCN-IR-NEXT: v_mov_b32_e32 v0, v3
1319 ; GCN-IR-NEXT: v_mov_b32_e32 v1, v2
1320 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1321 %result = udiv i64 %x, 32768
1325 define amdgpu_kernel void @s_test_udiv_k_den_i64(ptr addrspace(1) %out, i64 %x) {
1326 ; GCN-LABEL: s_test_udiv_k_den_i64:
1328 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1329 ; GCN-NEXT: s_add_u32 s1, 0, 0xaaaa0000
1330 ; GCN-NEXT: v_mov_b32_e32 v0, 0xffffffe8
1331 ; GCN-NEXT: v_mul_hi_u32 v0, s1, v0
1332 ; GCN-NEXT: s_addc_u32 s8, 0, 42
1333 ; GCN-NEXT: s_add_i32 s8, s8, 0xaaaaa80
1334 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
1335 ; GCN-NEXT: s_mov_b32 s0, s4
1336 ; GCN-NEXT: s_mul_i32 s4, s1, 0xffffffe8
1337 ; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s1, v0
1338 ; GCN-NEXT: s_mul_i32 s9, s8, 0xffffffe8
1339 ; GCN-NEXT: v_mov_b32_e32 v1, s4
1340 ; GCN-NEXT: v_add_i32_e32 v0, vcc, s9, v0
1341 ; GCN-NEXT: v_mul_hi_u32 v2, s8, v1
1342 ; GCN-NEXT: v_mul_lo_u32 v3, s1, v0
1343 ; GCN-NEXT: v_mul_hi_u32 v1, s1, v1
1344 ; GCN-NEXT: v_mul_hi_u32 v4, s1, v0
1345 ; GCN-NEXT: s_mul_i32 s4, s8, s4
1346 ; GCN-NEXT: s_mov_b32 s3, 0xf000
1347 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3
1348 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
1349 ; GCN-NEXT: v_mul_hi_u32 v4, s8, v0
1350 ; GCN-NEXT: v_mul_lo_u32 v0, s8, v0
1351 ; GCN-NEXT: v_add_i32_e32 v1, vcc, s4, v1
1352 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v3, v2, vcc
1353 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v4, vcc
1354 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0
1355 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
1356 ; GCN-NEXT: v_mov_b32_e32 v2, s8
1357 ; GCN-NEXT: v_add_i32_e32 v0, vcc, s1, v0
1358 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, v2, v1, vcc
1359 ; GCN-NEXT: v_mul_lo_u32 v2, s6, v1
1360 ; GCN-NEXT: v_mul_hi_u32 v3, s6, v0
1361 ; GCN-NEXT: v_mul_hi_u32 v4, s6, v1
1362 ; GCN-NEXT: v_mul_hi_u32 v5, s7, v1
1363 ; GCN-NEXT: v_mul_lo_u32 v1, s7, v1
1364 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
1365 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
1366 ; GCN-NEXT: v_mul_lo_u32 v4, s7, v0
1367 ; GCN-NEXT: v_mul_hi_u32 v0, s7, v0
1368 ; GCN-NEXT: s_mov_b32 s2, -1
1369 ; GCN-NEXT: s_mov_b32 s1, s5
1370 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v4
1371 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc
1372 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
1373 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1374 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc
1375 ; GCN-NEXT: v_mul_lo_u32 v4, v1, 24
1376 ; GCN-NEXT: v_mul_hi_u32 v5, v0, 24
1377 ; GCN-NEXT: v_add_i32_e32 v2, vcc, 1, v0
1378 ; GCN-NEXT: v_mul_lo_u32 v8, v0, 24
1379 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
1380 ; GCN-NEXT: v_add_i32_e32 v6, vcc, 2, v0
1381 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
1382 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v5
1383 ; GCN-NEXT: v_mov_b32_e32 v5, s7
1384 ; GCN-NEXT: v_sub_i32_e32 v8, vcc, s6, v8
1385 ; GCN-NEXT: v_subb_u32_e32 v4, vcc, v5, v4, vcc
1386 ; GCN-NEXT: v_subrev_i32_e32 v5, vcc, 24, v8
1387 ; GCN-NEXT: v_subbrev_u32_e32 v9, vcc, 0, v4, vcc
1388 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 23, v5
1389 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
1390 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v9
1391 ; GCN-NEXT: v_cndmask_b32_e32 v5, -1, v5, vcc
1392 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5
1393 ; GCN-NEXT: v_cndmask_b32_e32 v2, v2, v6, vcc
1394 ; GCN-NEXT: v_cndmask_b32_e32 v3, v3, v7, vcc
1395 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 23, v8
1396 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc
1397 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v4
1398 ; GCN-NEXT: v_cndmask_b32_e32 v4, -1, v5, vcc
1399 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
1400 ; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
1401 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
1402 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1403 ; GCN-NEXT: s_endpgm
1405 ; GCN-IR-LABEL: s_test_udiv_k_den_i64:
1406 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1407 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
1408 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1409 ; GCN-IR-NEXT: s_flbit_i32_b32 s6, s2
1410 ; GCN-IR-NEXT: s_flbit_i32_b32 s7, s3
1411 ; GCN-IR-NEXT: s_add_i32 s6, s6, 32
1412 ; GCN-IR-NEXT: s_min_u32 s10, s6, s7
1413 ; GCN-IR-NEXT: s_sub_u32 s8, 59, s10
1414 ; GCN-IR-NEXT: s_subb_u32 s9, 0, 0
1415 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[4:5], s[2:3], 0
1416 ; GCN-IR-NEXT: v_cmp_gt_u64_e64 s[6:7], s[8:9], 63
1417 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[12:13], s[8:9], 63
1418 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[6:7]
1419 ; GCN-IR-NEXT: s_and_b64 s[6:7], s[4:5], exec
1420 ; GCN-IR-NEXT: s_cselect_b32 s7, 0, s3
1421 ; GCN-IR-NEXT: s_cselect_b32 s6, 0, s2
1422 ; GCN-IR-NEXT: s_or_b64 s[4:5], s[4:5], s[12:13]
1423 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[4:5]
1424 ; GCN-IR-NEXT: s_mov_b64 s[4:5], 0
1425 ; GCN-IR-NEXT: s_cbranch_vccz .LBB11_5
1426 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1427 ; GCN-IR-NEXT: s_add_u32 s12, s8, 1
1428 ; GCN-IR-NEXT: s_addc_u32 s13, s9, 0
1429 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[6:7], s[12:13], 0
1430 ; GCN-IR-NEXT: s_sub_i32 s8, 63, s8
1431 ; GCN-IR-NEXT: s_andn2_b64 vcc, exec, s[6:7]
1432 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[2:3], s8
1433 ; GCN-IR-NEXT: s_cbranch_vccz .LBB11_4
1434 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1435 ; GCN-IR-NEXT: s_lshr_b64 s[8:9], s[2:3], s12
1436 ; GCN-IR-NEXT: s_add_u32 s2, s10, 0xffffffc4
1437 ; GCN-IR-NEXT: s_addc_u32 s3, 0, -1
1438 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1439 ; GCN-IR-NEXT: s_mov_b32 s5, 0
1440 ; GCN-IR-NEXT: .LBB11_3: ; %udiv-do-while
1441 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1442 ; GCN-IR-NEXT: s_lshl_b64 s[8:9], s[8:9], 1
1443 ; GCN-IR-NEXT: s_lshr_b32 s4, s7, 31
1444 ; GCN-IR-NEXT: s_lshl_b64 s[6:7], s[6:7], 1
1445 ; GCN-IR-NEXT: s_or_b64 s[8:9], s[8:9], s[4:5]
1446 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[10:11], s[6:7]
1447 ; GCN-IR-NEXT: s_sub_u32 s4, 23, s8
1448 ; GCN-IR-NEXT: s_subb_u32 s4, 0, s9
1449 ; GCN-IR-NEXT: s_ashr_i32 s10, s4, 31
1450 ; GCN-IR-NEXT: s_and_b32 s4, s10, 1
1451 ; GCN-IR-NEXT: s_and_b32 s10, s10, 24
1452 ; GCN-IR-NEXT: s_sub_u32 s8, s8, s10
1453 ; GCN-IR-NEXT: s_subb_u32 s9, s9, 0
1454 ; GCN-IR-NEXT: s_add_u32 s2, s2, 1
1455 ; GCN-IR-NEXT: s_addc_u32 s3, s3, 0
1456 ; GCN-IR-NEXT: v_cmp_eq_u64_e64 s[12:13], s[2:3], 0
1457 ; GCN-IR-NEXT: s_mov_b64 s[10:11], s[4:5]
1458 ; GCN-IR-NEXT: s_and_b64 vcc, exec, s[12:13]
1459 ; GCN-IR-NEXT: s_cbranch_vccz .LBB11_3
1460 ; GCN-IR-NEXT: .LBB11_4: ; %Flow6
1461 ; GCN-IR-NEXT: s_lshl_b64 s[2:3], s[6:7], 1
1462 ; GCN-IR-NEXT: s_or_b64 s[6:7], s[4:5], s[2:3]
1463 ; GCN-IR-NEXT: .LBB11_5: ; %udiv-end
1464 ; GCN-IR-NEXT: v_mov_b32_e32 v0, s6
1465 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
1466 ; GCN-IR-NEXT: s_mov_b32 s2, -1
1467 ; GCN-IR-NEXT: v_mov_b32_e32 v1, s7
1468 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1469 ; GCN-IR-NEXT: s_endpgm
1470 %result = udiv i64 %x, 24
1471 store i64 %result, ptr addrspace(1) %out
1475 define i64 @v_test_udiv_k_den_i64(i64 %x) {
1476 ; GCN-LABEL: v_test_udiv_k_den_i64:
1478 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1479 ; GCN-NEXT: s_add_u32 s4, 0, 0xaaaa0000
1480 ; GCN-NEXT: v_mov_b32_e32 v2, 0xffffffe8
1481 ; GCN-NEXT: v_mul_hi_u32 v2, s4, v2
1482 ; GCN-NEXT: s_addc_u32 s5, 0, 42
1483 ; GCN-NEXT: s_add_i32 s5, s5, 0xaaaaa80
1484 ; GCN-NEXT: s_mul_i32 s6, s4, 0xffffffe8
1485 ; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s4, v2
1486 ; GCN-NEXT: s_mul_i32 s7, s5, 0xffffffe8
1487 ; GCN-NEXT: v_mov_b32_e32 v3, s6
1488 ; GCN-NEXT: v_add_i32_e32 v2, vcc, s7, v2
1489 ; GCN-NEXT: v_mul_hi_u32 v4, s5, v3
1490 ; GCN-NEXT: v_mul_lo_u32 v5, s4, v2
1491 ; GCN-NEXT: v_mul_hi_u32 v3, s4, v3
1492 ; GCN-NEXT: v_mul_hi_u32 v6, s4, v2
1493 ; GCN-NEXT: s_mul_i32 s6, s5, s6
1494 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5
1495 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
1496 ; GCN-NEXT: v_mul_hi_u32 v6, s5, v2
1497 ; GCN-NEXT: v_mul_lo_u32 v2, s5, v2
1498 ; GCN-NEXT: v_add_i32_e32 v3, vcc, s6, v3
1499 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v4, vcc
1500 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v6, vcc
1501 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2
1502 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
1503 ; GCN-NEXT: v_mov_b32_e32 v4, s5
1504 ; GCN-NEXT: v_add_i32_e32 v2, vcc, s4, v2
1505 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v4, v3, vcc
1506 ; GCN-NEXT: v_mul_lo_u32 v4, v0, v3
1507 ; GCN-NEXT: v_mul_hi_u32 v5, v0, v2
1508 ; GCN-NEXT: v_mul_hi_u32 v6, v0, v3
1509 ; GCN-NEXT: v_mul_hi_u32 v7, v1, v3
1510 ; GCN-NEXT: v_mul_lo_u32 v3, v1, v3
1511 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v5, v4
1512 ; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc
1513 ; GCN-NEXT: v_mul_lo_u32 v6, v1, v2
1514 ; GCN-NEXT: v_mul_hi_u32 v2, v1, v2
1515 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v6
1516 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v5, v2, vcc
1517 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v7, vcc
1518 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3
1519 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v4, vcc
1520 ; GCN-NEXT: v_mul_lo_u32 v4, v3, 24
1521 ; GCN-NEXT: v_mul_hi_u32 v5, v2, 24
1522 ; GCN-NEXT: v_mul_lo_u32 v6, v2, 24
1523 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v5, v4
1524 ; GCN-NEXT: v_sub_i32_e32 v0, vcc, v0, v6
1525 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v1, v4, vcc
1526 ; GCN-NEXT: v_subrev_i32_e32 v4, vcc, 24, v0
1527 ; GCN-NEXT: v_subbrev_u32_e32 v5, vcc, 0, v1, vcc
1528 ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, 23, v4
1529 ; GCN-NEXT: v_cndmask_b32_e64 v4, 0, -1, vcc
1530 ; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 0, v5
1531 ; GCN-NEXT: v_cndmask_b32_e32 v4, -1, v4, vcc
1532 ; GCN-NEXT: v_add_i32_e32 v5, vcc, 2, v2
1533 ; GCN-NEXT: v_addc_u32_e32 v6, vcc, 0, v3, vcc
1534 ; GCN-NEXT: v_add_i32_e32 v7, vcc, 1, v2
1535 ; GCN-NEXT: v_cmp_lt_u32_e64 s[4:5], 23, v0
1536 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, 0, v3, vcc
1537 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, s[4:5]
1538 ; GCN-NEXT: v_cmp_eq_u32_e64 s[4:5], 0, v1
1539 ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
1540 ; GCN-NEXT: v_cndmask_b32_e64 v0, -1, v0, s[4:5]
1541 ; GCN-NEXT: v_cndmask_b32_e32 v4, v7, v5, vcc
1542 ; GCN-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, v0
1543 ; GCN-NEXT: v_cndmask_b32_e32 v1, v8, v6, vcc
1544 ; GCN-NEXT: v_cndmask_b32_e64 v0, v2, v4, s[4:5]
1545 ; GCN-NEXT: v_cndmask_b32_e64 v1, v3, v1, s[4:5]
1546 ; GCN-NEXT: s_setpc_b64 s[30:31]
1548 ; GCN-IR-LABEL: v_test_udiv_k_den_i64:
1549 ; GCN-IR: ; %bb.0: ; %_udiv-special-cases
1550 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1551 ; GCN-IR-NEXT: v_ffbh_u32_e32 v2, v0
1552 ; GCN-IR-NEXT: v_add_i32_e64 v2, s[4:5], 32, v2
1553 ; GCN-IR-NEXT: v_ffbh_u32_e32 v3, v1
1554 ; GCN-IR-NEXT: v_min_u32_e32 v6, v2, v3
1555 ; GCN-IR-NEXT: v_sub_i32_e64 v4, s[4:5], 59, v6
1556 ; GCN-IR-NEXT: v_subb_u32_e64 v5, s[4:5], 0, 0, s[4:5]
1557 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
1558 ; GCN-IR-NEXT: v_cmp_lt_u64_e64 s[4:5], 63, v[4:5]
1559 ; GCN-IR-NEXT: s_or_b64 s[4:5], vcc, s[4:5]
1560 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 63, v[4:5]
1561 ; GCN-IR-NEXT: s_xor_b64 s[6:7], s[4:5], -1
1562 ; GCN-IR-NEXT: v_cndmask_b32_e64 v2, v1, 0, s[4:5]
1563 ; GCN-IR-NEXT: v_cndmask_b32_e64 v3, v0, 0, s[4:5]
1564 ; GCN-IR-NEXT: s_and_b64 s[4:5], s[6:7], vcc
1565 ; GCN-IR-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
1566 ; GCN-IR-NEXT: s_cbranch_execz .LBB12_6
1567 ; GCN-IR-NEXT: ; %bb.1: ; %udiv-bb1
1568 ; GCN-IR-NEXT: v_add_i32_e32 v7, vcc, 1, v4
1569 ; GCN-IR-NEXT: v_addc_u32_e32 v8, vcc, 0, v5, vcc
1570 ; GCN-IR-NEXT: v_sub_i32_e64 v2, s[4:5], 63, v4
1571 ; GCN-IR-NEXT: v_cmp_ne_u64_e32 vcc, 0, v[7:8]
1572 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[0:1], v2
1573 ; GCN-IR-NEXT: v_mov_b32_e32 v4, 0
1574 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1575 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc
1576 ; GCN-IR-NEXT: s_xor_b64 s[8:9], exec, s[4:5]
1577 ; GCN-IR-NEXT: s_cbranch_execz .LBB12_5
1578 ; GCN-IR-NEXT: ; %bb.2: ; %udiv-preheader
1579 ; GCN-IR-NEXT: v_lshr_b64 v[7:8], v[0:1], v7
1580 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, 0xffffffc4, v6
1581 ; GCN-IR-NEXT: v_mov_b32_e32 v9, 0
1582 ; GCN-IR-NEXT: v_addc_u32_e64 v1, s[4:5], 0, -1, vcc
1583 ; GCN-IR-NEXT: s_mov_b64 s[10:11], 0
1584 ; GCN-IR-NEXT: v_mov_b32_e32 v10, 0
1585 ; GCN-IR-NEXT: v_mov_b32_e32 v5, 0
1586 ; GCN-IR-NEXT: .LBB12_3: ; %udiv-do-while
1587 ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1
1588 ; GCN-IR-NEXT: v_lshl_b64 v[7:8], v[7:8], 1
1589 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v3
1590 ; GCN-IR-NEXT: v_or_b32_e32 v6, v7, v4
1591 ; GCN-IR-NEXT: v_sub_i32_e32 v4, vcc, 23, v6
1592 ; GCN-IR-NEXT: v_subb_u32_e32 v4, vcc, 0, v8, vcc
1593 ; GCN-IR-NEXT: v_add_i32_e32 v0, vcc, 1, v0
1594 ; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[2:3], 1
1595 ; GCN-IR-NEXT: v_ashrrev_i32_e32 v7, 31, v4
1596 ; GCN-IR-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
1597 ; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v7
1598 ; GCN-IR-NEXT: v_and_b32_e32 v7, 24, v7
1599 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[0:1]
1600 ; GCN-IR-NEXT: v_or_b32_e32 v3, v10, v3
1601 ; GCN-IR-NEXT: v_or_b32_e32 v2, v9, v2
1602 ; GCN-IR-NEXT: v_sub_i32_e64 v7, s[4:5], v6, v7
1603 ; GCN-IR-NEXT: v_mov_b32_e32 v10, v5
1604 ; GCN-IR-NEXT: v_subbrev_u32_e64 v8, s[4:5], 0, v8, s[4:5]
1605 ; GCN-IR-NEXT: s_or_b64 s[10:11], vcc, s[10:11]
1606 ; GCN-IR-NEXT: v_mov_b32_e32 v9, v4
1607 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[10:11]
1608 ; GCN-IR-NEXT: s_cbranch_execnz .LBB12_3
1609 ; GCN-IR-NEXT: ; %bb.4: ; %Flow
1610 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11]
1611 ; GCN-IR-NEXT: .LBB12_5: ; %Flow4
1612 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9]
1613 ; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[2:3], 1
1614 ; GCN-IR-NEXT: v_or_b32_e32 v2, v5, v1
1615 ; GCN-IR-NEXT: v_or_b32_e32 v3, v4, v0
1616 ; GCN-IR-NEXT: .LBB12_6: ; %Flow5
1617 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7]
1618 ; GCN-IR-NEXT: v_mov_b32_e32 v0, v3
1619 ; GCN-IR-NEXT: v_mov_b32_e32 v1, v2
1620 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1621 %result = udiv i64 %x, 24
1625 define amdgpu_kernel void @s_test_udiv24_k_num_i64(ptr addrspace(1) %out, i64 %x) {
1626 ; GCN-LABEL: s_test_udiv24_k_num_i64:
1628 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
1629 ; GCN-NEXT: s_mov_b32 s4, 0x41c00000
1630 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
1631 ; GCN-NEXT: s_lshr_b32 s2, s3, 8
1632 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
1633 ; GCN-NEXT: s_mov_b32 s3, 0xf000
1634 ; GCN-NEXT: s_mov_b32 s2, -1
1635 ; GCN-NEXT: v_rcp_iflag_f32_e32 v1, v0
1636 ; GCN-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1637 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1638 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1639 ; GCN-NEXT: v_mad_f32 v1, -v1, v0, s4
1640 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1641 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1642 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1643 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1644 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1645 ; GCN-NEXT: s_endpgm
1647 ; GCN-IR-LABEL: s_test_udiv24_k_num_i64:
1649 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
1650 ; GCN-IR-NEXT: s_mov_b32 s4, 0x41c00000
1651 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1652 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 8
1653 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
1654 ; GCN-IR-NEXT: s_mov_b32 s3, 0xf000
1655 ; GCN-IR-NEXT: s_mov_b32 s2, -1
1656 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v1, v0
1657 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1658 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1659 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1660 ; GCN-IR-NEXT: v_mad_f32 v1, -v1, v0, s4
1661 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1662 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1663 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1664 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1665 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
1666 ; GCN-IR-NEXT: s_endpgm
1667 %x.shr = lshr i64 %x, 40
1668 %result = udiv i64 24, %x.shr
1669 store i64 %result, ptr addrspace(1) %out
1673 define amdgpu_kernel void @s_test_udiv24_k_den_i64(ptr addrspace(1) %out, i64 %x) {
1674 ; GCN-LABEL: s_test_udiv24_k_den_i64:
1676 ; GCN-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
1677 ; GCN-NEXT: s_mov_b32 s7, 0xf000
1678 ; GCN-NEXT: s_mov_b32 s6, -1
1679 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
1680 ; GCN-NEXT: s_lshr_b32 s2, s3, 8
1681 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, s2
1682 ; GCN-NEXT: s_mov_b32 s2, 0x46b6fe00
1683 ; GCN-NEXT: s_mov_b32 s4, s0
1684 ; GCN-NEXT: s_mov_b32 s5, s1
1685 ; GCN-NEXT: v_mul_f32_e32 v1, 0x38331158, v0
1686 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1687 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1688 ; GCN-NEXT: v_mad_f32 v0, -v1, s2, v0
1689 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s2
1690 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1691 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1692 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1693 ; GCN-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
1694 ; GCN-NEXT: s_endpgm
1696 ; GCN-IR-LABEL: s_test_udiv24_k_den_i64:
1698 ; GCN-IR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
1699 ; GCN-IR-NEXT: s_mov_b32 s7, 0xf000
1700 ; GCN-IR-NEXT: s_mov_b32 s6, -1
1701 ; GCN-IR-NEXT: s_waitcnt lgkmcnt(0)
1702 ; GCN-IR-NEXT: s_lshr_b32 s2, s3, 8
1703 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, s2
1704 ; GCN-IR-NEXT: s_mov_b32 s2, 0x46b6fe00
1705 ; GCN-IR-NEXT: s_mov_b32 s4, s0
1706 ; GCN-IR-NEXT: s_mov_b32 s5, s1
1707 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x38331158, v0
1708 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1709 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1710 ; GCN-IR-NEXT: v_mad_f32 v0, -v1, s2, v0
1711 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s2
1712 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1713 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1714 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1715 ; GCN-IR-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
1716 ; GCN-IR-NEXT: s_endpgm
1717 %x.shr = lshr i64 %x, 40
1718 %result = udiv i64 %x.shr, 23423
1719 store i64 %result, ptr addrspace(1) %out
1723 define i64 @v_test_udiv24_k_num_i64(i64 %x) {
1724 ; GCN-LABEL: v_test_udiv24_k_num_i64:
1726 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1727 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1728 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, v0
1729 ; GCN-NEXT: s_mov_b32 s4, 0x41c00000
1730 ; GCN-NEXT: v_rcp_iflag_f32_e32 v1, v0
1731 ; GCN-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1732 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1733 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1734 ; GCN-NEXT: v_mad_f32 v1, -v1, v0, s4
1735 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1736 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1737 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1738 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1739 ; GCN-NEXT: s_setpc_b64 s[30:31]
1741 ; GCN-IR-LABEL: v_test_udiv24_k_num_i64:
1743 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1744 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1745 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, v0
1746 ; GCN-IR-NEXT: s_mov_b32 s4, 0x41c00000
1747 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v1, v0
1748 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x41c00000, v1
1749 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1750 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1751 ; GCN-IR-NEXT: v_mad_f32 v1, -v1, v0, s4
1752 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1753 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1754 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1755 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1756 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1757 %x.shr = lshr i64 %x, 40
1758 %result = udiv i64 24, %x.shr
1762 define i64 @v_test_udiv24_pow2_k_num_i64(i64 %x) {
1763 ; GCN-LABEL: v_test_udiv24_pow2_k_num_i64:
1765 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1766 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1767 ; GCN-NEXT: v_cvt_f32_u32_e32 v0, v0
1768 ; GCN-NEXT: s_mov_b32 s4, 0x47000000
1769 ; GCN-NEXT: v_rcp_iflag_f32_e32 v1, v0
1770 ; GCN-NEXT: v_mul_f32_e32 v1, 0x47000000, v1
1771 ; GCN-NEXT: v_trunc_f32_e32 v1, v1
1772 ; GCN-NEXT: v_cvt_u32_f32_e32 v2, v1
1773 ; GCN-NEXT: v_mad_f32 v1, -v1, v0, s4
1774 ; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1775 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1776 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1777 ; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1778 ; GCN-NEXT: s_setpc_b64 s[30:31]
1780 ; GCN-IR-LABEL: v_test_udiv24_pow2_k_num_i64:
1782 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1783 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1784 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, v0
1785 ; GCN-IR-NEXT: s_mov_b32 s4, 0x47000000
1786 ; GCN-IR-NEXT: v_rcp_iflag_f32_e32 v1, v0
1787 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x47000000, v1
1788 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1789 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1790 ; GCN-IR-NEXT: v_mad_f32 v1, -v1, v0, s4
1791 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, v0
1792 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1793 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1794 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1795 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1796 %x.shr = lshr i64 %x, 40
1797 %result = udiv i64 32768, %x.shr
1801 define i64 @v_test_udiv24_pow2_k_den_i64(i64 %x) {
1802 ; GCN-LABEL: v_test_udiv24_pow2_k_den_i64:
1804 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1805 ; GCN-NEXT: v_lshrrev_b32_e32 v0, 23, v1
1806 ; GCN-NEXT: v_mov_b32_e32 v1, 0
1807 ; GCN-NEXT: s_setpc_b64 s[30:31]
1809 ; GCN-IR-LABEL: v_test_udiv24_pow2_k_den_i64:
1811 ; GCN-IR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1812 ; GCN-IR-NEXT: v_lshrrev_b32_e32 v0, 8, v1
1813 ; GCN-IR-NEXT: v_cvt_f32_u32_e32 v0, v0
1814 ; GCN-IR-NEXT: s_mov_b32 s4, 0x47000000
1815 ; GCN-IR-NEXT: v_mul_f32_e32 v1, 0x38000000, v0
1816 ; GCN-IR-NEXT: v_trunc_f32_e32 v1, v1
1817 ; GCN-IR-NEXT: v_cvt_u32_f32_e32 v2, v1
1818 ; GCN-IR-NEXT: v_mad_f32 v0, -v1, s4, v0
1819 ; GCN-IR-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s4
1820 ; GCN-IR-NEXT: v_mov_b32_e32 v1, 0
1821 ; GCN-IR-NEXT: v_addc_u32_e32 v0, vcc, 0, v2, vcc
1822 ; GCN-IR-NEXT: v_and_b32_e32 v0, 0xffffff, v0
1823 ; GCN-IR-NEXT: s_setpc_b64 s[30:31]
1824 %x.shr = lshr i64 %x, 40
1825 %result = udiv i64 %x.shr, 32768