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