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 %head = insertelement <vscale x 1 x i8> poison, i8 -7, i32 0
38 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
39 %vc = udiv <vscale x 1 x i8> %va, %splat
40 ret <vscale x 1 x i8> %vc
43 ; Test V/1 to see if we can optimize it away for scalable vectors.
44 define <vscale x 1 x i8> @vdivu_vi_nxv1i8_1(<vscale x 1 x i8> %va) {
45 ; CHECK-LABEL: vdivu_vi_nxv1i8_1:
48 %head = insertelement <vscale x 1 x i8> poison, i8 1, i32 0
49 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
50 %vc = udiv <vscale x 1 x i8> %va, %splat
51 ret <vscale x 1 x i8> %vc
54 ; Test 0/V to see if we can optimize it away for scalable vectors.
55 define <vscale x 1 x i8> @vdivu_iv_nxv1i8_0(<vscale x 1 x i8> %va) {
56 ; CHECK-LABEL: vdivu_iv_nxv1i8_0:
58 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
59 ; CHECK-NEXT: vmv.v.i v8, 0
61 %head = insertelement <vscale x 1 x i8> poison, i8 0, i32 0
62 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
63 %vc = udiv <vscale x 1 x i8> %splat, %va
64 ret <vscale x 1 x i8> %vc
67 define <vscale x 2 x i8> @vdivu_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
68 ; CHECK-LABEL: vdivu_vv_nxv2i8:
70 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
71 ; CHECK-NEXT: vdivu.vv v8, v8, v9
73 %vc = udiv <vscale x 2 x i8> %va, %vb
74 ret <vscale x 2 x i8> %vc
77 define <vscale x 2 x i8> @vdivu_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
78 ; CHECK-LABEL: vdivu_vx_nxv2i8:
80 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
81 ; CHECK-NEXT: vdivu.vx v8, v8, a0
83 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
84 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
85 %vc = udiv <vscale x 2 x i8> %va, %splat
86 ret <vscale x 2 x i8> %vc
89 define <vscale x 2 x i8> @vdivu_vi_nxv2i8_0(<vscale x 2 x i8> %va) {
90 ; CHECK-LABEL: vdivu_vi_nxv2i8_0:
92 ; CHECK-NEXT: li a0, 33
93 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
94 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
95 ; CHECK-NEXT: vsrl.vi v8, v8, 5
97 %head = insertelement <vscale x 2 x i8> poison, i8 -7, i32 0
98 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
99 %vc = udiv <vscale x 2 x i8> %va, %splat
100 ret <vscale x 2 x i8> %vc
103 define <vscale x 4 x i8> @vdivu_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
104 ; CHECK-LABEL: vdivu_vv_nxv4i8:
106 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
107 ; CHECK-NEXT: vdivu.vv v8, v8, v9
109 %vc = udiv <vscale x 4 x i8> %va, %vb
110 ret <vscale x 4 x i8> %vc
113 define <vscale x 4 x i8> @vdivu_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
114 ; CHECK-LABEL: vdivu_vx_nxv4i8:
116 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
117 ; CHECK-NEXT: vdivu.vx v8, v8, a0
119 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
120 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
121 %vc = udiv <vscale x 4 x i8> %va, %splat
122 ret <vscale x 4 x i8> %vc
125 define <vscale x 4 x i8> @vdivu_vi_nxv4i8_0(<vscale x 4 x i8> %va) {
126 ; CHECK-LABEL: vdivu_vi_nxv4i8_0:
128 ; CHECK-NEXT: li a0, 33
129 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
130 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
131 ; CHECK-NEXT: vsrl.vi v8, v8, 5
133 %head = insertelement <vscale x 4 x i8> poison, i8 -7, i32 0
134 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
135 %vc = udiv <vscale x 4 x i8> %va, %splat
136 ret <vscale x 4 x i8> %vc
139 define <vscale x 8 x i8> @vdivu_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
140 ; CHECK-LABEL: vdivu_vv_nxv8i8:
142 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
143 ; CHECK-NEXT: vdivu.vv v8, v8, v9
145 %vc = udiv <vscale x 8 x i8> %va, %vb
146 ret <vscale x 8 x i8> %vc
149 define <vscale x 8 x i8> @vdivu_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
150 ; CHECK-LABEL: vdivu_vx_nxv8i8:
152 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
153 ; CHECK-NEXT: vdivu.vx v8, v8, a0
155 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
156 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
157 %vc = udiv <vscale x 8 x i8> %va, %splat
158 ret <vscale x 8 x i8> %vc
161 define <vscale x 8 x i8> @vdivu_vi_nxv8i8_0(<vscale x 8 x i8> %va) {
162 ; CHECK-LABEL: vdivu_vi_nxv8i8_0:
164 ; CHECK-NEXT: li a0, 33
165 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
166 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
167 ; CHECK-NEXT: vsrl.vi v8, v8, 5
169 %head = insertelement <vscale x 8 x i8> poison, i8 -7, i32 0
170 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
171 %vc = udiv <vscale x 8 x i8> %va, %splat
172 ret <vscale x 8 x i8> %vc
175 define <vscale x 16 x i8> @vdivu_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
176 ; CHECK-LABEL: vdivu_vv_nxv16i8:
178 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
179 ; CHECK-NEXT: vdivu.vv v8, v8, v10
181 %vc = udiv <vscale x 16 x i8> %va, %vb
182 ret <vscale x 16 x i8> %vc
185 define <vscale x 16 x i8> @vdivu_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
186 ; CHECK-LABEL: vdivu_vx_nxv16i8:
188 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
189 ; CHECK-NEXT: vdivu.vx v8, v8, a0
191 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
192 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
193 %vc = udiv <vscale x 16 x i8> %va, %splat
194 ret <vscale x 16 x i8> %vc
197 define <vscale x 16 x i8> @vdivu_vi_nxv16i8_0(<vscale x 16 x i8> %va) {
198 ; CHECK-LABEL: vdivu_vi_nxv16i8_0:
200 ; CHECK-NEXT: li a0, 33
201 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
202 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
203 ; CHECK-NEXT: vsrl.vi v8, v8, 5
205 %head = insertelement <vscale x 16 x i8> poison, i8 -7, i32 0
206 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
207 %vc = udiv <vscale x 16 x i8> %va, %splat
208 ret <vscale x 16 x i8> %vc
211 define <vscale x 32 x i8> @vdivu_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
212 ; CHECK-LABEL: vdivu_vv_nxv32i8:
214 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
215 ; CHECK-NEXT: vdivu.vv v8, v8, v12
217 %vc = udiv <vscale x 32 x i8> %va, %vb
218 ret <vscale x 32 x i8> %vc
221 define <vscale x 32 x i8> @vdivu_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
222 ; CHECK-LABEL: vdivu_vx_nxv32i8:
224 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
225 ; CHECK-NEXT: vdivu.vx v8, v8, a0
227 %head = insertelement <vscale x 32 x i8> poison, i8 %b, i32 0
228 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
229 %vc = udiv <vscale x 32 x i8> %va, %splat
230 ret <vscale x 32 x i8> %vc
233 define <vscale x 32 x i8> @vdivu_vi_nxv32i8_0(<vscale x 32 x i8> %va) {
234 ; CHECK-LABEL: vdivu_vi_nxv32i8_0:
236 ; CHECK-NEXT: li a0, 33
237 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
238 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
239 ; CHECK-NEXT: vsrl.vi v8, v8, 5
241 %head = insertelement <vscale x 32 x i8> poison, i8 -7, i32 0
242 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
243 %vc = udiv <vscale x 32 x i8> %va, %splat
244 ret <vscale x 32 x i8> %vc
247 define <vscale x 64 x i8> @vdivu_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
248 ; CHECK-LABEL: vdivu_vv_nxv64i8:
250 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
251 ; CHECK-NEXT: vdivu.vv v8, v8, v16
253 %vc = udiv <vscale x 64 x i8> %va, %vb
254 ret <vscale x 64 x i8> %vc
257 define <vscale x 64 x i8> @vdivu_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
258 ; CHECK-LABEL: vdivu_vx_nxv64i8:
260 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
261 ; CHECK-NEXT: vdivu.vx v8, v8, a0
263 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
264 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
265 %vc = udiv <vscale x 64 x i8> %va, %splat
266 ret <vscale x 64 x i8> %vc
269 define <vscale x 64 x i8> @vdivu_vi_nxv64i8_0(<vscale x 64 x i8> %va) {
270 ; CHECK-LABEL: vdivu_vi_nxv64i8_0:
272 ; CHECK-NEXT: li a0, 33
273 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
274 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
275 ; CHECK-NEXT: vsrl.vi v8, v8, 5
277 %head = insertelement <vscale x 64 x i8> poison, i8 -7, i32 0
278 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
279 %vc = udiv <vscale x 64 x i8> %va, %splat
280 ret <vscale x 64 x i8> %vc
283 define <vscale x 1 x i16> @vdivu_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
284 ; CHECK-LABEL: vdivu_vv_nxv1i16:
286 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
287 ; CHECK-NEXT: vdivu.vv v8, v8, v9
289 %vc = udiv <vscale x 1 x i16> %va, %vb
290 ret <vscale x 1 x i16> %vc
293 define <vscale x 1 x i16> @vdivu_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
294 ; CHECK-LABEL: vdivu_vx_nxv1i16:
296 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
297 ; CHECK-NEXT: vdivu.vx v8, v8, a0
299 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
300 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
301 %vc = udiv <vscale x 1 x i16> %va, %splat
302 ret <vscale x 1 x i16> %vc
305 define <vscale x 1 x i16> @vdivu_vi_nxv1i16_0(<vscale x 1 x i16> %va) {
306 ; CHECK-LABEL: vdivu_vi_nxv1i16_0:
308 ; CHECK-NEXT: lui a0, 2
309 ; CHECK-NEXT: addi a0, a0, 1
310 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
311 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
312 ; CHECK-NEXT: vsrl.vi v8, v8, 13
314 %head = insertelement <vscale x 1 x i16> poison, i16 -7, i32 0
315 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
316 %vc = udiv <vscale x 1 x i16> %va, %splat
317 ret <vscale x 1 x i16> %vc
320 define <vscale x 2 x i16> @vdivu_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
321 ; CHECK-LABEL: vdivu_vv_nxv2i16:
323 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
324 ; CHECK-NEXT: vdivu.vv v8, v8, v9
326 %vc = udiv <vscale x 2 x i16> %va, %vb
327 ret <vscale x 2 x i16> %vc
330 define <vscale x 2 x i16> @vdivu_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
331 ; CHECK-LABEL: vdivu_vx_nxv2i16:
333 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
334 ; CHECK-NEXT: vdivu.vx v8, v8, a0
336 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
337 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
338 %vc = udiv <vscale x 2 x i16> %va, %splat
339 ret <vscale x 2 x i16> %vc
342 define <vscale x 2 x i16> @vdivu_vi_nxv2i16_0(<vscale x 2 x i16> %va) {
343 ; CHECK-LABEL: vdivu_vi_nxv2i16_0:
345 ; CHECK-NEXT: lui a0, 2
346 ; CHECK-NEXT: addi a0, a0, 1
347 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
348 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
349 ; CHECK-NEXT: vsrl.vi v8, v8, 13
351 %head = insertelement <vscale x 2 x i16> poison, i16 -7, i32 0
352 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
353 %vc = udiv <vscale x 2 x i16> %va, %splat
354 ret <vscale x 2 x i16> %vc
357 define <vscale x 4 x i16> @vdivu_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
358 ; CHECK-LABEL: vdivu_vv_nxv4i16:
360 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
361 ; CHECK-NEXT: vdivu.vv v8, v8, v9
363 %vc = udiv <vscale x 4 x i16> %va, %vb
364 ret <vscale x 4 x i16> %vc
367 define <vscale x 4 x i16> @vdivu_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
368 ; CHECK-LABEL: vdivu_vx_nxv4i16:
370 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
371 ; CHECK-NEXT: vdivu.vx v8, v8, a0
373 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
374 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
375 %vc = udiv <vscale x 4 x i16> %va, %splat
376 ret <vscale x 4 x i16> %vc
379 define <vscale x 4 x i16> @vdivu_vi_nxv4i16_0(<vscale x 4 x i16> %va) {
380 ; CHECK-LABEL: vdivu_vi_nxv4i16_0:
382 ; CHECK-NEXT: lui a0, 2
383 ; CHECK-NEXT: addi a0, a0, 1
384 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
385 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
386 ; CHECK-NEXT: vsrl.vi v8, v8, 13
388 %head = insertelement <vscale x 4 x i16> poison, i16 -7, i32 0
389 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
390 %vc = udiv <vscale x 4 x i16> %va, %splat
391 ret <vscale x 4 x i16> %vc
394 define <vscale x 8 x i16> @vdivu_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
395 ; CHECK-LABEL: vdivu_vv_nxv8i16:
397 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
398 ; CHECK-NEXT: vdivu.vv v8, v8, v10
400 %vc = udiv <vscale x 8 x i16> %va, %vb
401 ret <vscale x 8 x i16> %vc
404 define <vscale x 8 x i16> @vdivu_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
405 ; CHECK-LABEL: vdivu_vx_nxv8i16:
407 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
408 ; CHECK-NEXT: vdivu.vx v8, v8, a0
410 %head = insertelement <vscale x 8 x i16> poison, i16 %b, i32 0
411 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
412 %vc = udiv <vscale x 8 x i16> %va, %splat
413 ret <vscale x 8 x i16> %vc
416 define <vscale x 8 x i16> @vdivu_vi_nxv8i16_0(<vscale x 8 x i16> %va) {
417 ; CHECK-LABEL: vdivu_vi_nxv8i16_0:
419 ; CHECK-NEXT: lui a0, 2
420 ; CHECK-NEXT: addi a0, a0, 1
421 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
422 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
423 ; CHECK-NEXT: vsrl.vi v8, v8, 13
425 %head = insertelement <vscale x 8 x i16> poison, i16 -7, i32 0
426 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
427 %vc = udiv <vscale x 8 x i16> %va, %splat
428 ret <vscale x 8 x i16> %vc
431 define <vscale x 16 x i16> @vdivu_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
432 ; CHECK-LABEL: vdivu_vv_nxv16i16:
434 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
435 ; CHECK-NEXT: vdivu.vv v8, v8, v12
437 %vc = udiv <vscale x 16 x i16> %va, %vb
438 ret <vscale x 16 x i16> %vc
441 define <vscale x 16 x i16> @vdivu_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
442 ; CHECK-LABEL: vdivu_vx_nxv16i16:
444 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
445 ; CHECK-NEXT: vdivu.vx v8, v8, a0
447 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
448 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
449 %vc = udiv <vscale x 16 x i16> %va, %splat
450 ret <vscale x 16 x i16> %vc
453 define <vscale x 16 x i16> @vdivu_vi_nxv16i16_0(<vscale x 16 x i16> %va) {
454 ; CHECK-LABEL: vdivu_vi_nxv16i16_0:
456 ; CHECK-NEXT: lui a0, 2
457 ; CHECK-NEXT: addi a0, a0, 1
458 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
459 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
460 ; CHECK-NEXT: vsrl.vi v8, v8, 13
462 %head = insertelement <vscale x 16 x i16> poison, i16 -7, i32 0
463 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
464 %vc = udiv <vscale x 16 x i16> %va, %splat
465 ret <vscale x 16 x i16> %vc
468 define <vscale x 32 x i16> @vdivu_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
469 ; CHECK-LABEL: vdivu_vv_nxv32i16:
471 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
472 ; CHECK-NEXT: vdivu.vv v8, v8, v16
474 %vc = udiv <vscale x 32 x i16> %va, %vb
475 ret <vscale x 32 x i16> %vc
478 define <vscale x 32 x i16> @vdivu_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
479 ; CHECK-LABEL: vdivu_vx_nxv32i16:
481 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
482 ; CHECK-NEXT: vdivu.vx v8, v8, a0
484 %head = insertelement <vscale x 32 x i16> poison, i16 %b, i32 0
485 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
486 %vc = udiv <vscale x 32 x i16> %va, %splat
487 ret <vscale x 32 x i16> %vc
490 define <vscale x 32 x i16> @vdivu_vi_nxv32i16_0(<vscale x 32 x i16> %va) {
491 ; CHECK-LABEL: vdivu_vi_nxv32i16_0:
493 ; CHECK-NEXT: lui a0, 2
494 ; CHECK-NEXT: addi a0, a0, 1
495 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
496 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
497 ; CHECK-NEXT: vsrl.vi v8, v8, 13
499 %head = insertelement <vscale x 32 x i16> poison, i16 -7, i32 0
500 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
501 %vc = udiv <vscale x 32 x i16> %va, %splat
502 ret <vscale x 32 x i16> %vc
505 define <vscale x 1 x i32> @vdivu_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
506 ; CHECK-LABEL: vdivu_vv_nxv1i32:
508 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
509 ; CHECK-NEXT: vdivu.vv v8, v8, v9
511 %vc = udiv <vscale x 1 x i32> %va, %vb
512 ret <vscale x 1 x i32> %vc
515 define <vscale x 1 x i32> @vdivu_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
516 ; CHECK-LABEL: vdivu_vx_nxv1i32:
518 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
519 ; CHECK-NEXT: vdivu.vx v8, v8, a0
521 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
522 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
523 %vc = udiv <vscale x 1 x i32> %va, %splat
524 ret <vscale x 1 x i32> %vc
527 define <vscale x 1 x i32> @vdivu_vi_nxv1i32_0(<vscale x 1 x i32> %va) {
528 ; CHECK-LABEL: vdivu_vi_nxv1i32_0:
530 ; CHECK-NEXT: lui a0, 131072
531 ; CHECK-NEXT: addi a0, a0, 1
532 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
533 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
534 ; CHECK-NEXT: vsrl.vi v8, v8, 29
536 %head = insertelement <vscale x 1 x i32> poison, i32 -7, i32 0
537 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
538 %vc = udiv <vscale x 1 x i32> %va, %splat
539 ret <vscale x 1 x i32> %vc
542 define <vscale x 2 x i32> @vdivu_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
543 ; CHECK-LABEL: vdivu_vv_nxv2i32:
545 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
546 ; CHECK-NEXT: vdivu.vv v8, v8, v9
548 %vc = udiv <vscale x 2 x i32> %va, %vb
549 ret <vscale x 2 x i32> %vc
552 define <vscale x 2 x i32> @vdivu_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
553 ; CHECK-LABEL: vdivu_vx_nxv2i32:
555 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
556 ; CHECK-NEXT: vdivu.vx v8, v8, a0
558 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
559 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
560 %vc = udiv <vscale x 2 x i32> %va, %splat
561 ret <vscale x 2 x i32> %vc
564 define <vscale x 2 x i32> @vdivu_vi_nxv2i32_0(<vscale x 2 x i32> %va) {
565 ; CHECK-LABEL: vdivu_vi_nxv2i32_0:
567 ; CHECK-NEXT: lui a0, 131072
568 ; CHECK-NEXT: addi a0, a0, 1
569 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
570 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
571 ; CHECK-NEXT: vsrl.vi v8, v8, 29
573 %head = insertelement <vscale x 2 x i32> poison, i32 -7, i32 0
574 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
575 %vc = udiv <vscale x 2 x i32> %va, %splat
576 ret <vscale x 2 x i32> %vc
579 define <vscale x 4 x i32> @vdivu_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
580 ; CHECK-LABEL: vdivu_vv_nxv4i32:
582 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
583 ; CHECK-NEXT: vdivu.vv v8, v8, v10
585 %vc = udiv <vscale x 4 x i32> %va, %vb
586 ret <vscale x 4 x i32> %vc
589 define <vscale x 4 x i32> @vdivu_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
590 ; CHECK-LABEL: vdivu_vx_nxv4i32:
592 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
593 ; CHECK-NEXT: vdivu.vx v8, v8, a0
595 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
596 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
597 %vc = udiv <vscale x 4 x i32> %va, %splat
598 ret <vscale x 4 x i32> %vc
601 define <vscale x 4 x i32> @vdivu_vi_nxv4i32_0(<vscale x 4 x i32> %va) {
602 ; CHECK-LABEL: vdivu_vi_nxv4i32_0:
604 ; CHECK-NEXT: lui a0, 131072
605 ; CHECK-NEXT: addi a0, a0, 1
606 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
607 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
608 ; CHECK-NEXT: vsrl.vi v8, v8, 29
610 %head = insertelement <vscale x 4 x i32> poison, i32 -7, i32 0
611 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
612 %vc = udiv <vscale x 4 x i32> %va, %splat
613 ret <vscale x 4 x i32> %vc
616 define <vscale x 8 x i32> @vdivu_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
617 ; CHECK-LABEL: vdivu_vv_nxv8i32:
619 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
620 ; CHECK-NEXT: vdivu.vv v8, v8, v12
622 %vc = udiv <vscale x 8 x i32> %va, %vb
623 ret <vscale x 8 x i32> %vc
626 define <vscale x 8 x i32> @vdivu_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
627 ; CHECK-LABEL: vdivu_vx_nxv8i32:
629 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
630 ; CHECK-NEXT: vdivu.vx v8, v8, a0
632 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
633 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
634 %vc = udiv <vscale x 8 x i32> %va, %splat
635 ret <vscale x 8 x i32> %vc
638 define <vscale x 8 x i32> @vdivu_vi_nxv8i32_0(<vscale x 8 x i32> %va) {
639 ; CHECK-LABEL: vdivu_vi_nxv8i32_0:
641 ; CHECK-NEXT: lui a0, 131072
642 ; CHECK-NEXT: addi a0, a0, 1
643 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
644 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
645 ; CHECK-NEXT: vsrl.vi v8, v8, 29
647 %head = insertelement <vscale x 8 x i32> poison, i32 -7, i32 0
648 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
649 %vc = udiv <vscale x 8 x i32> %va, %splat
650 ret <vscale x 8 x i32> %vc
653 define <vscale x 16 x i32> @vdivu_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
654 ; CHECK-LABEL: vdivu_vv_nxv16i32:
656 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
657 ; CHECK-NEXT: vdivu.vv v8, v8, v16
659 %vc = udiv <vscale x 16 x i32> %va, %vb
660 ret <vscale x 16 x i32> %vc
663 define <vscale x 16 x i32> @vdivu_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
664 ; CHECK-LABEL: vdivu_vx_nxv16i32:
666 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
667 ; CHECK-NEXT: vdivu.vx v8, v8, a0
669 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
670 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
671 %vc = udiv <vscale x 16 x i32> %va, %splat
672 ret <vscale x 16 x i32> %vc
675 define <vscale x 16 x i32> @vdivu_vi_nxv16i32_0(<vscale x 16 x i32> %va) {
676 ; CHECK-LABEL: vdivu_vi_nxv16i32_0:
678 ; CHECK-NEXT: lui a0, 131072
679 ; CHECK-NEXT: addi a0, a0, 1
680 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
681 ; CHECK-NEXT: vmulhu.vx v8, v8, a0
682 ; CHECK-NEXT: vsrl.vi v8, v8, 29
684 %head = insertelement <vscale x 16 x i32> poison, i32 -7, i32 0
685 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
686 %vc = udiv <vscale x 16 x i32> %va, %splat
687 ret <vscale x 16 x i32> %vc
690 define <vscale x 1 x i64> @vdivu_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
691 ; CHECK-LABEL: vdivu_vv_nxv1i64:
693 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
694 ; CHECK-NEXT: vdivu.vv v8, v8, v9
696 %vc = udiv <vscale x 1 x i64> %va, %vb
697 ret <vscale x 1 x i64> %vc
700 define <vscale x 1 x i64> @vdivu_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
701 ; RV32-LABEL: vdivu_vx_nxv1i64:
703 ; RV32-NEXT: addi sp, sp, -16
704 ; RV32-NEXT: .cfi_def_cfa_offset 16
705 ; RV32-NEXT: sw a1, 12(sp)
706 ; RV32-NEXT: sw a0, 8(sp)
707 ; RV32-NEXT: addi a0, sp, 8
708 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
709 ; RV32-NEXT: vlse64.v v9, (a0), zero
710 ; RV32-NEXT: vdivu.vv v8, v8, v9
711 ; RV32-NEXT: addi sp, sp, 16
714 ; RV64-LABEL: vdivu_vx_nxv1i64:
716 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
717 ; RV64-NEXT: vdivu.vx v8, v8, a0
719 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
720 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
721 %vc = udiv <vscale x 1 x i64> %va, %splat
722 ret <vscale x 1 x i64> %vc
725 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_0(<vscale x 1 x i64> %va) {
726 ; RV32-V-LABEL: vdivu_vi_nxv1i64_0:
728 ; RV32-V-NEXT: addi sp, sp, -16
729 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
730 ; RV32-V-NEXT: lui a0, 131072
731 ; RV32-V-NEXT: sw a0, 12(sp)
732 ; RV32-V-NEXT: li a0, 1
733 ; RV32-V-NEXT: sw a0, 8(sp)
734 ; RV32-V-NEXT: addi a0, sp, 8
735 ; RV32-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
736 ; RV32-V-NEXT: vlse64.v v9, (a0), zero
737 ; RV32-V-NEXT: vmulhu.vv v8, v8, v9
738 ; RV32-V-NEXT: li a0, 61
739 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
740 ; RV32-V-NEXT: addi sp, sp, 16
743 ; ZVE64X-LABEL: vdivu_vi_nxv1i64_0:
745 ; ZVE64X-NEXT: li a0, -7
746 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m1, ta, ma
747 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
750 ; RV64-V-LABEL: vdivu_vi_nxv1i64_0:
752 ; RV64-V-NEXT: li a0, 1
753 ; RV64-V-NEXT: slli a0, a0, 61
754 ; RV64-V-NEXT: addi a0, a0, 1
755 ; RV64-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
756 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
757 ; RV64-V-NEXT: li a0, 61
758 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
760 %head = insertelement <vscale x 1 x i64> poison, i64 -7, i32 0
761 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
762 %vc = udiv <vscale x 1 x i64> %va, %splat
763 ret <vscale x 1 x i64> %vc
766 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_1(<vscale x 1 x i64> %va) {
767 ; CHECK-LABEL: vdivu_vi_nxv1i64_1:
769 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
770 ; CHECK-NEXT: vsrl.vi v8, v8, 1
772 %head = insertelement <vscale x 1 x i64> poison, i64 2, i32 0
773 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
774 %vc = udiv <vscale x 1 x i64> %va, %splat
775 ret <vscale x 1 x i64> %vc
778 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
779 define <vscale x 1 x i64> @vdivu_vi_nxv1i64_2(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
780 ; CHECK-LABEL: vdivu_vi_nxv1i64_2:
782 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
783 ; CHECK-NEXT: vadd.vi v9, v9, 4
784 ; CHECK-NEXT: vsrl.vv v8, v8, v9
786 %head = insertelement <vscale x 1 x i64> poison, i64 16, i32 0
787 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
788 %vc = shl <vscale x 1 x i64> %splat, %vb
789 %vd = udiv <vscale x 1 x i64> %va, %vc
790 ret <vscale x 1 x i64> %vd
793 define <vscale x 2 x i64> @vdivu_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
794 ; CHECK-LABEL: vdivu_vv_nxv2i64:
796 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
797 ; CHECK-NEXT: vdivu.vv v8, v8, v10
799 %vc = udiv <vscale x 2 x i64> %va, %vb
800 ret <vscale x 2 x i64> %vc
803 define <vscale x 2 x i64> @vdivu_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
804 ; RV32-LABEL: vdivu_vx_nxv2i64:
806 ; RV32-NEXT: addi sp, sp, -16
807 ; RV32-NEXT: .cfi_def_cfa_offset 16
808 ; RV32-NEXT: sw a1, 12(sp)
809 ; RV32-NEXT: sw a0, 8(sp)
810 ; RV32-NEXT: addi a0, sp, 8
811 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
812 ; RV32-NEXT: vlse64.v v10, (a0), zero
813 ; RV32-NEXT: vdivu.vv v8, v8, v10
814 ; RV32-NEXT: addi sp, sp, 16
817 ; RV64-LABEL: vdivu_vx_nxv2i64:
819 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
820 ; RV64-NEXT: vdivu.vx v8, v8, a0
822 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
823 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
824 %vc = udiv <vscale x 2 x i64> %va, %splat
825 ret <vscale x 2 x i64> %vc
828 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_0(<vscale x 2 x i64> %va) {
829 ; RV32-V-LABEL: vdivu_vi_nxv2i64_0:
831 ; RV32-V-NEXT: addi sp, sp, -16
832 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
833 ; RV32-V-NEXT: lui a0, 131072
834 ; RV32-V-NEXT: sw a0, 12(sp)
835 ; RV32-V-NEXT: li a0, 1
836 ; RV32-V-NEXT: sw a0, 8(sp)
837 ; RV32-V-NEXT: addi a0, sp, 8
838 ; RV32-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
839 ; RV32-V-NEXT: vlse64.v v10, (a0), zero
840 ; RV32-V-NEXT: vmulhu.vv v8, v8, v10
841 ; RV32-V-NEXT: li a0, 61
842 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
843 ; RV32-V-NEXT: addi sp, sp, 16
846 ; ZVE64X-LABEL: vdivu_vi_nxv2i64_0:
848 ; ZVE64X-NEXT: li a0, -7
849 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m2, ta, ma
850 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
853 ; RV64-V-LABEL: vdivu_vi_nxv2i64_0:
855 ; RV64-V-NEXT: li a0, 1
856 ; RV64-V-NEXT: slli a0, a0, 61
857 ; RV64-V-NEXT: addi a0, a0, 1
858 ; RV64-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
859 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
860 ; RV64-V-NEXT: li a0, 61
861 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
863 %head = insertelement <vscale x 2 x i64> poison, i64 -7, i32 0
864 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
865 %vc = udiv <vscale x 2 x i64> %va, %splat
866 ret <vscale x 2 x i64> %vc
869 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_1(<vscale x 2 x i64> %va) {
870 ; CHECK-LABEL: vdivu_vi_nxv2i64_1:
872 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
873 ; CHECK-NEXT: vsrl.vi v8, v8, 1
875 %head = insertelement <vscale x 2 x i64> poison, i64 2, i32 0
876 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
877 %vc = udiv <vscale x 2 x i64> %va, %splat
878 ret <vscale x 2 x i64> %vc
881 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
882 define <vscale x 2 x i64> @vdivu_vi_nxv2i64_2(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
883 ; CHECK-LABEL: vdivu_vi_nxv2i64_2:
885 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
886 ; CHECK-NEXT: vadd.vi v10, v10, 4
887 ; CHECK-NEXT: vsrl.vv v8, v8, v10
889 %head = insertelement <vscale x 2 x i64> poison, i64 16, i32 0
890 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
891 %vc = shl <vscale x 2 x i64> %splat, %vb
892 %vd = udiv <vscale x 2 x i64> %va, %vc
893 ret <vscale x 2 x i64> %vd
896 define <vscale x 4 x i64> @vdivu_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
897 ; CHECK-LABEL: vdivu_vv_nxv4i64:
899 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
900 ; CHECK-NEXT: vdivu.vv v8, v8, v12
902 %vc = udiv <vscale x 4 x i64> %va, %vb
903 ret <vscale x 4 x i64> %vc
906 define <vscale x 4 x i64> @vdivu_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
907 ; RV32-LABEL: vdivu_vx_nxv4i64:
909 ; RV32-NEXT: addi sp, sp, -16
910 ; RV32-NEXT: .cfi_def_cfa_offset 16
911 ; RV32-NEXT: sw a1, 12(sp)
912 ; RV32-NEXT: sw a0, 8(sp)
913 ; RV32-NEXT: addi a0, sp, 8
914 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
915 ; RV32-NEXT: vlse64.v v12, (a0), zero
916 ; RV32-NEXT: vdivu.vv v8, v8, v12
917 ; RV32-NEXT: addi sp, sp, 16
920 ; RV64-LABEL: vdivu_vx_nxv4i64:
922 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
923 ; RV64-NEXT: vdivu.vx v8, v8, a0
925 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
926 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
927 %vc = udiv <vscale x 4 x i64> %va, %splat
928 ret <vscale x 4 x i64> %vc
931 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_0(<vscale x 4 x i64> %va) {
932 ; RV32-V-LABEL: vdivu_vi_nxv4i64_0:
934 ; RV32-V-NEXT: addi sp, sp, -16
935 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
936 ; RV32-V-NEXT: lui a0, 131072
937 ; RV32-V-NEXT: sw a0, 12(sp)
938 ; RV32-V-NEXT: li a0, 1
939 ; RV32-V-NEXT: sw a0, 8(sp)
940 ; RV32-V-NEXT: addi a0, sp, 8
941 ; RV32-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
942 ; RV32-V-NEXT: vlse64.v v12, (a0), zero
943 ; RV32-V-NEXT: vmulhu.vv v8, v8, v12
944 ; RV32-V-NEXT: li a0, 61
945 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
946 ; RV32-V-NEXT: addi sp, sp, 16
949 ; ZVE64X-LABEL: vdivu_vi_nxv4i64_0:
951 ; ZVE64X-NEXT: li a0, -7
952 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m4, ta, ma
953 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
956 ; RV64-V-LABEL: vdivu_vi_nxv4i64_0:
958 ; RV64-V-NEXT: li a0, 1
959 ; RV64-V-NEXT: slli a0, a0, 61
960 ; RV64-V-NEXT: addi a0, a0, 1
961 ; RV64-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
962 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
963 ; RV64-V-NEXT: li a0, 61
964 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
966 %head = insertelement <vscale x 4 x i64> poison, i64 -7, i32 0
967 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
968 %vc = udiv <vscale x 4 x i64> %va, %splat
969 ret <vscale x 4 x i64> %vc
972 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_1(<vscale x 4 x i64> %va) {
973 ; CHECK-LABEL: vdivu_vi_nxv4i64_1:
975 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
976 ; CHECK-NEXT: vsrl.vi v8, v8, 1
978 %head = insertelement <vscale x 4 x i64> poison, i64 2, i32 0
979 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
980 %vc = udiv <vscale x 4 x i64> %va, %splat
981 ret <vscale x 4 x i64> %vc
984 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
985 define <vscale x 4 x i64> @vdivu_vi_nxv4i64_2(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
986 ; CHECK-LABEL: vdivu_vi_nxv4i64_2:
988 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
989 ; CHECK-NEXT: vadd.vi v12, v12, 4
990 ; CHECK-NEXT: vsrl.vv v8, v8, v12
992 %head = insertelement <vscale x 4 x i64> poison, i64 16, i32 0
993 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
994 %vc = shl <vscale x 4 x i64> %splat, %vb
995 %vd = udiv <vscale x 4 x i64> %va, %vc
996 ret <vscale x 4 x i64> %vd
999 define <vscale x 8 x i64> @vdivu_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1000 ; CHECK-LABEL: vdivu_vv_nxv8i64:
1002 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1003 ; CHECK-NEXT: vdivu.vv v8, v8, v16
1005 %vc = udiv <vscale x 8 x i64> %va, %vb
1006 ret <vscale x 8 x i64> %vc
1009 define <vscale x 8 x i64> @vdivu_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
1010 ; RV32-LABEL: vdivu_vx_nxv8i64:
1012 ; RV32-NEXT: addi sp, sp, -16
1013 ; RV32-NEXT: .cfi_def_cfa_offset 16
1014 ; RV32-NEXT: sw a1, 12(sp)
1015 ; RV32-NEXT: sw a0, 8(sp)
1016 ; RV32-NEXT: addi a0, sp, 8
1017 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1018 ; RV32-NEXT: vlse64.v v16, (a0), zero
1019 ; RV32-NEXT: vdivu.vv v8, v8, v16
1020 ; RV32-NEXT: addi sp, sp, 16
1023 ; RV64-LABEL: vdivu_vx_nxv8i64:
1025 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1026 ; RV64-NEXT: vdivu.vx v8, v8, a0
1028 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
1029 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1030 %vc = udiv <vscale x 8 x i64> %va, %splat
1031 ret <vscale x 8 x i64> %vc
1034 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_0(<vscale x 8 x i64> %va) {
1035 ; RV32-V-LABEL: vdivu_vi_nxv8i64_0:
1037 ; RV32-V-NEXT: addi sp, sp, -16
1038 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1039 ; RV32-V-NEXT: lui a0, 131072
1040 ; RV32-V-NEXT: sw a0, 12(sp)
1041 ; RV32-V-NEXT: li a0, 1
1042 ; RV32-V-NEXT: sw a0, 8(sp)
1043 ; RV32-V-NEXT: addi a0, sp, 8
1044 ; RV32-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1045 ; RV32-V-NEXT: vlse64.v v16, (a0), zero
1046 ; RV32-V-NEXT: vmulhu.vv v8, v8, v16
1047 ; RV32-V-NEXT: li a0, 61
1048 ; RV32-V-NEXT: vsrl.vx v8, v8, a0
1049 ; RV32-V-NEXT: addi sp, sp, 16
1052 ; ZVE64X-LABEL: vdivu_vi_nxv8i64_0:
1054 ; ZVE64X-NEXT: li a0, -7
1055 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1056 ; ZVE64X-NEXT: vdivu.vx v8, v8, a0
1059 ; RV64-V-LABEL: vdivu_vi_nxv8i64_0:
1061 ; RV64-V-NEXT: li a0, 1
1062 ; RV64-V-NEXT: slli a0, a0, 61
1063 ; RV64-V-NEXT: addi a0, a0, 1
1064 ; RV64-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1065 ; RV64-V-NEXT: vmulhu.vx v8, v8, a0
1066 ; RV64-V-NEXT: li a0, 61
1067 ; RV64-V-NEXT: vsrl.vx v8, v8, a0
1069 %head = insertelement <vscale x 8 x i64> poison, i64 -7, i32 0
1070 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1071 %vc = udiv <vscale x 8 x i64> %va, %splat
1072 ret <vscale x 8 x i64> %vc
1075 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_1(<vscale x 8 x i64> %va) {
1076 ; CHECK-LABEL: vdivu_vi_nxv8i64_1:
1078 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1079 ; CHECK-NEXT: vsrl.vi v8, v8, 1
1081 %head = insertelement <vscale x 8 x i64> poison, i64 2, i32 0
1082 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1083 %vc = udiv <vscale x 8 x i64> %va, %splat
1084 ret <vscale x 8 x i64> %vc
1087 ; fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
1088 define <vscale x 8 x i64> @vdivu_vi_nxv8i64_2(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1089 ; CHECK-LABEL: vdivu_vi_nxv8i64_2:
1091 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1092 ; CHECK-NEXT: vadd.vi v16, v16, 4
1093 ; CHECK-NEXT: vsrl.vv v8, v8, v16
1095 %head = insertelement <vscale x 8 x i64> poison, i64 16, i32 0
1096 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1097 %vc = shl <vscale x 8 x i64> %splat, %vb
1098 %vd = udiv <vscale x 8 x i64> %va, %vc
1099 ret <vscale x 8 x i64> %vd
1102 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) {
1103 ; CHECK-LABEL: vdivu_vv_mask_nxv8i32:
1105 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
1106 ; CHECK-NEXT: vmv.v.i v16, 1
1107 ; CHECK-NEXT: vmerge.vvm v12, v16, v12, v0
1108 ; CHECK-NEXT: vdivu.vv v8, v8, v12
1110 %head = insertelement <vscale x 8 x i32> poison, i32 1, i32 0
1111 %one = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1112 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %vb, <vscale x 8 x i32> %one
1113 %vc = udiv <vscale x 8 x i32> %va, %vs
1114 ret <vscale x 8 x i32> %vc
1117 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) {
1118 ; CHECK-LABEL: vdivu_vx_mask_nxv8i32:
1120 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
1121 ; CHECK-NEXT: vmv.v.i v12, 1
1122 ; CHECK-NEXT: vmerge.vxm v12, v12, a0, v0
1123 ; CHECK-NEXT: vdivu.vv v8, v8, v12
1125 %head1 = insertelement <vscale x 8 x i32> poison, i32 1, i32 0
1126 %one = shufflevector <vscale x 8 x i32> %head1, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1127 %head2 = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
1128 %splat = shufflevector <vscale x 8 x i32> %head2, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1129 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %splat, <vscale x 8 x i32> %one
1130 %vc = udiv <vscale x 8 x i32> %va, %vs
1131 ret <vscale x 8 x i32> %vc
1134 define <vscale x 8 x i32> @vdivu_vi_mask_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i1> %mask) {
1135 ; CHECK-LABEL: vdivu_vi_mask_nxv8i32:
1137 ; CHECK-NEXT: lui a0, 149797
1138 ; CHECK-NEXT: addi a0, a0, -1755
1139 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu
1140 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
1141 ; CHECK-NEXT: vsub.vv v16, v8, v12
1142 ; CHECK-NEXT: vsrl.vi v16, v16, 1
1143 ; CHECK-NEXT: vadd.vv v12, v16, v12
1144 ; CHECK-NEXT: vsrl.vi v8, v12, 2, v0.t
1146 %head1 = insertelement <vscale x 8 x i32> poison, i32 1, i32 0
1147 %one = shufflevector <vscale x 8 x i32> %head1, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1148 %head2 = insertelement <vscale x 8 x i32> poison, i32 7, i32 0
1149 %splat = shufflevector <vscale x 8 x i32> %head2, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
1150 %vs = select <vscale x 8 x i1> %mask, <vscale x 8 x i32> %splat, <vscale x 8 x i32> %one
1151 %vc = udiv <vscale x 8 x i32> %va, %vs
1152 ret <vscale x 8 x i32> %vc