1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,RV32-V
3 ; RUN: llc -mtriple=riscv32 -mattr=+zve64x -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32,ZVE64X
4 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,RV64-V
5 ; RUN: llc -mtriple=riscv64 -mattr=+zve64x -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64,ZVE64X
7 define <vscale x 1 x i8> @vdivu_vv_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb) {
8 ; CHECK-LABEL: vdivu_vv_nxv1i8:
10 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
11 ; CHECK-NEXT: vdivu.vv v8, v8, v9
13 %vc = udiv <vscale x 1 x i8> %va, %vb
14 ret <vscale x 1 x i8> %vc
17 define <vscale x 1 x i8> @vdivu_vx_nxv1i8(<vscale x 1 x i8> %va, i8 signext %b) {
18 ; CHECK-LABEL: vdivu_vx_nxv1i8:
20 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
21 ; CHECK-NEXT: vdivu.vx v8, v8, a0
23 %head = insertelement <vscale x 1 x i8> poison, i8 %b, i32 0
24 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
25 %vc = udiv <vscale x 1 x i8> %va, %splat
26 ret <vscale x 1 x i8> %vc
29 define <vscale x 1 x i8> @vdivu_vi_nxv1i8_0(<vscale x 1 x i8> %va) {
30 ; CHECK-LABEL: vdivu_vi_nxv1i8_0:
32 ; CHECK-NEXT: li a0, 33
33 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
34 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
35 ; CHECK-NEXT: vsrl.vi v8, v8, 5
37 %vc = udiv <vscale x 1 x i8> %va, splat (i8 -7)
38 ret <vscale x 1 x i8> %vc
41 ; Test V/1 to see if we can optimize it away for scalable vectors.
42 define <vscale x 1 x i8> @vdivu_vi_nxv1i8_1(<vscale x 1 x i8> %va) {
43 ; CHECK-LABEL: vdivu_vi_nxv1i8_1:
46 %vc = udiv <vscale x 1 x i8> %va, splat (i8 1)
47 ret <vscale x 1 x i8> %vc
50 ; Test 0/V to see if we can optimize it away for scalable vectors.
51 define <vscale x 1 x i8> @vdivu_iv_nxv1i8_0(<vscale x 1 x i8> %va) {
52 ; CHECK-LABEL: vdivu_iv_nxv1i8_0:
54 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
55 ; CHECK-NEXT: vmv.v.i v8, 0
57 %vc = udiv <vscale x 1 x i8> splat (i8 0), %va
58 ret <vscale x 1 x i8> %vc
61 define <vscale x 2 x i8> @vdivu_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
62 ; CHECK-LABEL: vdivu_vv_nxv2i8:
64 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
65 ; CHECK-NEXT: vdivu.vv v8, v8, v9
67 %vc = udiv <vscale x 2 x i8> %va, %vb
68 ret <vscale x 2 x i8> %vc
71 define <vscale x 2 x i8> @vdivu_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
72 ; CHECK-LABEL: vdivu_vx_nxv2i8:
74 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
75 ; CHECK-NEXT: vdivu.vx v8, v8, a0
77 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
78 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
79 %vc = udiv <vscale x 2 x i8> %va, %splat
80 ret <vscale x 2 x i8> %vc
83 define <vscale x 2 x i8> @vdivu_vi_nxv2i8_0(<vscale x 2 x i8> %va) {
84 ; CHECK-LABEL: vdivu_vi_nxv2i8_0:
86 ; CHECK-NEXT: li a0, 33
87 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
88 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
89 ; CHECK-NEXT: vsrl.vi v8, v8, 5
91 %vc = udiv <vscale x 2 x i8> %va, splat (i8 -7)
92 ret <vscale x 2 x i8> %vc
95 define <vscale x 4 x i8> @vdivu_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
96 ; CHECK-LABEL: vdivu_vv_nxv4i8:
98 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
99 ; CHECK-NEXT: vdivu.vv v8, v8, v9
101 %vc = udiv <vscale x 4 x i8> %va, %vb
102 ret <vscale x 4 x i8> %vc
105 define <vscale x 4 x i8> @vdivu_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
106 ; CHECK-LABEL: vdivu_vx_nxv4i8:
108 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
109 ; CHECK-NEXT: vdivu.vx v8, v8, a0
111 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
112 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
113 %vc = udiv <vscale x 4 x i8> %va, %splat
114 ret <vscale x 4 x i8> %vc
117 define <vscale x 4 x i8> @vdivu_vi_nxv4i8_0(<vscale x 4 x i8> %va) {
118 ; CHECK-LABEL: vdivu_vi_nxv4i8_0:
120 ; CHECK-NEXT: li a0, 33
121 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
122 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
123 ; CHECK-NEXT: vsrl.vi v8, v8, 5
125 %vc = udiv <vscale x 4 x i8> %va, splat (i8 -7)
126 ret <vscale x 4 x i8> %vc
129 define <vscale x 8 x i8> @vdivu_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
130 ; CHECK-LABEL: vdivu_vv_nxv8i8:
132 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
133 ; CHECK-NEXT: vdivu.vv v8, v8, v9
135 %vc = udiv <vscale x 8 x i8> %va, %vb
136 ret <vscale x 8 x i8> %vc
139 define <vscale x 8 x i8> @vdivu_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
140 ; CHECK-LABEL: vdivu_vx_nxv8i8:
142 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
143 ; CHECK-NEXT: vdivu.vx v8, v8, a0
145 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
146 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
147 %vc = udiv <vscale x 8 x i8> %va, %splat
148 ret <vscale x 8 x i8> %vc
151 define <vscale x 8 x i8> @vdivu_vi_nxv8i8_0(<vscale x 8 x i8> %va) {
152 ; CHECK-LABEL: vdivu_vi_nxv8i8_0:
154 ; CHECK-NEXT: li a0, 33
155 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
156 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
157 ; CHECK-NEXT: vsrl.vi v8, v8, 5
159 %vc = udiv <vscale x 8 x i8> %va, splat (i8 -7)
160 ret <vscale x 8 x i8> %vc
163 define <vscale x 16 x i8> @vdivu_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
164 ; CHECK-LABEL: vdivu_vv_nxv16i8:
166 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
167 ; CHECK-NEXT: vdivu.vv v8, v8, v10
169 %vc = udiv <vscale x 16 x i8> %va, %vb
170 ret <vscale x 16 x i8> %vc
173 define <vscale x 16 x i8> @vdivu_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
174 ; CHECK-LABEL: vdivu_vx_nxv16i8:
176 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
177 ; CHECK-NEXT: vdivu.vx v8, v8, a0
179 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
180 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
181 %vc = udiv <vscale x 16 x i8> %va, %splat
182 ret <vscale x 16 x i8> %vc
185 define <vscale x 16 x i8> @vdivu_vi_nxv16i8_0(<vscale x 16 x i8> %va) {
186 ; CHECK-LABEL: vdivu_vi_nxv16i8_0:
188 ; CHECK-NEXT: li a0, 33
189 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
190 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
191 ; CHECK-NEXT: vsrl.vi v8, v8, 5
193 %vc = udiv <vscale x 16 x i8> %va, splat (i8 -7)
194 ret <vscale x 16 x i8> %vc
197 define <vscale x 32 x i8> @vdivu_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
198 ; CHECK-LABEL: vdivu_vv_nxv32i8:
200 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
201 ; CHECK-NEXT: vdivu.vv v8, v8, v12
203 %vc = udiv <vscale x 32 x i8> %va, %vb
204 ret <vscale x 32 x i8> %vc
207 define <vscale x 32 x i8> @vdivu_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
208 ; CHECK-LABEL: vdivu_vx_nxv32i8:
210 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
211 ; CHECK-NEXT: vdivu.vx v8, v8, a0
213 %head = insertelement <vscale x 32 x i8> poison, i8 %b, i32 0
214 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
215 %vc = udiv <vscale x 32 x i8> %va, %splat
216 ret <vscale x 32 x i8> %vc
219 define <vscale x 32 x i8> @vdivu_vi_nxv32i8_0(<vscale x 32 x i8> %va) {
220 ; CHECK-LABEL: vdivu_vi_nxv32i8_0:
222 ; CHECK-NEXT: li a0, 33
223 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
224 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
225 ; CHECK-NEXT: vsrl.vi v8, v8, 5
227 %vc = udiv <vscale x 32 x i8> %va, splat (i8 -7)
228 ret <vscale x 32 x i8> %vc
231 define <vscale x 64 x i8> @vdivu_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
232 ; CHECK-LABEL: vdivu_vv_nxv64i8:
234 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
235 ; CHECK-NEXT: vdivu.vv v8, v8, v16
237 %vc = udiv <vscale x 64 x i8> %va, %vb
238 ret <vscale x 64 x i8> %vc
241 define <vscale x 64 x i8> @vdivu_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
242 ; CHECK-LABEL: vdivu_vx_nxv64i8:
244 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
245 ; CHECK-NEXT: vdivu.vx v8, v8, a0
247 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
248 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
249 %vc = udiv <vscale x 64 x i8> %va, %splat
250 ret <vscale x 64 x i8> %vc
253 define <vscale x 64 x i8> @vdivu_vi_nxv64i8_0(<vscale x 64 x i8> %va) {
254 ; CHECK-LABEL: vdivu_vi_nxv64i8_0:
256 ; CHECK-NEXT: li a0, 33
257 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
258 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
259 ; CHECK-NEXT: vsrl.vi v8, v8, 5
261 %vc = udiv <vscale x 64 x i8> %va, splat (i8 -7)
262 ret <vscale x 64 x i8> %vc
265 define <vscale x 1 x i16> @vdivu_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
266 ; CHECK-LABEL: vdivu_vv_nxv1i16:
268 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
269 ; CHECK-NEXT: vdivu.vv v8, v8, v9
271 %vc = udiv <vscale x 1 x i16> %va, %vb
272 ret <vscale x 1 x i16> %vc
275 define <vscale x 1 x i16> @vdivu_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
276 ; CHECK-LABEL: vdivu_vx_nxv1i16:
278 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
279 ; CHECK-NEXT: vdivu.vx v8, v8, a0
281 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
282 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
283 %vc = udiv <vscale x 1 x i16> %va, %splat
284 ret <vscale x 1 x i16> %vc
287 define <vscale x 1 x i16> @vdivu_vi_nxv1i16_0(<vscale x 1 x i16> %va) {
288 ; CHECK-LABEL: vdivu_vi_nxv1i16_0:
290 ; CHECK-NEXT: lui a0, 2
291 ; CHECK-NEXT: addi a0, a0, 1
292 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
293 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
294 ; CHECK-NEXT: vsrl.vi v8, v8, 13
296 %vc = udiv <vscale x 1 x i16> %va, splat (i16 -7)
297 ret <vscale x 1 x i16> %vc
300 define <vscale x 2 x i16> @vdivu_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
301 ; CHECK-LABEL: vdivu_vv_nxv2i16:
303 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
304 ; CHECK-NEXT: vdivu.vv v8, v8, v9
306 %vc = udiv <vscale x 2 x i16> %va, %vb
307 ret <vscale x 2 x i16> %vc
310 define <vscale x 2 x i16> @vdivu_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
311 ; CHECK-LABEL: vdivu_vx_nxv2i16:
313 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
314 ; CHECK-NEXT: vdivu.vx v8, v8, a0
316 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
317 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
318 %vc = udiv <vscale x 2 x i16> %va, %splat
319 ret <vscale x 2 x i16> %vc
322 define <vscale x 2 x i16> @vdivu_vi_nxv2i16_0(<vscale x 2 x i16> %va) {
323 ; CHECK-LABEL: vdivu_vi_nxv2i16_0:
325 ; CHECK-NEXT: lui a0, 2
326 ; CHECK-NEXT: addi a0, a0, 1
327 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
328 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
329 ; CHECK-NEXT: vsrl.vi v8, v8, 13
331 %vc = udiv <vscale x 2 x i16> %va, splat (i16 -7)
332 ret <vscale x 2 x i16> %vc
335 define <vscale x 4 x i16> @vdivu_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
336 ; CHECK-LABEL: vdivu_vv_nxv4i16:
338 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
339 ; CHECK-NEXT: vdivu.vv v8, v8, v9
341 %vc = udiv <vscale x 4 x i16> %va, %vb
342 ret <vscale x 4 x i16> %vc
345 define <vscale x 4 x i16> @vdivu_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
346 ; CHECK-LABEL: vdivu_vx_nxv4i16:
348 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
349 ; CHECK-NEXT: vdivu.vx v8, v8, a0
351 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
352 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
353 %vc = udiv <vscale x 4 x i16> %va, %splat
354 ret <vscale x 4 x i16> %vc
357 define <vscale x 4 x i16> @vdivu_vi_nxv4i16_0(<vscale x 4 x i16> %va) {
358 ; CHECK-LABEL: vdivu_vi_nxv4i16_0:
360 ; CHECK-NEXT: lui a0, 2
361 ; CHECK-NEXT: addi a0, a0, 1
362 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
363 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
364 ; CHECK-NEXT: vsrl.vi v8, v8, 13
366 %vc = udiv <vscale x 4 x i16> %va, splat (i16 -7)
367 ret <vscale x 4 x i16> %vc
370 define <vscale x 8 x i16> @vdivu_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
371 ; CHECK-LABEL: vdivu_vv_nxv8i16:
373 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
374 ; CHECK-NEXT: vdivu.vv v8, v8, v10
376 %vc = udiv <vscale x 8 x i16> %va, %vb
377 ret <vscale x 8 x i16> %vc
380 define <vscale x 8 x i16> @vdivu_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
381 ; CHECK-LABEL: vdivu_vx_nxv8i16:
383 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
384 ; CHECK-NEXT: vdivu.vx v8, v8, a0
386 %head = insertelement <vscale x 8 x i16> poison, i16 %b, i32 0
387 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
388 %vc = udiv <vscale x 8 x i16> %va, %splat
389 ret <vscale x 8 x i16> %vc
392 define <vscale x 8 x i16> @vdivu_vi_nxv8i16_0(<vscale x 8 x i16> %va) {
393 ; CHECK-LABEL: vdivu_vi_nxv8i16_0:
395 ; CHECK-NEXT: lui a0, 2
396 ; CHECK-NEXT: addi a0, a0, 1
397 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
398 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
399 ; CHECK-NEXT: vsrl.vi v8, v8, 13
401 %vc = udiv <vscale x 8 x i16> %va, splat (i16 -7)
402 ret <vscale x 8 x i16> %vc
405 define <vscale x 16 x i16> @vdivu_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
406 ; CHECK-LABEL: vdivu_vv_nxv16i16:
408 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
409 ; CHECK-NEXT: vdivu.vv v8, v8, v12
411 %vc = udiv <vscale x 16 x i16> %va, %vb
412 ret <vscale x 16 x i16> %vc
415 define <vscale x 16 x i16> @vdivu_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
416 ; CHECK-LABEL: vdivu_vx_nxv16i16:
418 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
419 ; CHECK-NEXT: vdivu.vx v8, v8, a0
421 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
422 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
423 %vc = udiv <vscale x 16 x i16> %va, %splat
424 ret <vscale x 16 x i16> %vc
427 define <vscale x 16 x i16> @vdivu_vi_nxv16i16_0(<vscale x 16 x i16> %va) {
428 ; CHECK-LABEL: vdivu_vi_nxv16i16_0:
430 ; CHECK-NEXT: lui a0, 2
431 ; CHECK-NEXT: addi a0, a0, 1
432 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
433 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
434 ; CHECK-NEXT: vsrl.vi v8, v8, 13
436 %vc = udiv <vscale x 16 x i16> %va, splat (i16 -7)
437 ret <vscale x 16 x i16> %vc
440 define <vscale x 32 x i16> @vdivu_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
441 ; CHECK-LABEL: vdivu_vv_nxv32i16:
443 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
444 ; CHECK-NEXT: vdivu.vv v8, v8, v16
446 %vc = udiv <vscale x 32 x i16> %va, %vb
447 ret <vscale x 32 x i16> %vc
450 define <vscale x 32 x i16> @vdivu_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
451 ; CHECK-LABEL: vdivu_vx_nxv32i16:
453 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
454 ; CHECK-NEXT: vdivu.vx v8, v8, a0
456 %head = insertelement <vscale x 32 x i16> poison, i16 %b, i32 0
457 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
458 %vc = udiv <vscale x 32 x i16> %va, %splat
459 ret <vscale x 32 x i16> %vc
462 define <vscale x 32 x i16> @vdivu_vi_nxv32i16_0(<vscale x 32 x i16> %va) {
463 ; CHECK-LABEL: vdivu_vi_nxv32i16_0:
465 ; CHECK-NEXT: lui a0, 2
466 ; CHECK-NEXT: addi a0, a0, 1
467 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
468 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
469 ; CHECK-NEXT: vsrl.vi v8, v8, 13
471 %vc = udiv <vscale x 32 x i16> %va, splat (i16 -7)
472 ret <vscale x 32 x i16> %vc
475 define <vscale x 1 x i32> @vdivu_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
476 ; CHECK-LABEL: vdivu_vv_nxv1i32:
478 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
479 ; CHECK-NEXT: vdivu.vv v8, v8, v9
481 %vc = udiv <vscale x 1 x i32> %va, %vb
482 ret <vscale x 1 x i32> %vc
485 define <vscale x 1 x i32> @vdivu_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
486 ; CHECK-LABEL: vdivu_vx_nxv1i32:
488 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
489 ; CHECK-NEXT: vdivu.vx v8, v8, a0
491 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
492 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
493 %vc = udiv <vscale x 1 x i32> %va, %splat
494 ret <vscale x 1 x i32> %vc
497 define <vscale x 1 x i32> @vdivu_vi_nxv1i32_0(<vscale x 1 x i32> %va) {
498 ; CHECK-LABEL: vdivu_vi_nxv1i32_0:
500 ; CHECK-NEXT: lui a0, 131072
501 ; CHECK-NEXT: addi a0, a0, 1
502 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
503 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
504 ; CHECK-NEXT: vsrl.vi v8, v8, 29
506 %vc = udiv <vscale x 1 x i32> %va, splat (i32 -7)
507 ret <vscale x 1 x i32> %vc
510 define <vscale x 2 x i32> @vdivu_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
511 ; CHECK-LABEL: vdivu_vv_nxv2i32:
513 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
514 ; CHECK-NEXT: vdivu.vv v8, v8, v9
516 %vc = udiv <vscale x 2 x i32> %va, %vb
517 ret <vscale x 2 x i32> %vc
520 define <vscale x 2 x i32> @vdivu_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
521 ; CHECK-LABEL: vdivu_vx_nxv2i32:
523 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
524 ; CHECK-NEXT: vdivu.vx v8, v8, a0
526 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
527 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
528 %vc = udiv <vscale x 2 x i32> %va, %splat
529 ret <vscale x 2 x i32> %vc
532 define <vscale x 2 x i32> @vdivu_vi_nxv2i32_0(<vscale x 2 x i32> %va) {
533 ; CHECK-LABEL: vdivu_vi_nxv2i32_0:
535 ; CHECK-NEXT: lui a0, 131072
536 ; CHECK-NEXT: addi a0, a0, 1
537 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
538 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
539 ; CHECK-NEXT: vsrl.vi v8, v8, 29
541 %vc = udiv <vscale x 2 x i32> %va, splat (i32 -7)
542 ret <vscale x 2 x i32> %vc
545 define <vscale x 4 x i32> @vdivu_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
546 ; CHECK-LABEL: vdivu_vv_nxv4i32:
548 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
549 ; CHECK-NEXT: vdivu.vv v8, v8, v10
551 %vc = udiv <vscale x 4 x i32> %va, %vb
552 ret <vscale x 4 x i32> %vc
555 define <vscale x 4 x i32> @vdivu_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
556 ; CHECK-LABEL: vdivu_vx_nxv4i32:
558 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
559 ; CHECK-NEXT: vdivu.vx v8, v8, a0
561 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
562 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
563 %vc = udiv <vscale x 4 x i32> %va, %splat
564 ret <vscale x 4 x i32> %vc
567 define <vscale x 4 x i32> @vdivu_vi_nxv4i32_0(<vscale x 4 x i32> %va) {
568 ; CHECK-LABEL: vdivu_vi_nxv4i32_0:
570 ; CHECK-NEXT: lui a0, 131072
571 ; CHECK-NEXT: addi a0, a0, 1
572 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
573 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
574 ; CHECK-NEXT: vsrl.vi v8, v8, 29
576 %vc = udiv <vscale x 4 x i32> %va, splat (i32 -7)
577 ret <vscale x 4 x i32> %vc
580 define <vscale x 8 x i32> @vdivu_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
581 ; CHECK-LABEL: vdivu_vv_nxv8i32:
583 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
584 ; CHECK-NEXT: vdivu.vv v8, v8, v12
586 %vc = udiv <vscale x 8 x i32> %va, %vb
587 ret <vscale x 8 x i32> %vc
590 define <vscale x 8 x i32> @vdivu_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
591 ; CHECK-LABEL: vdivu_vx_nxv8i32:
593 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
594 ; CHECK-NEXT: vdivu.vx v8, v8, a0
596 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
597 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
598 %vc = udiv <vscale x 8 x i32> %va, %splat
599 ret <vscale x 8 x i32> %vc
602 define <vscale x 8 x i32> @vdivu_vi_nxv8i32_0(<vscale x 8 x i32> %va) {
603 ; CHECK-LABEL: vdivu_vi_nxv8i32_0:
605 ; CHECK-NEXT: lui a0, 131072
606 ; CHECK-NEXT: addi a0, a0, 1
607 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
608 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
609 ; CHECK-NEXT: vsrl.vi v8, v8, 29
611 %vc = udiv <vscale x 8 x i32> %va, splat (i32 -7)
612 ret <vscale x 8 x i32> %vc
615 define <vscale x 16 x i32> @vdivu_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
616 ; CHECK-LABEL: vdivu_vv_nxv16i32:
618 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
619 ; CHECK-NEXT: vdivu.vv v8, v8, v16
621 %vc = udiv <vscale x 16 x i32> %va, %vb
622 ret <vscale x 16 x i32> %vc
625 define <vscale x 16 x i32> @vdivu_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
626 ; CHECK-LABEL: vdivu_vx_nxv16i32:
628 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
629 ; CHECK-NEXT: vdivu.vx v8, v8, a0
631 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
632 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
633 %vc = udiv <vscale x 16 x i32> %va, %splat
634 ret <vscale x 16 x i32> %vc
637 define <vscale x 16 x i32> @vdivu_vi_nxv16i32_0(<vscale x 16 x i32> %va) {
638 ; CHECK-LABEL: vdivu_vi_nxv16i32_0:
640 ; CHECK-NEXT: lui a0, 131072
641 ; CHECK-NEXT: addi a0, a0, 1
642 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
643 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
644 ; CHECK-NEXT: vsrl.vi v8, v8, 29
646 %vc = udiv <vscale x 16 x i32> %va, splat (i32 -7)
647 ret <vscale x 16 x i32> %vc
650 define <vscale x 1 x i64> @vdivu_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
651 ; CHECK-LABEL: vdivu_vv_nxv1i64:
653 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
654 ; CHECK-NEXT: vdivu.vv v8, v8, v9
656 %vc = udiv <vscale x 1 x i64> %va, %vb
657 ret <vscale x 1 x i64> %vc
660 define <vscale x 1 x i64> @vdivu_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
661 ; RV32-LABEL: vdivu_vx_nxv1i64:
663 ; RV32-NEXT: addi sp, sp, -16
664 ; RV32-NEXT: .cfi_def_cfa_offset 16
665 ; RV32-NEXT: sw a1, 12(sp)
666 ; RV32-NEXT: sw a0, 8(sp)
667 ; RV32-NEXT: addi a0, sp, 8
668 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
669 ; RV32-NEXT: vlse64.v v9, (a0), zero
670 ; RV32-NEXT: vdivu.vv v8, v8, v9
671 ; RV32-NEXT: addi sp, sp, 16
674 ; RV64-LABEL: vdivu_vx_nxv1i64:
676 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
677 ; RV64-NEXT: vdivu.vx v8, v8, a0
679 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
680 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
681 %vc = udiv <vscale x 1 x i64> %va, %splat
682 ret <vscale x 1 x i64> %vc
685 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_0(<vscale x 1 x i64> %va) {
686 ; RV32-V-LABEL: vdivu_vi_nxv1i64_0:
688 ; RV32-V-NEXT: addi sp, sp, -16
689 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
690 ; RV32-V-NEXT: lui a0, 131072
691 ; RV32-V-NEXT: sw a0, 12(sp)
692 ; RV32-V-NEXT: li a0, 1
693 ; RV32-V-NEXT: sw a0, 8(sp)
694 ; RV32-V-NEXT: addi a0, sp, 8
695 ; RV32-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
696 ; RV32-V-NEXT: vlse64.v v9, (a0), zero
697 ; RV32-V-NEXT: vmulhu.vv v8, v8, v9
698 ; RV32-V-NEXT: li a0, 61
699 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
700 ; RV32-V-NEXT: addi sp, sp, 16
703 ; ZVE64X-LABEL: vdivu_vi_nxv1i64_0:
705 ; ZVE64X-NEXT: li a0, -7
706 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m1, ta, ma
707 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
710 ; RV64-V-LABEL: vdivu_vi_nxv1i64_0:
712 ; RV64-V-NEXT: li a0, 1
713 ; RV64-V-NEXT: slli a0, a0, 61
714 ; RV64-V-NEXT: addi a0, a0, 1
715 ; RV64-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
716 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
717 ; RV64-V-NEXT: li a0, 61
718 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
720 %vc = udiv <vscale x 1 x i64> %va, splat (i64 -7)
721 ret <vscale x 1 x i64> %vc
724 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_1(<vscale x 1 x i64> %va) {
725 ; CHECK-LABEL: vdivu_vi_nxv1i64_1:
727 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
728 ; CHECK-NEXT: vsrl.vi v8, v8, 1
730 %vc = udiv <vscale x 1 x i64> %va, splat (i64 2)
731 ret <vscale x 1 x i64> %vc
734 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
735 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_2(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
736 ; CHECK-LABEL: vdivu_vi_nxv1i64_2:
738 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
739 ; CHECK-NEXT: vadd.vi v9, v9, 4
740 ; CHECK-NEXT: vsrl.vv v8, v8, v9
742 %vc = shl <vscale x 1 x i64> splat (i64 16), %vb
743 %vd = udiv <vscale x 1 x i64> %va, %vc
744 ret <vscale x 1 x i64> %vd
747 define <vscale x 2 x i64> @vdivu_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
748 ; CHECK-LABEL: vdivu_vv_nxv2i64:
750 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
751 ; CHECK-NEXT: vdivu.vv v8, v8, v10
753 %vc = udiv <vscale x 2 x i64> %va, %vb
754 ret <vscale x 2 x i64> %vc
757 define <vscale x 2 x i64> @vdivu_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
758 ; RV32-LABEL: vdivu_vx_nxv2i64:
760 ; RV32-NEXT: addi sp, sp, -16
761 ; RV32-NEXT: .cfi_def_cfa_offset 16
762 ; RV32-NEXT: sw a1, 12(sp)
763 ; RV32-NEXT: sw a0, 8(sp)
764 ; RV32-NEXT: addi a0, sp, 8
765 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
766 ; RV32-NEXT: vlse64.v v10, (a0), zero
767 ; RV32-NEXT: vdivu.vv v8, v8, v10
768 ; RV32-NEXT: addi sp, sp, 16
771 ; RV64-LABEL: vdivu_vx_nxv2i64:
773 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
774 ; RV64-NEXT: vdivu.vx v8, v8, a0
776 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
777 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
778 %vc = udiv <vscale x 2 x i64> %va, %splat
779 ret <vscale x 2 x i64> %vc
782 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_0(<vscale x 2 x i64> %va) {
783 ; RV32-V-LABEL: vdivu_vi_nxv2i64_0:
785 ; RV32-V-NEXT: addi sp, sp, -16
786 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
787 ; RV32-V-NEXT: lui a0, 131072
788 ; RV32-V-NEXT: sw a0, 12(sp)
789 ; RV32-V-NEXT: li a0, 1
790 ; RV32-V-NEXT: sw a0, 8(sp)
791 ; RV32-V-NEXT: addi a0, sp, 8
792 ; RV32-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
793 ; RV32-V-NEXT: vlse64.v v10, (a0), zero
794 ; RV32-V-NEXT: vmulhu.vv v8, v8, v10
795 ; RV32-V-NEXT: li a0, 61
796 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
797 ; RV32-V-NEXT: addi sp, sp, 16
800 ; ZVE64X-LABEL: vdivu_vi_nxv2i64_0:
802 ; ZVE64X-NEXT: li a0, -7
803 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m2, ta, ma
804 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
807 ; RV64-V-LABEL: vdivu_vi_nxv2i64_0:
809 ; RV64-V-NEXT: li a0, 1
810 ; RV64-V-NEXT: slli a0, a0, 61
811 ; RV64-V-NEXT: addi a0, a0, 1
812 ; RV64-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
813 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
814 ; RV64-V-NEXT: li a0, 61
815 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
817 %vc = udiv <vscale x 2 x i64> %va, splat (i64 -7)
818 ret <vscale x 2 x i64> %vc
821 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_1(<vscale x 2 x i64> %va) {
822 ; CHECK-LABEL: vdivu_vi_nxv2i64_1:
824 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
825 ; CHECK-NEXT: vsrl.vi v8, v8, 1
827 %vc = udiv <vscale x 2 x i64> %va, splat (i64 2)
828 ret <vscale x 2 x i64> %vc
831 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
832 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_2(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
833 ; CHECK-LABEL: vdivu_vi_nxv2i64_2:
835 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
836 ; CHECK-NEXT: vadd.vi v10, v10, 4
837 ; CHECK-NEXT: vsrl.vv v8, v8, v10
839 %vc = shl <vscale x 2 x i64> splat (i64 16), %vb
840 %vd = udiv <vscale x 2 x i64> %va, %vc
841 ret <vscale x 2 x i64> %vd
844 define <vscale x 4 x i64> @vdivu_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
845 ; CHECK-LABEL: vdivu_vv_nxv4i64:
847 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
848 ; CHECK-NEXT: vdivu.vv v8, v8, v12
850 %vc = udiv <vscale x 4 x i64> %va, %vb
851 ret <vscale x 4 x i64> %vc
854 define <vscale x 4 x i64> @vdivu_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
855 ; RV32-LABEL: vdivu_vx_nxv4i64:
857 ; RV32-NEXT: addi sp, sp, -16
858 ; RV32-NEXT: .cfi_def_cfa_offset 16
859 ; RV32-NEXT: sw a1, 12(sp)
860 ; RV32-NEXT: sw a0, 8(sp)
861 ; RV32-NEXT: addi a0, sp, 8
862 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
863 ; RV32-NEXT: vlse64.v v12, (a0), zero
864 ; RV32-NEXT: vdivu.vv v8, v8, v12
865 ; RV32-NEXT: addi sp, sp, 16
868 ; RV64-LABEL: vdivu_vx_nxv4i64:
870 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
871 ; RV64-NEXT: vdivu.vx v8, v8, a0
873 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
874 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
875 %vc = udiv <vscale x 4 x i64> %va, %splat
876 ret <vscale x 4 x i64> %vc
879 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_0(<vscale x 4 x i64> %va) {
880 ; RV32-V-LABEL: vdivu_vi_nxv4i64_0:
882 ; RV32-V-NEXT: addi sp, sp, -16
883 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
884 ; RV32-V-NEXT: lui a0, 131072
885 ; RV32-V-NEXT: sw a0, 12(sp)
886 ; RV32-V-NEXT: li a0, 1
887 ; RV32-V-NEXT: sw a0, 8(sp)
888 ; RV32-V-NEXT: addi a0, sp, 8
889 ; RV32-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
890 ; RV32-V-NEXT: vlse64.v v12, (a0), zero
891 ; RV32-V-NEXT: vmulhu.vv v8, v8, v12
892 ; RV32-V-NEXT: li a0, 61
893 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
894 ; RV32-V-NEXT: addi sp, sp, 16
897 ; ZVE64X-LABEL: vdivu_vi_nxv4i64_0:
899 ; ZVE64X-NEXT: li a0, -7
900 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m4, ta, ma
901 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
904 ; RV64-V-LABEL: vdivu_vi_nxv4i64_0:
906 ; RV64-V-NEXT: li a0, 1
907 ; RV64-V-NEXT: slli a0, a0, 61
908 ; RV64-V-NEXT: addi a0, a0, 1
909 ; RV64-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
910 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
911 ; RV64-V-NEXT: li a0, 61
912 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
914 %vc = udiv <vscale x 4 x i64> %va, splat (i64 -7)
915 ret <vscale x 4 x i64> %vc
918 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_1(<vscale x 4 x i64> %va) {
919 ; CHECK-LABEL: vdivu_vi_nxv4i64_1:
921 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
922 ; CHECK-NEXT: vsrl.vi v8, v8, 1
924 %vc = udiv <vscale x 4 x i64> %va, splat (i64 2)
925 ret <vscale x 4 x i64> %vc
928 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
929 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_2(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
930 ; CHECK-LABEL: vdivu_vi_nxv4i64_2:
932 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
933 ; CHECK-NEXT: vadd.vi v12, v12, 4
934 ; CHECK-NEXT: vsrl.vv v8, v8, v12
936 %vc = shl <vscale x 4 x i64> splat (i64 16), %vb
937 %vd = udiv <vscale x 4 x i64> %va, %vc
938 ret <vscale x 4 x i64> %vd
941 define <vscale x 8 x i64> @vdivu_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
942 ; CHECK-LABEL: vdivu_vv_nxv8i64:
944 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
945 ; CHECK-NEXT: vdivu.vv v8, v8, v16
947 %vc = udiv <vscale x 8 x i64> %va, %vb
948 ret <vscale x 8 x i64> %vc
951 define <vscale x 8 x i64> @vdivu_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
952 ; RV32-LABEL: vdivu_vx_nxv8i64:
954 ; RV32-NEXT: addi sp, sp, -16
955 ; RV32-NEXT: .cfi_def_cfa_offset 16
956 ; RV32-NEXT: sw a1, 12(sp)
957 ; RV32-NEXT: sw a0, 8(sp)
958 ; RV32-NEXT: addi a0, sp, 8
959 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
960 ; RV32-NEXT: vlse64.v v16, (a0), zero
961 ; RV32-NEXT: vdivu.vv v8, v8, v16
962 ; RV32-NEXT: addi sp, sp, 16
965 ; RV64-LABEL: vdivu_vx_nxv8i64:
967 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
968 ; RV64-NEXT: vdivu.vx v8, v8, a0
970 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
971 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
972 %vc = udiv <vscale x 8 x i64> %va, %splat
973 ret <vscale x 8 x i64> %vc
976 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_0(<vscale x 8 x i64> %va) {
977 ; RV32-V-LABEL: vdivu_vi_nxv8i64_0:
979 ; RV32-V-NEXT: addi sp, sp, -16
980 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
981 ; RV32-V-NEXT: lui a0, 131072
982 ; RV32-V-NEXT: sw a0, 12(sp)
983 ; RV32-V-NEXT: li a0, 1
984 ; RV32-V-NEXT: sw a0, 8(sp)
985 ; RV32-V-NEXT: addi a0, sp, 8
986 ; RV32-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
987 ; RV32-V-NEXT: vlse64.v v16, (a0), zero
988 ; RV32-V-NEXT: vmulhu.vv v8, v8, v16
989 ; RV32-V-NEXT: li a0, 61
990 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
991 ; RV32-V-NEXT: addi sp, sp, 16
994 ; ZVE64X-LABEL: vdivu_vi_nxv8i64_0:
996 ; ZVE64X-NEXT: li a0, -7
997 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m8, ta, ma
998 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
1001 ; RV64-V-LABEL: vdivu_vi_nxv8i64_0:
1003 ; RV64-V-NEXT: li a0, 1
1004 ; RV64-V-NEXT: slli a0, a0, 61
1005 ; RV64-V-NEXT: addi a0, a0, 1
1006 ; RV64-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1007 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
1008 ; RV64-V-NEXT: li a0, 61
1009 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
1011 %vc = udiv <vscale x 8 x i64> %va, splat (i64 -7)
1012 ret <vscale x 8 x i64> %vc
1015 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_1(<vscale x 8 x i64> %va) {
1016 ; CHECK-LABEL: vdivu_vi_nxv8i64_1:
1018 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1019 ; CHECK-NEXT: vsrl.vi v8, v8, 1
1021 %vc = udiv <vscale x 8 x i64> %va, splat (i64 2)
1022 ret <vscale x 8 x i64> %vc
1025 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
1026 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_2(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1027 ; CHECK-LABEL: vdivu_vi_nxv8i64_2:
1029 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1030 ; CHECK-NEXT: vadd.vi v16, v16, 4
1031 ; CHECK-NEXT: vsrl.vv v8, v8, v16
1033 %vc = shl <vscale x 8 x i64> splat (i64 16), %vb
1034 %vd = udiv <vscale x 8 x i64> %va, %vc
1035 ret <vscale x 8 x i64> %vd
1038 define <vscale x 8 x i32> @vdivu_vv_mask_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb, <vscale x 8 x i1> %mask) {
1039 ; CHECK-LABEL: vdivu_vv_mask_nxv8i32:
1041 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
1042 ; CHECK-NEXT: vmv.v.i v16, 1
1043 ; CHECK-NEXT: vmerge.vvm v12, v16, v12, v0
1044 ; CHECK-NEXT: vdivu.vv v8, v8, v12
1046 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %vb, <vscale x 8 x i32> splat (i32 1)
1047 %vc = udiv <vscale x 8 x i32> %va, %vs
1048 ret <vscale x 8 x i32> %vc
1051 define <vscale x 8 x i32> @vdivu_vx_mask_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b, <vscale x 8 x i1> %mask) {
1052 ; CHECK-LABEL: vdivu_vx_mask_nxv8i32:
1054 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
1055 ; CHECK-NEXT: vmv.v.i v12, 1
1056 ; CHECK-NEXT: vmerge.vxm v12, v12, a0, v0
1057 ; CHECK-NEXT: vdivu.vv v8, v8, v12
1059 %head2 = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
1060 %splat = shufflevector <vscale x 8 x i32> %head2, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1061 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %splat, <vscale x 8 x i32> splat (i32 1)
1062 %vc = udiv <vscale x 8 x i32> %va, %vs
1063 ret <vscale x 8 x i32> %vc
1066 define <vscale x 8 x i32> @vdivu_vi_mask_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i1> %mask) {
1067 ; CHECK-LABEL: vdivu_vi_mask_nxv8i32:
1069 ; CHECK-NEXT: lui a0, 149797
1070 ; CHECK-NEXT: addi a0, a0, -1755
1071 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu
1072 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
1073 ; CHECK-NEXT: vsub.vv v16, v8, v12
1074 ; CHECK-NEXT: vsrl.vi v16, v16, 1
1075 ; CHECK-NEXT: vadd.vv v12, v16, v12
1076 ; CHECK-NEXT: vsrl.vi v8, v12, 2, v0.t
1078 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> splat (i32 7), <vscale x 8 x i32> splat (i32 1)
1079 %vc = udiv <vscale x 8 x i32> %va, %vs
1080 ret <vscale x 8 x i32> %vc