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> @vremu_vv_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb) {
8 ; CHECK-LABEL: vremu_vv_nxv1i8:
10 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
11 ; CHECK-NEXT: vremu.vv v8, v8, v9
13 %vc = urem <vscale x 1 x i8> %va, %vb
14 ret <vscale x 1 x i8> %vc
17 define <vscale x 1 x i8> @vremu_vx_nxv1i8(<vscale x 1 x i8> %va, i8 signext %b) {
18 ; CHECK-LABEL: vremu_vx_nxv1i8:
20 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
21 ; CHECK-NEXT: vremu.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 = urem <vscale x 1 x i8> %va, %splat
26 ret <vscale x 1 x i8> %vc
29 define <vscale x 1 x i8> @vremu_vi_nxv1i8_0(<vscale x 1 x i8> %va) {
30 ; CHECK-LABEL: vremu_vi_nxv1i8_0:
32 ; CHECK-NEXT: li a0, 33
33 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
34 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
35 ; CHECK-NEXT: vsrl.vi v9, v9, 5
36 ; CHECK-NEXT: li a0, -7
37 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
39 %vc = urem <vscale x 1 x i8> %va, splat (i8 -7)
40 ret <vscale x 1 x i8> %vc
43 define <vscale x 2 x i8> @vremu_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
44 ; CHECK-LABEL: vremu_vv_nxv2i8:
46 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
47 ; CHECK-NEXT: vremu.vv v8, v8, v9
49 %vc = urem <vscale x 2 x i8> %va, %vb
50 ret <vscale x 2 x i8> %vc
53 define <vscale x 2 x i8> @vremu_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
54 ; CHECK-LABEL: vremu_vx_nxv2i8:
56 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
57 ; CHECK-NEXT: vremu.vx v8, v8, a0
59 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
60 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
61 %vc = urem <vscale x 2 x i8> %va, %splat
62 ret <vscale x 2 x i8> %vc
65 define <vscale x 2 x i8> @vremu_vi_nxv2i8_0(<vscale x 2 x i8> %va) {
66 ; CHECK-LABEL: vremu_vi_nxv2i8_0:
68 ; CHECK-NEXT: li a0, 33
69 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
70 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
71 ; CHECK-NEXT: vsrl.vi v9, v9, 5
72 ; CHECK-NEXT: li a0, -7
73 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
75 %vc = urem <vscale x 2 x i8> %va, splat (i8 -7)
76 ret <vscale x 2 x i8> %vc
79 define <vscale x 4 x i8> @vremu_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
80 ; CHECK-LABEL: vremu_vv_nxv4i8:
82 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
83 ; CHECK-NEXT: vremu.vv v8, v8, v9
85 %vc = urem <vscale x 4 x i8> %va, %vb
86 ret <vscale x 4 x i8> %vc
89 define <vscale x 4 x i8> @vremu_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
90 ; CHECK-LABEL: vremu_vx_nxv4i8:
92 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
93 ; CHECK-NEXT: vremu.vx v8, v8, a0
95 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
96 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
97 %vc = urem <vscale x 4 x i8> %va, %splat
98 ret <vscale x 4 x i8> %vc
101 define <vscale x 4 x i8> @vremu_vi_nxv4i8_0(<vscale x 4 x i8> %va) {
102 ; CHECK-LABEL: vremu_vi_nxv4i8_0:
104 ; CHECK-NEXT: li a0, 33
105 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
106 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
107 ; CHECK-NEXT: vsrl.vi v9, v9, 5
108 ; CHECK-NEXT: li a0, -7
109 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
111 %vc = urem <vscale x 4 x i8> %va, splat (i8 -7)
112 ret <vscale x 4 x i8> %vc
115 define <vscale x 8 x i8> @vremu_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
116 ; CHECK-LABEL: vremu_vv_nxv8i8:
118 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
119 ; CHECK-NEXT: vremu.vv v8, v8, v9
121 %vc = urem <vscale x 8 x i8> %va, %vb
122 ret <vscale x 8 x i8> %vc
125 define <vscale x 8 x i8> @vremu_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
126 ; CHECK-LABEL: vremu_vx_nxv8i8:
128 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
129 ; CHECK-NEXT: vremu.vx v8, v8, a0
131 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
132 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
133 %vc = urem <vscale x 8 x i8> %va, %splat
134 ret <vscale x 8 x i8> %vc
137 define <vscale x 8 x i8> @vremu_vi_nxv8i8_0(<vscale x 8 x i8> %va) {
138 ; CHECK-LABEL: vremu_vi_nxv8i8_0:
140 ; CHECK-NEXT: li a0, 33
141 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
142 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
143 ; CHECK-NEXT: vsrl.vi v9, v9, 5
144 ; CHECK-NEXT: li a0, -7
145 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
147 %vc = urem <vscale x 8 x i8> %va, splat (i8 -7)
148 ret <vscale x 8 x i8> %vc
151 define <vscale x 16 x i8> @vremu_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
152 ; CHECK-LABEL: vremu_vv_nxv16i8:
154 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
155 ; CHECK-NEXT: vremu.vv v8, v8, v10
157 %vc = urem <vscale x 16 x i8> %va, %vb
158 ret <vscale x 16 x i8> %vc
161 define <vscale x 16 x i8> @vremu_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
162 ; CHECK-LABEL: vremu_vx_nxv16i8:
164 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
165 ; CHECK-NEXT: vremu.vx v8, v8, a0
167 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
168 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
169 %vc = urem <vscale x 16 x i8> %va, %splat
170 ret <vscale x 16 x i8> %vc
173 define <vscale x 16 x i8> @vremu_vi_nxv16i8_0(<vscale x 16 x i8> %va) {
174 ; CHECK-LABEL: vremu_vi_nxv16i8_0:
176 ; CHECK-NEXT: li a0, 33
177 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
178 ; CHECK-NEXT: vmulhu.vx v10, v8, a0
179 ; CHECK-NEXT: vsrl.vi v10, v10, 5
180 ; CHECK-NEXT: li a0, -7
181 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
183 %vc = urem <vscale x 16 x i8> %va, splat (i8 -7)
184 ret <vscale x 16 x i8> %vc
187 define <vscale x 32 x i8> @vremu_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
188 ; CHECK-LABEL: vremu_vv_nxv32i8:
190 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
191 ; CHECK-NEXT: vremu.vv v8, v8, v12
193 %vc = urem <vscale x 32 x i8> %va, %vb
194 ret <vscale x 32 x i8> %vc
197 define <vscale x 32 x i8> @vremu_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
198 ; CHECK-LABEL: vremu_vx_nxv32i8:
200 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
201 ; CHECK-NEXT: vremu.vx v8, v8, a0
203 %head = insertelement <vscale x 32 x i8> poison, i8 %b, i32 0
204 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
205 %vc = urem <vscale x 32 x i8> %va, %splat
206 ret <vscale x 32 x i8> %vc
209 define <vscale x 32 x i8> @vremu_vi_nxv32i8_0(<vscale x 32 x i8> %va) {
210 ; CHECK-LABEL: vremu_vi_nxv32i8_0:
212 ; CHECK-NEXT: li a0, 33
213 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
214 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
215 ; CHECK-NEXT: vsrl.vi v12, v12, 5
216 ; CHECK-NEXT: li a0, -7
217 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
219 %vc = urem <vscale x 32 x i8> %va, splat (i8 -7)
220 ret <vscale x 32 x i8> %vc
223 define <vscale x 64 x i8> @vremu_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
224 ; CHECK-LABEL: vremu_vv_nxv64i8:
226 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
227 ; CHECK-NEXT: vremu.vv v8, v8, v16
229 %vc = urem <vscale x 64 x i8> %va, %vb
230 ret <vscale x 64 x i8> %vc
233 define <vscale x 64 x i8> @vremu_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
234 ; CHECK-LABEL: vremu_vx_nxv64i8:
236 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
237 ; CHECK-NEXT: vremu.vx v8, v8, a0
239 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
240 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
241 %vc = urem <vscale x 64 x i8> %va, %splat
242 ret <vscale x 64 x i8> %vc
245 define <vscale x 64 x i8> @vremu_vi_nxv64i8_0(<vscale x 64 x i8> %va) {
246 ; CHECK-LABEL: vremu_vi_nxv64i8_0:
248 ; CHECK-NEXT: li a0, 33
249 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
250 ; CHECK-NEXT: vmulhu.vx v16, v8, a0
251 ; CHECK-NEXT: vsrl.vi v16, v16, 5
252 ; CHECK-NEXT: li a0, -7
253 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
255 %vc = urem <vscale x 64 x i8> %va, splat (i8 -7)
256 ret <vscale x 64 x i8> %vc
259 define <vscale x 1 x i16> @vremu_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
260 ; CHECK-LABEL: vremu_vv_nxv1i16:
262 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
263 ; CHECK-NEXT: vremu.vv v8, v8, v9
265 %vc = urem <vscale x 1 x i16> %va, %vb
266 ret <vscale x 1 x i16> %vc
269 define <vscale x 1 x i16> @vremu_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
270 ; CHECK-LABEL: vremu_vx_nxv1i16:
272 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
273 ; CHECK-NEXT: vremu.vx v8, v8, a0
275 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
276 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
277 %vc = urem <vscale x 1 x i16> %va, %splat
278 ret <vscale x 1 x i16> %vc
281 define <vscale x 1 x i16> @vremu_vi_nxv1i16_0(<vscale x 1 x i16> %va) {
282 ; CHECK-LABEL: vremu_vi_nxv1i16_0:
284 ; CHECK-NEXT: lui a0, 2
285 ; CHECK-NEXT: addi a0, a0, 1
286 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
287 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
288 ; CHECK-NEXT: vsrl.vi v9, v9, 13
289 ; CHECK-NEXT: li a0, -7
290 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
292 %vc = urem <vscale x 1 x i16> %va, splat (i16 -7)
293 ret <vscale x 1 x i16> %vc
296 define <vscale x 2 x i16> @vremu_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
297 ; CHECK-LABEL: vremu_vv_nxv2i16:
299 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
300 ; CHECK-NEXT: vremu.vv v8, v8, v9
302 %vc = urem <vscale x 2 x i16> %va, %vb
303 ret <vscale x 2 x i16> %vc
306 define <vscale x 2 x i16> @vremu_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
307 ; CHECK-LABEL: vremu_vx_nxv2i16:
309 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
310 ; CHECK-NEXT: vremu.vx v8, v8, a0
312 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
313 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
314 %vc = urem <vscale x 2 x i16> %va, %splat
315 ret <vscale x 2 x i16> %vc
318 define <vscale x 2 x i16> @vremu_vi_nxv2i16_0(<vscale x 2 x i16> %va) {
319 ; CHECK-LABEL: vremu_vi_nxv2i16_0:
321 ; CHECK-NEXT: lui a0, 2
322 ; CHECK-NEXT: addi a0, a0, 1
323 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
324 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
325 ; CHECK-NEXT: vsrl.vi v9, v9, 13
326 ; CHECK-NEXT: li a0, -7
327 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
329 %vc = urem <vscale x 2 x i16> %va, splat (i16 -7)
330 ret <vscale x 2 x i16> %vc
333 define <vscale x 4 x i16> @vremu_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
334 ; CHECK-LABEL: vremu_vv_nxv4i16:
336 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
337 ; CHECK-NEXT: vremu.vv v8, v8, v9
339 %vc = urem <vscale x 4 x i16> %va, %vb
340 ret <vscale x 4 x i16> %vc
343 define <vscale x 4 x i16> @vremu_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
344 ; CHECK-LABEL: vremu_vx_nxv4i16:
346 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
347 ; CHECK-NEXT: vremu.vx v8, v8, a0
349 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
350 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
351 %vc = urem <vscale x 4 x i16> %va, %splat
352 ret <vscale x 4 x i16> %vc
355 define <vscale x 4 x i16> @vremu_vi_nxv4i16_0(<vscale x 4 x i16> %va) {
356 ; CHECK-LABEL: vremu_vi_nxv4i16_0:
358 ; CHECK-NEXT: lui a0, 2
359 ; CHECK-NEXT: addi a0, a0, 1
360 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
361 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
362 ; CHECK-NEXT: vsrl.vi v9, v9, 13
363 ; CHECK-NEXT: li a0, -7
364 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
366 %vc = urem <vscale x 4 x i16> %va, splat (i16 -7)
367 ret <vscale x 4 x i16> %vc
370 define <vscale x 8 x i16> @vremu_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
371 ; CHECK-LABEL: vremu_vv_nxv8i16:
373 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
374 ; CHECK-NEXT: vremu.vv v8, v8, v10
376 %vc = urem <vscale x 8 x i16> %va, %vb
377 ret <vscale x 8 x i16> %vc
380 define <vscale x 8 x i16> @vremu_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
381 ; CHECK-LABEL: vremu_vx_nxv8i16:
383 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
384 ; CHECK-NEXT: vremu.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 = urem <vscale x 8 x i16> %va, %splat
389 ret <vscale x 8 x i16> %vc
392 define <vscale x 8 x i16> @vremu_vi_nxv8i16_0(<vscale x 8 x i16> %va) {
393 ; CHECK-LABEL: vremu_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 v10, v8, a0
399 ; CHECK-NEXT: vsrl.vi v10, v10, 13
400 ; CHECK-NEXT: li a0, -7
401 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
403 %vc = urem <vscale x 8 x i16> %va, splat (i16 -7)
404 ret <vscale x 8 x i16> %vc
407 define <vscale x 16 x i16> @vremu_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
408 ; CHECK-LABEL: vremu_vv_nxv16i16:
410 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
411 ; CHECK-NEXT: vremu.vv v8, v8, v12
413 %vc = urem <vscale x 16 x i16> %va, %vb
414 ret <vscale x 16 x i16> %vc
417 define <vscale x 16 x i16> @vremu_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
418 ; CHECK-LABEL: vremu_vx_nxv16i16:
420 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
421 ; CHECK-NEXT: vremu.vx v8, v8, a0
423 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
424 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
425 %vc = urem <vscale x 16 x i16> %va, %splat
426 ret <vscale x 16 x i16> %vc
429 define <vscale x 16 x i16> @vremu_vi_nxv16i16_0(<vscale x 16 x i16> %va) {
430 ; CHECK-LABEL: vremu_vi_nxv16i16_0:
432 ; CHECK-NEXT: lui a0, 2
433 ; CHECK-NEXT: addi a0, a0, 1
434 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
435 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
436 ; CHECK-NEXT: vsrl.vi v12, v12, 13
437 ; CHECK-NEXT: li a0, -7
438 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
440 %vc = urem <vscale x 16 x i16> %va, splat (i16 -7)
441 ret <vscale x 16 x i16> %vc
444 define <vscale x 32 x i16> @vremu_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
445 ; CHECK-LABEL: vremu_vv_nxv32i16:
447 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
448 ; CHECK-NEXT: vremu.vv v8, v8, v16
450 %vc = urem <vscale x 32 x i16> %va, %vb
451 ret <vscale x 32 x i16> %vc
454 define <vscale x 32 x i16> @vremu_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
455 ; CHECK-LABEL: vremu_vx_nxv32i16:
457 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
458 ; CHECK-NEXT: vremu.vx v8, v8, a0
460 %head = insertelement <vscale x 32 x i16> poison, i16 %b, i32 0
461 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
462 %vc = urem <vscale x 32 x i16> %va, %splat
463 ret <vscale x 32 x i16> %vc
466 define <vscale x 32 x i16> @vremu_vi_nxv32i16_0(<vscale x 32 x i16> %va) {
467 ; CHECK-LABEL: vremu_vi_nxv32i16_0:
469 ; CHECK-NEXT: lui a0, 2
470 ; CHECK-NEXT: addi a0, a0, 1
471 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
472 ; CHECK-NEXT: vmulhu.vx v16, v8, a0
473 ; CHECK-NEXT: vsrl.vi v16, v16, 13
474 ; CHECK-NEXT: li a0, -7
475 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
477 %vc = urem <vscale x 32 x i16> %va, splat (i16 -7)
478 ret <vscale x 32 x i16> %vc
481 define <vscale x 1 x i32> @vremu_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
482 ; CHECK-LABEL: vremu_vv_nxv1i32:
484 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
485 ; CHECK-NEXT: vremu.vv v8, v8, v9
487 %vc = urem <vscale x 1 x i32> %va, %vb
488 ret <vscale x 1 x i32> %vc
491 define <vscale x 1 x i32> @vremu_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
492 ; CHECK-LABEL: vremu_vx_nxv1i32:
494 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
495 ; CHECK-NEXT: vremu.vx v8, v8, a0
497 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
498 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
499 %vc = urem <vscale x 1 x i32> %va, %splat
500 ret <vscale x 1 x i32> %vc
503 define <vscale x 1 x i32> @vremu_vi_nxv1i32_0(<vscale x 1 x i32> %va) {
504 ; CHECK-LABEL: vremu_vi_nxv1i32_0:
506 ; CHECK-NEXT: lui a0, 131072
507 ; CHECK-NEXT: addi a0, a0, 1
508 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
509 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
510 ; CHECK-NEXT: vsrl.vi v9, v9, 29
511 ; CHECK-NEXT: li a0, -7
512 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
514 %vc = urem <vscale x 1 x i32> %va, splat (i32 -7)
515 ret <vscale x 1 x i32> %vc
518 define <vscale x 2 x i32> @vremu_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
519 ; CHECK-LABEL: vremu_vv_nxv2i32:
521 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
522 ; CHECK-NEXT: vremu.vv v8, v8, v9
524 %vc = urem <vscale x 2 x i32> %va, %vb
525 ret <vscale x 2 x i32> %vc
528 define <vscale x 2 x i32> @vremu_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
529 ; CHECK-LABEL: vremu_vx_nxv2i32:
531 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
532 ; CHECK-NEXT: vremu.vx v8, v8, a0
534 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
535 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
536 %vc = urem <vscale x 2 x i32> %va, %splat
537 ret <vscale x 2 x i32> %vc
540 define <vscale x 2 x i32> @vremu_vi_nxv2i32_0(<vscale x 2 x i32> %va) {
541 ; CHECK-LABEL: vremu_vi_nxv2i32_0:
543 ; CHECK-NEXT: lui a0, 131072
544 ; CHECK-NEXT: addi a0, a0, 1
545 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
546 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
547 ; CHECK-NEXT: vsrl.vi v9, v9, 29
548 ; CHECK-NEXT: li a0, -7
549 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
551 %vc = urem <vscale x 2 x i32> %va, splat (i32 -7)
552 ret <vscale x 2 x i32> %vc
555 define <vscale x 4 x i32> @vremu_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
556 ; CHECK-LABEL: vremu_vv_nxv4i32:
558 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
559 ; CHECK-NEXT: vremu.vv v8, v8, v10
561 %vc = urem <vscale x 4 x i32> %va, %vb
562 ret <vscale x 4 x i32> %vc
565 define <vscale x 4 x i32> @vremu_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
566 ; CHECK-LABEL: vremu_vx_nxv4i32:
568 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
569 ; CHECK-NEXT: vremu.vx v8, v8, a0
571 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
572 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
573 %vc = urem <vscale x 4 x i32> %va, %splat
574 ret <vscale x 4 x i32> %vc
577 define <vscale x 4 x i32> @vremu_vi_nxv4i32_0(<vscale x 4 x i32> %va) {
578 ; CHECK-LABEL: vremu_vi_nxv4i32_0:
580 ; CHECK-NEXT: lui a0, 131072
581 ; CHECK-NEXT: addi a0, a0, 1
582 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
583 ; CHECK-NEXT: vmulhu.vx v10, v8, a0
584 ; CHECK-NEXT: vsrl.vi v10, v10, 29
585 ; CHECK-NEXT: li a0, -7
586 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
588 %vc = urem <vscale x 4 x i32> %va, splat (i32 -7)
589 ret <vscale x 4 x i32> %vc
592 define <vscale x 8 x i32> @vremu_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
593 ; CHECK-LABEL: vremu_vv_nxv8i32:
595 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
596 ; CHECK-NEXT: vremu.vv v8, v8, v12
598 %vc = urem <vscale x 8 x i32> %va, %vb
599 ret <vscale x 8 x i32> %vc
602 define <vscale x 8 x i32> @vremu_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
603 ; CHECK-LABEL: vremu_vx_nxv8i32:
605 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
606 ; CHECK-NEXT: vremu.vx v8, v8, a0
608 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
609 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
610 %vc = urem <vscale x 8 x i32> %va, %splat
611 ret <vscale x 8 x i32> %vc
614 define <vscale x 8 x i32> @vremu_vi_nxv8i32_0(<vscale x 8 x i32> %va) {
615 ; CHECK-LABEL: vremu_vi_nxv8i32_0:
617 ; CHECK-NEXT: lui a0, 131072
618 ; CHECK-NEXT: addi a0, a0, 1
619 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
620 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
621 ; CHECK-NEXT: vsrl.vi v12, v12, 29
622 ; CHECK-NEXT: li a0, -7
623 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
625 %vc = urem <vscale x 8 x i32> %va, splat (i32 -7)
626 ret <vscale x 8 x i32> %vc
629 define <vscale x 16 x i32> @vremu_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
630 ; CHECK-LABEL: vremu_vv_nxv16i32:
632 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
633 ; CHECK-NEXT: vremu.vv v8, v8, v16
635 %vc = urem <vscale x 16 x i32> %va, %vb
636 ret <vscale x 16 x i32> %vc
639 define <vscale x 16 x i32> @vremu_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
640 ; CHECK-LABEL: vremu_vx_nxv16i32:
642 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
643 ; CHECK-NEXT: vremu.vx v8, v8, a0
645 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
646 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
647 %vc = urem <vscale x 16 x i32> %va, %splat
648 ret <vscale x 16 x i32> %vc
651 define <vscale x 16 x i32> @vremu_vi_nxv16i32_0(<vscale x 16 x i32> %va) {
652 ; CHECK-LABEL: vremu_vi_nxv16i32_0:
654 ; CHECK-NEXT: lui a0, 131072
655 ; CHECK-NEXT: addi a0, a0, 1
656 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
657 ; CHECK-NEXT: vmulhu.vx v16, v8, a0
658 ; CHECK-NEXT: vsrl.vi v16, v16, 29
659 ; CHECK-NEXT: li a0, -7
660 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
662 %vc = urem <vscale x 16 x i32> %va, splat (i32 -7)
663 ret <vscale x 16 x i32> %vc
666 define <vscale x 1 x i64> @vremu_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
667 ; CHECK-LABEL: vremu_vv_nxv1i64:
669 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
670 ; CHECK-NEXT: vremu.vv v8, v8, v9
672 %vc = urem <vscale x 1 x i64> %va, %vb
673 ret <vscale x 1 x i64> %vc
676 define <vscale x 1 x i64> @vremu_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
677 ; RV32-LABEL: vremu_vx_nxv1i64:
679 ; RV32-NEXT: addi sp, sp, -16
680 ; RV32-NEXT: .cfi_def_cfa_offset 16
681 ; RV32-NEXT: sw a1, 12(sp)
682 ; RV32-NEXT: sw a0, 8(sp)
683 ; RV32-NEXT: addi a0, sp, 8
684 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
685 ; RV32-NEXT: vlse64.v v9, (a0), zero
686 ; RV32-NEXT: vremu.vv v8, v8, v9
687 ; RV32-NEXT: addi sp, sp, 16
690 ; RV64-LABEL: vremu_vx_nxv1i64:
692 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
693 ; RV64-NEXT: vremu.vx v8, v8, a0
695 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
696 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
697 %vc = urem <vscale x 1 x i64> %va, %splat
698 ret <vscale x 1 x i64> %vc
701 define <vscale x 1 x i64> @vremu_vi_nxv1i64_0(<vscale x 1 x i64> %va) {
702 ; RV32-V-LABEL: vremu_vi_nxv1i64_0:
704 ; RV32-V-NEXT: addi sp, sp, -16
705 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
706 ; RV32-V-NEXT: lui a0, 131072
707 ; RV32-V-NEXT: sw a0, 12(sp)
708 ; RV32-V-NEXT: li a0, 1
709 ; RV32-V-NEXT: sw a0, 8(sp)
710 ; RV32-V-NEXT: addi a0, sp, 8
711 ; RV32-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
712 ; RV32-V-NEXT: vlse64.v v9, (a0), zero
713 ; RV32-V-NEXT: vmulhu.vv v9, v8, v9
714 ; RV32-V-NEXT: li a0, 61
715 ; RV32-V-NEXT: vsrl.vx v9, v9, a0
716 ; RV32-V-NEXT: li a0, -7
717 ; RV32-V-NEXT: vnmsac.vx v8, a0, v9
718 ; RV32-V-NEXT: addi sp, sp, 16
721 ; ZVE64X-LABEL: vremu_vi_nxv1i64_0:
723 ; ZVE64X-NEXT: li a0, -7
724 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m1, ta, ma
725 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
728 ; RV64-V-LABEL: vremu_vi_nxv1i64_0:
730 ; RV64-V-NEXT: li a0, 1
731 ; RV64-V-NEXT: slli a0, a0, 61
732 ; RV64-V-NEXT: addi a0, a0, 1
733 ; RV64-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
734 ; RV64-V-NEXT: vmulhu.vx v9, v8, a0
735 ; RV64-V-NEXT: li a0, 61
736 ; RV64-V-NEXT: vsrl.vx v9, v9, a0
737 ; RV64-V-NEXT: li a0, -7
738 ; RV64-V-NEXT: vnmsac.vx v8, a0, v9
740 %vc = urem <vscale x 1 x i64> %va, splat (i64 -7)
741 ret <vscale x 1 x i64> %vc
744 ; fold (urem x, pow2) -> (and x, pow2-1)
745 define <vscale x 1 x i64> @vremu_vi_nxv1i64_1(<vscale x 1 x i64> %va) {
746 ; CHECK-LABEL: vremu_vi_nxv1i64_1:
748 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
749 ; CHECK-NEXT: vand.vi v8, v8, 15
751 %vc = urem <vscale x 1 x i64> %va, splat (i64 16)
752 ret <vscale x 1 x i64> %vc
755 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
756 define <vscale x 1 x i64> @vremu_vi_nxv1i64_2(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
757 ; CHECK-LABEL: vremu_vi_nxv1i64_2:
759 ; CHECK-NEXT: li a0, 16
760 ; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma
761 ; CHECK-NEXT: vmv.v.x v10, a0
762 ; CHECK-NEXT: vsll.vv v9, v10, v9
763 ; CHECK-NEXT: vadd.vi v9, v9, -1
764 ; CHECK-NEXT: vand.vv v8, v8, v9
766 %vc = shl <vscale x 1 x i64> splat (i64 16), %vb
767 %vd = urem <vscale x 1 x i64> %va, %vc
768 ret <vscale x 1 x i64> %vd
771 define <vscale x 2 x i64> @vremu_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
772 ; CHECK-LABEL: vremu_vv_nxv2i64:
774 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
775 ; CHECK-NEXT: vremu.vv v8, v8, v10
777 %vc = urem <vscale x 2 x i64> %va, %vb
778 ret <vscale x 2 x i64> %vc
781 define <vscale x 2 x i64> @vremu_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
782 ; RV32-LABEL: vremu_vx_nxv2i64:
784 ; RV32-NEXT: addi sp, sp, -16
785 ; RV32-NEXT: .cfi_def_cfa_offset 16
786 ; RV32-NEXT: sw a1, 12(sp)
787 ; RV32-NEXT: sw a0, 8(sp)
788 ; RV32-NEXT: addi a0, sp, 8
789 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
790 ; RV32-NEXT: vlse64.v v10, (a0), zero
791 ; RV32-NEXT: vremu.vv v8, v8, v10
792 ; RV32-NEXT: addi sp, sp, 16
795 ; RV64-LABEL: vremu_vx_nxv2i64:
797 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
798 ; RV64-NEXT: vremu.vx v8, v8, a0
800 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
801 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
802 %vc = urem <vscale x 2 x i64> %va, %splat
803 ret <vscale x 2 x i64> %vc
806 define <vscale x 2 x i64> @vremu_vi_nxv2i64_0(<vscale x 2 x i64> %va) {
807 ; RV32-V-LABEL: vremu_vi_nxv2i64_0:
809 ; RV32-V-NEXT: addi sp, sp, -16
810 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
811 ; RV32-V-NEXT: lui a0, 131072
812 ; RV32-V-NEXT: sw a0, 12(sp)
813 ; RV32-V-NEXT: li a0, 1
814 ; RV32-V-NEXT: sw a0, 8(sp)
815 ; RV32-V-NEXT: addi a0, sp, 8
816 ; RV32-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
817 ; RV32-V-NEXT: vlse64.v v10, (a0), zero
818 ; RV32-V-NEXT: vmulhu.vv v10, v8, v10
819 ; RV32-V-NEXT: li a0, 61
820 ; RV32-V-NEXT: vsrl.vx v10, v10, a0
821 ; RV32-V-NEXT: li a0, -7
822 ; RV32-V-NEXT: vnmsac.vx v8, a0, v10
823 ; RV32-V-NEXT: addi sp, sp, 16
826 ; ZVE64X-LABEL: vremu_vi_nxv2i64_0:
828 ; ZVE64X-NEXT: li a0, -7
829 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m2, ta, ma
830 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
833 ; RV64-V-LABEL: vremu_vi_nxv2i64_0:
835 ; RV64-V-NEXT: li a0, 1
836 ; RV64-V-NEXT: slli a0, a0, 61
837 ; RV64-V-NEXT: addi a0, a0, 1
838 ; RV64-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
839 ; RV64-V-NEXT: vmulhu.vx v10, v8, a0
840 ; RV64-V-NEXT: li a0, 61
841 ; RV64-V-NEXT: vsrl.vx v10, v10, a0
842 ; RV64-V-NEXT: li a0, -7
843 ; RV64-V-NEXT: vnmsac.vx v8, a0, v10
845 %vc = urem <vscale x 2 x i64> %va, splat (i64 -7)
846 ret <vscale x 2 x i64> %vc
849 ; fold (urem x, pow2) -> (and x, pow2-1)
850 define <vscale x 2 x i64> @vremu_vi_nxv2i64_1(<vscale x 2 x i64> %va) {
851 ; CHECK-LABEL: vremu_vi_nxv2i64_1:
853 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
854 ; CHECK-NEXT: vand.vi v8, v8, 15
856 %vc = urem <vscale x 2 x i64> %va, splat (i64 16)
857 ret <vscale x 2 x i64> %vc
860 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
861 define <vscale x 2 x i64> @vremu_vi_nxv2i64_2(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
862 ; CHECK-LABEL: vremu_vi_nxv2i64_2:
864 ; CHECK-NEXT: li a0, 16
865 ; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma
866 ; CHECK-NEXT: vmv.v.x v12, a0
867 ; CHECK-NEXT: vsll.vv v10, v12, v10
868 ; CHECK-NEXT: vadd.vi v10, v10, -1
869 ; CHECK-NEXT: vand.vv v8, v8, v10
871 %vc = shl <vscale x 2 x i64> splat (i64 16), %vb
872 %vd = urem <vscale x 2 x i64> %va, %vc
873 ret <vscale x 2 x i64> %vd
876 define <vscale x 4 x i64> @vremu_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
877 ; CHECK-LABEL: vremu_vv_nxv4i64:
879 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
880 ; CHECK-NEXT: vremu.vv v8, v8, v12
882 %vc = urem <vscale x 4 x i64> %va, %vb
883 ret <vscale x 4 x i64> %vc
886 define <vscale x 4 x i64> @vremu_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
887 ; RV32-LABEL: vremu_vx_nxv4i64:
889 ; RV32-NEXT: addi sp, sp, -16
890 ; RV32-NEXT: .cfi_def_cfa_offset 16
891 ; RV32-NEXT: sw a1, 12(sp)
892 ; RV32-NEXT: sw a0, 8(sp)
893 ; RV32-NEXT: addi a0, sp, 8
894 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
895 ; RV32-NEXT: vlse64.v v12, (a0), zero
896 ; RV32-NEXT: vremu.vv v8, v8, v12
897 ; RV32-NEXT: addi sp, sp, 16
900 ; RV64-LABEL: vremu_vx_nxv4i64:
902 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
903 ; RV64-NEXT: vremu.vx v8, v8, a0
905 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
906 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
907 %vc = urem <vscale x 4 x i64> %va, %splat
908 ret <vscale x 4 x i64> %vc
911 define <vscale x 4 x i64> @vremu_vi_nxv4i64_0(<vscale x 4 x i64> %va) {
912 ; RV32-V-LABEL: vremu_vi_nxv4i64_0:
914 ; RV32-V-NEXT: addi sp, sp, -16
915 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
916 ; RV32-V-NEXT: lui a0, 131072
917 ; RV32-V-NEXT: sw a0, 12(sp)
918 ; RV32-V-NEXT: li a0, 1
919 ; RV32-V-NEXT: sw a0, 8(sp)
920 ; RV32-V-NEXT: addi a0, sp, 8
921 ; RV32-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
922 ; RV32-V-NEXT: vlse64.v v12, (a0), zero
923 ; RV32-V-NEXT: vmulhu.vv v12, v8, v12
924 ; RV32-V-NEXT: li a0, 61
925 ; RV32-V-NEXT: vsrl.vx v12, v12, a0
926 ; RV32-V-NEXT: li a0, -7
927 ; RV32-V-NEXT: vnmsac.vx v8, a0, v12
928 ; RV32-V-NEXT: addi sp, sp, 16
931 ; ZVE64X-LABEL: vremu_vi_nxv4i64_0:
933 ; ZVE64X-NEXT: li a0, -7
934 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m4, ta, ma
935 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
938 ; RV64-V-LABEL: vremu_vi_nxv4i64_0:
940 ; RV64-V-NEXT: li a0, 1
941 ; RV64-V-NEXT: slli a0, a0, 61
942 ; RV64-V-NEXT: addi a0, a0, 1
943 ; RV64-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
944 ; RV64-V-NEXT: vmulhu.vx v12, v8, a0
945 ; RV64-V-NEXT: li a0, 61
946 ; RV64-V-NEXT: vsrl.vx v12, v12, a0
947 ; RV64-V-NEXT: li a0, -7
948 ; RV64-V-NEXT: vnmsac.vx v8, a0, v12
950 %vc = urem <vscale x 4 x i64> %va, splat (i64 -7)
951 ret <vscale x 4 x i64> %vc
954 ; fold (urem x, pow2) -> (and x, pow2-1)
955 define <vscale x 4 x i64> @vremu_vi_nxv4i64_1(<vscale x 4 x i64> %va) {
956 ; CHECK-LABEL: vremu_vi_nxv4i64_1:
958 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
959 ; CHECK-NEXT: vand.vi v8, v8, 15
961 %vc = urem <vscale x 4 x i64> %va, splat (i64 16)
962 ret <vscale x 4 x i64> %vc
965 ;fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
966 define <vscale x 4 x i64> @vremu_vi_nxv4i64_2(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
967 ; CHECK-LABEL: vremu_vi_nxv4i64_2:
969 ; CHECK-NEXT: li a0, 16
970 ; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma
971 ; CHECK-NEXT: vmv.v.x v16, a0
972 ; CHECK-NEXT: vsll.vv v12, v16, v12
973 ; CHECK-NEXT: vadd.vi v12, v12, -1
974 ; CHECK-NEXT: vand.vv v8, v8, v12
976 %vc = shl <vscale x 4 x i64> splat (i64 16), %vb
977 %vd = urem <vscale x 4 x i64> %va, %vc
978 ret <vscale x 4 x i64> %vd
981 define <vscale x 8 x i64> @vremu_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
982 ; CHECK-LABEL: vremu_vv_nxv8i64:
984 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
985 ; CHECK-NEXT: vremu.vv v8, v8, v16
987 %vc = urem <vscale x 8 x i64> %va, %vb
988 ret <vscale x 8 x i64> %vc
991 define <vscale x 8 x i64> @vremu_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
992 ; RV32-LABEL: vremu_vx_nxv8i64:
994 ; RV32-NEXT: addi sp, sp, -16
995 ; RV32-NEXT: .cfi_def_cfa_offset 16
996 ; RV32-NEXT: sw a1, 12(sp)
997 ; RV32-NEXT: sw a0, 8(sp)
998 ; RV32-NEXT: addi a0, sp, 8
999 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1000 ; RV32-NEXT: vlse64.v v16, (a0), zero
1001 ; RV32-NEXT: vremu.vv v8, v8, v16
1002 ; RV32-NEXT: addi sp, sp, 16
1005 ; RV64-LABEL: vremu_vx_nxv8i64:
1007 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1008 ; RV64-NEXT: vremu.vx v8, v8, a0
1010 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
1011 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1012 %vc = urem <vscale x 8 x i64> %va, %splat
1013 ret <vscale x 8 x i64> %vc
1016 define <vscale x 8 x i64> @vremu_vi_nxv8i64_0(<vscale x 8 x i64> %va) {
1017 ; RV32-V-LABEL: vremu_vi_nxv8i64_0:
1019 ; RV32-V-NEXT: addi sp, sp, -16
1020 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1021 ; RV32-V-NEXT: lui a0, 131072
1022 ; RV32-V-NEXT: sw a0, 12(sp)
1023 ; RV32-V-NEXT: li a0, 1
1024 ; RV32-V-NEXT: sw a0, 8(sp)
1025 ; RV32-V-NEXT: addi a0, sp, 8
1026 ; RV32-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1027 ; RV32-V-NEXT: vlse64.v v16, (a0), zero
1028 ; RV32-V-NEXT: vmulhu.vv v16, v8, v16
1029 ; RV32-V-NEXT: li a0, 61
1030 ; RV32-V-NEXT: vsrl.vx v16, v16, a0
1031 ; RV32-V-NEXT: li a0, -7
1032 ; RV32-V-NEXT: vnmsac.vx v8, a0, v16
1033 ; RV32-V-NEXT: addi sp, sp, 16
1036 ; ZVE64X-LABEL: vremu_vi_nxv8i64_0:
1038 ; ZVE64X-NEXT: li a0, -7
1039 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1040 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
1043 ; RV64-V-LABEL: vremu_vi_nxv8i64_0:
1045 ; RV64-V-NEXT: li a0, 1
1046 ; RV64-V-NEXT: slli a0, a0, 61
1047 ; RV64-V-NEXT: addi a0, a0, 1
1048 ; RV64-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1049 ; RV64-V-NEXT: vmulhu.vx v16, v8, a0
1050 ; RV64-V-NEXT: li a0, 61
1051 ; RV64-V-NEXT: vsrl.vx v16, v16, a0
1052 ; RV64-V-NEXT: li a0, -7
1053 ; RV64-V-NEXT: vnmsac.vx v8, a0, v16
1055 %vc = urem <vscale x 8 x i64> %va, splat (i64 -7)
1056 ret <vscale x 8 x i64> %vc
1059 ; fold (urem x, pow2) -> (and x, pow2-1)
1060 define <vscale x 8 x i64> @vremu_vi_nxv8i64_1(<vscale x 8 x i64> %va) {
1061 ; CHECK-LABEL: vremu_vi_nxv8i64_1:
1063 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1064 ; CHECK-NEXT: vand.vi v8, v8, 15
1066 %vc = urem <vscale x 8 x i64> %va, splat (i64 16)
1067 ret <vscale x 8 x i64> %vc
1070 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
1071 define <vscale x 8 x i64> @vremu_vi_nxv8i64_2(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1072 ; CHECK-LABEL: vremu_vi_nxv8i64_2:
1074 ; CHECK-NEXT: li a0, 16
1075 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1076 ; CHECK-NEXT: vmv.v.x v24, a0
1077 ; CHECK-NEXT: vsll.vv v16, v24, v16
1078 ; CHECK-NEXT: vadd.vi v16, v16, -1
1079 ; CHECK-NEXT: vand.vv v8, v8, v16
1081 %vc = shl <vscale x 8 x i64> splat (i64 16), %vb
1082 %vd = urem <vscale x 8 x i64> %va, %vc
1083 ret <vscale x 8 x i64> %vd