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 %head = insertelement <vscale x 1 x i8> poison, i8 -7, i32 0
40 %splat = shufflevector <vscale x 1 x i8> %head, <vscale x 1 x i8> poison, <vscale x 1 x i32> zeroinitializer
41 %vc = urem <vscale x 1 x i8> %va, %splat
42 ret <vscale x 1 x i8> %vc
45 define <vscale x 2 x i8> @vremu_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
46 ; CHECK-LABEL: vremu_vv_nxv2i8:
48 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
49 ; CHECK-NEXT: vremu.vv v8, v8, v9
51 %vc = urem <vscale x 2 x i8> %va, %vb
52 ret <vscale x 2 x i8> %vc
55 define <vscale x 2 x i8> @vremu_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
56 ; CHECK-LABEL: vremu_vx_nxv2i8:
58 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
59 ; CHECK-NEXT: vremu.vx v8, v8, a0
61 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
62 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
63 %vc = urem <vscale x 2 x i8> %va, %splat
64 ret <vscale x 2 x i8> %vc
67 define <vscale x 2 x i8> @vremu_vi_nxv2i8_0(<vscale x 2 x i8> %va) {
68 ; CHECK-LABEL: vremu_vi_nxv2i8_0:
70 ; CHECK-NEXT: li a0, 33
71 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
72 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
73 ; CHECK-NEXT: vsrl.vi v9, v9, 5
74 ; CHECK-NEXT: li a0, -7
75 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
77 %head = insertelement <vscale x 2 x i8> poison, i8 -7, 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 = urem <vscale x 2 x i8> %va, %splat
80 ret <vscale x 2 x i8> %vc
83 define <vscale x 4 x i8> @vremu_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
84 ; CHECK-LABEL: vremu_vv_nxv4i8:
86 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
87 ; CHECK-NEXT: vremu.vv v8, v8, v9
89 %vc = urem <vscale x 4 x i8> %va, %vb
90 ret <vscale x 4 x i8> %vc
93 define <vscale x 4 x i8> @vremu_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
94 ; CHECK-LABEL: vremu_vx_nxv4i8:
96 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
97 ; CHECK-NEXT: vremu.vx v8, v8, a0
99 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
100 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
101 %vc = urem <vscale x 4 x i8> %va, %splat
102 ret <vscale x 4 x i8> %vc
105 define <vscale x 4 x i8> @vremu_vi_nxv4i8_0(<vscale x 4 x i8> %va) {
106 ; CHECK-LABEL: vremu_vi_nxv4i8_0:
108 ; CHECK-NEXT: li a0, 33
109 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
110 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
111 ; CHECK-NEXT: vsrl.vi v9, v9, 5
112 ; CHECK-NEXT: li a0, -7
113 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
115 %head = insertelement <vscale x 4 x i8> poison, i8 -7, i32 0
116 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
117 %vc = urem <vscale x 4 x i8> %va, %splat
118 ret <vscale x 4 x i8> %vc
121 define <vscale x 8 x i8> @vremu_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
122 ; CHECK-LABEL: vremu_vv_nxv8i8:
124 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
125 ; CHECK-NEXT: vremu.vv v8, v8, v9
127 %vc = urem <vscale x 8 x i8> %va, %vb
128 ret <vscale x 8 x i8> %vc
131 define <vscale x 8 x i8> @vremu_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
132 ; CHECK-LABEL: vremu_vx_nxv8i8:
134 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
135 ; CHECK-NEXT: vremu.vx v8, v8, a0
137 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
138 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
139 %vc = urem <vscale x 8 x i8> %va, %splat
140 ret <vscale x 8 x i8> %vc
143 define <vscale x 8 x i8> @vremu_vi_nxv8i8_0(<vscale x 8 x i8> %va) {
144 ; CHECK-LABEL: vremu_vi_nxv8i8_0:
146 ; CHECK-NEXT: li a0, 33
147 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
148 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
149 ; CHECK-NEXT: vsrl.vi v9, v9, 5
150 ; CHECK-NEXT: li a0, -7
151 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
153 %head = insertelement <vscale x 8 x i8> poison, i8 -7, i32 0
154 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
155 %vc = urem <vscale x 8 x i8> %va, %splat
156 ret <vscale x 8 x i8> %vc
159 define <vscale x 16 x i8> @vremu_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
160 ; CHECK-LABEL: vremu_vv_nxv16i8:
162 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
163 ; CHECK-NEXT: vremu.vv v8, v8, v10
165 %vc = urem <vscale x 16 x i8> %va, %vb
166 ret <vscale x 16 x i8> %vc
169 define <vscale x 16 x i8> @vremu_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
170 ; CHECK-LABEL: vremu_vx_nxv16i8:
172 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
173 ; CHECK-NEXT: vremu.vx v8, v8, a0
175 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
176 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
177 %vc = urem <vscale x 16 x i8> %va, %splat
178 ret <vscale x 16 x i8> %vc
181 define <vscale x 16 x i8> @vremu_vi_nxv16i8_0(<vscale x 16 x i8> %va) {
182 ; CHECK-LABEL: vremu_vi_nxv16i8_0:
184 ; CHECK-NEXT: li a0, 33
185 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
186 ; CHECK-NEXT: vmulhu.vx v10, v8, a0
187 ; CHECK-NEXT: vsrl.vi v10, v10, 5
188 ; CHECK-NEXT: li a0, -7
189 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
191 %head = insertelement <vscale x 16 x i8> poison, i8 -7, 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 = urem <vscale x 16 x i8> %va, %splat
194 ret <vscale x 16 x i8> %vc
197 define <vscale x 32 x i8> @vremu_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
198 ; CHECK-LABEL: vremu_vv_nxv32i8:
200 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
201 ; CHECK-NEXT: vremu.vv v8, v8, v12
203 %vc = urem <vscale x 32 x i8> %va, %vb
204 ret <vscale x 32 x i8> %vc
207 define <vscale x 32 x i8> @vremu_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
208 ; CHECK-LABEL: vremu_vx_nxv32i8:
210 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
211 ; CHECK-NEXT: vremu.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 = urem <vscale x 32 x i8> %va, %splat
216 ret <vscale x 32 x i8> %vc
219 define <vscale x 32 x i8> @vremu_vi_nxv32i8_0(<vscale x 32 x i8> %va) {
220 ; CHECK-LABEL: vremu_vi_nxv32i8_0:
222 ; CHECK-NEXT: li a0, 33
223 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
224 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
225 ; CHECK-NEXT: vsrl.vi v12, v12, 5
226 ; CHECK-NEXT: li a0, -7
227 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
229 %head = insertelement <vscale x 32 x i8> poison, i8 -7, i32 0
230 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
231 %vc = urem <vscale x 32 x i8> %va, %splat
232 ret <vscale x 32 x i8> %vc
235 define <vscale x 64 x i8> @vremu_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
236 ; CHECK-LABEL: vremu_vv_nxv64i8:
238 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
239 ; CHECK-NEXT: vremu.vv v8, v8, v16
241 %vc = urem <vscale x 64 x i8> %va, %vb
242 ret <vscale x 64 x i8> %vc
245 define <vscale x 64 x i8> @vremu_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
246 ; CHECK-LABEL: vremu_vx_nxv64i8:
248 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
249 ; CHECK-NEXT: vremu.vx v8, v8, a0
251 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
252 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
253 %vc = urem <vscale x 64 x i8> %va, %splat
254 ret <vscale x 64 x i8> %vc
257 define <vscale x 64 x i8> @vremu_vi_nxv64i8_0(<vscale x 64 x i8> %va) {
258 ; CHECK-LABEL: vremu_vi_nxv64i8_0:
260 ; CHECK-NEXT: li a0, 33
261 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
262 ; CHECK-NEXT: vmulhu.vx v16, v8, a0
263 ; CHECK-NEXT: vsrl.vi v16, v16, 5
264 ; CHECK-NEXT: li a0, -7
265 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
267 %head = insertelement <vscale x 64 x i8> poison, i8 -7, i32 0
268 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
269 %vc = urem <vscale x 64 x i8> %va, %splat
270 ret <vscale x 64 x i8> %vc
273 define <vscale x 1 x i16> @vremu_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
274 ; CHECK-LABEL: vremu_vv_nxv1i16:
276 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
277 ; CHECK-NEXT: vremu.vv v8, v8, v9
279 %vc = urem <vscale x 1 x i16> %va, %vb
280 ret <vscale x 1 x i16> %vc
283 define <vscale x 1 x i16> @vremu_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
284 ; CHECK-LABEL: vremu_vx_nxv1i16:
286 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
287 ; CHECK-NEXT: vremu.vx v8, v8, a0
289 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
290 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
291 %vc = urem <vscale x 1 x i16> %va, %splat
292 ret <vscale x 1 x i16> %vc
295 define <vscale x 1 x i16> @vremu_vi_nxv1i16_0(<vscale x 1 x i16> %va) {
296 ; CHECK-LABEL: vremu_vi_nxv1i16_0:
298 ; CHECK-NEXT: lui a0, 2
299 ; CHECK-NEXT: addi a0, a0, 1
300 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
301 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
302 ; CHECK-NEXT: vsrl.vi v9, v9, 13
303 ; CHECK-NEXT: li a0, -7
304 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
306 %head = insertelement <vscale x 1 x i16> poison, i16 -7, i32 0
307 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
308 %vc = urem <vscale x 1 x i16> %va, %splat
309 ret <vscale x 1 x i16> %vc
312 define <vscale x 2 x i16> @vremu_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
313 ; CHECK-LABEL: vremu_vv_nxv2i16:
315 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
316 ; CHECK-NEXT: vremu.vv v8, v8, v9
318 %vc = urem <vscale x 2 x i16> %va, %vb
319 ret <vscale x 2 x i16> %vc
322 define <vscale x 2 x i16> @vremu_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
323 ; CHECK-LABEL: vremu_vx_nxv2i16:
325 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
326 ; CHECK-NEXT: vremu.vx v8, v8, a0
328 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
329 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
330 %vc = urem <vscale x 2 x i16> %va, %splat
331 ret <vscale x 2 x i16> %vc
334 define <vscale x 2 x i16> @vremu_vi_nxv2i16_0(<vscale x 2 x i16> %va) {
335 ; CHECK-LABEL: vremu_vi_nxv2i16_0:
337 ; CHECK-NEXT: lui a0, 2
338 ; CHECK-NEXT: addi a0, a0, 1
339 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
340 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
341 ; CHECK-NEXT: vsrl.vi v9, v9, 13
342 ; CHECK-NEXT: li a0, -7
343 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
345 %head = insertelement <vscale x 2 x i16> poison, i16 -7, i32 0
346 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
347 %vc = urem <vscale x 2 x i16> %va, %splat
348 ret <vscale x 2 x i16> %vc
351 define <vscale x 4 x i16> @vremu_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
352 ; CHECK-LABEL: vremu_vv_nxv4i16:
354 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
355 ; CHECK-NEXT: vremu.vv v8, v8, v9
357 %vc = urem <vscale x 4 x i16> %va, %vb
358 ret <vscale x 4 x i16> %vc
361 define <vscale x 4 x i16> @vremu_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
362 ; CHECK-LABEL: vremu_vx_nxv4i16:
364 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
365 ; CHECK-NEXT: vremu.vx v8, v8, a0
367 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
368 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
369 %vc = urem <vscale x 4 x i16> %va, %splat
370 ret <vscale x 4 x i16> %vc
373 define <vscale x 4 x i16> @vremu_vi_nxv4i16_0(<vscale x 4 x i16> %va) {
374 ; CHECK-LABEL: vremu_vi_nxv4i16_0:
376 ; CHECK-NEXT: lui a0, 2
377 ; CHECK-NEXT: addi a0, a0, 1
378 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
379 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
380 ; CHECK-NEXT: vsrl.vi v9, v9, 13
381 ; CHECK-NEXT: li a0, -7
382 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
384 %head = insertelement <vscale x 4 x i16> poison, i16 -7, i32 0
385 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
386 %vc = urem <vscale x 4 x i16> %va, %splat
387 ret <vscale x 4 x i16> %vc
390 define <vscale x 8 x i16> @vremu_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
391 ; CHECK-LABEL: vremu_vv_nxv8i16:
393 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
394 ; CHECK-NEXT: vremu.vv v8, v8, v10
396 %vc = urem <vscale x 8 x i16> %va, %vb
397 ret <vscale x 8 x i16> %vc
400 define <vscale x 8 x i16> @vremu_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
401 ; CHECK-LABEL: vremu_vx_nxv8i16:
403 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
404 ; CHECK-NEXT: vremu.vx v8, v8, a0
406 %head = insertelement <vscale x 8 x i16> poison, i16 %b, i32 0
407 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
408 %vc = urem <vscale x 8 x i16> %va, %splat
409 ret <vscale x 8 x i16> %vc
412 define <vscale x 8 x i16> @vremu_vi_nxv8i16_0(<vscale x 8 x i16> %va) {
413 ; CHECK-LABEL: vremu_vi_nxv8i16_0:
415 ; CHECK-NEXT: lui a0, 2
416 ; CHECK-NEXT: addi a0, a0, 1
417 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
418 ; CHECK-NEXT: vmulhu.vx v10, v8, a0
419 ; CHECK-NEXT: vsrl.vi v10, v10, 13
420 ; CHECK-NEXT: li a0, -7
421 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
423 %head = insertelement <vscale x 8 x i16> poison, i16 -7, i32 0
424 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
425 %vc = urem <vscale x 8 x i16> %va, %splat
426 ret <vscale x 8 x i16> %vc
429 define <vscale x 16 x i16> @vremu_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
430 ; CHECK-LABEL: vremu_vv_nxv16i16:
432 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
433 ; CHECK-NEXT: vremu.vv v8, v8, v12
435 %vc = urem <vscale x 16 x i16> %va, %vb
436 ret <vscale x 16 x i16> %vc
439 define <vscale x 16 x i16> @vremu_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
440 ; CHECK-LABEL: vremu_vx_nxv16i16:
442 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
443 ; CHECK-NEXT: vremu.vx v8, v8, a0
445 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
446 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
447 %vc = urem <vscale x 16 x i16> %va, %splat
448 ret <vscale x 16 x i16> %vc
451 define <vscale x 16 x i16> @vremu_vi_nxv16i16_0(<vscale x 16 x i16> %va) {
452 ; CHECK-LABEL: vremu_vi_nxv16i16_0:
454 ; CHECK-NEXT: lui a0, 2
455 ; CHECK-NEXT: addi a0, a0, 1
456 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
457 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
458 ; CHECK-NEXT: vsrl.vi v12, v12, 13
459 ; CHECK-NEXT: li a0, -7
460 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
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 = urem <vscale x 16 x i16> %va, %splat
465 ret <vscale x 16 x i16> %vc
468 define <vscale x 32 x i16> @vremu_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
469 ; CHECK-LABEL: vremu_vv_nxv32i16:
471 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
472 ; CHECK-NEXT: vremu.vv v8, v8, v16
474 %vc = urem <vscale x 32 x i16> %va, %vb
475 ret <vscale x 32 x i16> %vc
478 define <vscale x 32 x i16> @vremu_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
479 ; CHECK-LABEL: vremu_vx_nxv32i16:
481 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
482 ; CHECK-NEXT: vremu.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 = urem <vscale x 32 x i16> %va, %splat
487 ret <vscale x 32 x i16> %vc
490 define <vscale x 32 x i16> @vremu_vi_nxv32i16_0(<vscale x 32 x i16> %va) {
491 ; CHECK-LABEL: vremu_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 v16, v8, a0
497 ; CHECK-NEXT: vsrl.vi v16, v16, 13
498 ; CHECK-NEXT: li a0, -7
499 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
501 %head = insertelement <vscale x 32 x i16> poison, i16 -7, i32 0
502 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
503 %vc = urem <vscale x 32 x i16> %va, %splat
504 ret <vscale x 32 x i16> %vc
507 define <vscale x 1 x i32> @vremu_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
508 ; CHECK-LABEL: vremu_vv_nxv1i32:
510 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
511 ; CHECK-NEXT: vremu.vv v8, v8, v9
513 %vc = urem <vscale x 1 x i32> %va, %vb
514 ret <vscale x 1 x i32> %vc
517 define <vscale x 1 x i32> @vremu_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
518 ; CHECK-LABEL: vremu_vx_nxv1i32:
520 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
521 ; CHECK-NEXT: vremu.vx v8, v8, a0
523 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
524 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
525 %vc = urem <vscale x 1 x i32> %va, %splat
526 ret <vscale x 1 x i32> %vc
529 define <vscale x 1 x i32> @vremu_vi_nxv1i32_0(<vscale x 1 x i32> %va) {
530 ; CHECK-LABEL: vremu_vi_nxv1i32_0:
532 ; CHECK-NEXT: lui a0, 131072
533 ; CHECK-NEXT: addi a0, a0, 1
534 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
535 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
536 ; CHECK-NEXT: vsrl.vi v9, v9, 29
537 ; CHECK-NEXT: li a0, -7
538 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
540 %head = insertelement <vscale x 1 x i32> poison, i32 -7, i32 0
541 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
542 %vc = urem <vscale x 1 x i32> %va, %splat
543 ret <vscale x 1 x i32> %vc
546 define <vscale x 2 x i32> @vremu_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
547 ; CHECK-LABEL: vremu_vv_nxv2i32:
549 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
550 ; CHECK-NEXT: vremu.vv v8, v8, v9
552 %vc = urem <vscale x 2 x i32> %va, %vb
553 ret <vscale x 2 x i32> %vc
556 define <vscale x 2 x i32> @vremu_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
557 ; CHECK-LABEL: vremu_vx_nxv2i32:
559 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
560 ; CHECK-NEXT: vremu.vx v8, v8, a0
562 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
563 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
564 %vc = urem <vscale x 2 x i32> %va, %splat
565 ret <vscale x 2 x i32> %vc
568 define <vscale x 2 x i32> @vremu_vi_nxv2i32_0(<vscale x 2 x i32> %va) {
569 ; CHECK-LABEL: vremu_vi_nxv2i32_0:
571 ; CHECK-NEXT: lui a0, 131072
572 ; CHECK-NEXT: addi a0, a0, 1
573 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
574 ; CHECK-NEXT: vmulhu.vx v9, v8, a0
575 ; CHECK-NEXT: vsrl.vi v9, v9, 29
576 ; CHECK-NEXT: li a0, -7
577 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
579 %head = insertelement <vscale x 2 x i32> poison, i32 -7, i32 0
580 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
581 %vc = urem <vscale x 2 x i32> %va, %splat
582 ret <vscale x 2 x i32> %vc
585 define <vscale x 4 x i32> @vremu_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
586 ; CHECK-LABEL: vremu_vv_nxv4i32:
588 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
589 ; CHECK-NEXT: vremu.vv v8, v8, v10
591 %vc = urem <vscale x 4 x i32> %va, %vb
592 ret <vscale x 4 x i32> %vc
595 define <vscale x 4 x i32> @vremu_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
596 ; CHECK-LABEL: vremu_vx_nxv4i32:
598 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
599 ; CHECK-NEXT: vremu.vx v8, v8, a0
601 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
602 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
603 %vc = urem <vscale x 4 x i32> %va, %splat
604 ret <vscale x 4 x i32> %vc
607 define <vscale x 4 x i32> @vremu_vi_nxv4i32_0(<vscale x 4 x i32> %va) {
608 ; CHECK-LABEL: vremu_vi_nxv4i32_0:
610 ; CHECK-NEXT: lui a0, 131072
611 ; CHECK-NEXT: addi a0, a0, 1
612 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
613 ; CHECK-NEXT: vmulhu.vx v10, v8, a0
614 ; CHECK-NEXT: vsrl.vi v10, v10, 29
615 ; CHECK-NEXT: li a0, -7
616 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
618 %head = insertelement <vscale x 4 x i32> poison, i32 -7, i32 0
619 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
620 %vc = urem <vscale x 4 x i32> %va, %splat
621 ret <vscale x 4 x i32> %vc
624 define <vscale x 8 x i32> @vremu_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
625 ; CHECK-LABEL: vremu_vv_nxv8i32:
627 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
628 ; CHECK-NEXT: vremu.vv v8, v8, v12
630 %vc = urem <vscale x 8 x i32> %va, %vb
631 ret <vscale x 8 x i32> %vc
634 define <vscale x 8 x i32> @vremu_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
635 ; CHECK-LABEL: vremu_vx_nxv8i32:
637 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
638 ; CHECK-NEXT: vremu.vx v8, v8, a0
640 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
641 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
642 %vc = urem <vscale x 8 x i32> %va, %splat
643 ret <vscale x 8 x i32> %vc
646 define <vscale x 8 x i32> @vremu_vi_nxv8i32_0(<vscale x 8 x i32> %va) {
647 ; CHECK-LABEL: vremu_vi_nxv8i32_0:
649 ; CHECK-NEXT: lui a0, 131072
650 ; CHECK-NEXT: addi a0, a0, 1
651 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
652 ; CHECK-NEXT: vmulhu.vx v12, v8, a0
653 ; CHECK-NEXT: vsrl.vi v12, v12, 29
654 ; CHECK-NEXT: li a0, -7
655 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
657 %head = insertelement <vscale x 8 x i32> poison, i32 -7, i32 0
658 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
659 %vc = urem <vscale x 8 x i32> %va, %splat
660 ret <vscale x 8 x i32> %vc
663 define <vscale x 16 x i32> @vremu_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
664 ; CHECK-LABEL: vremu_vv_nxv16i32:
666 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
667 ; CHECK-NEXT: vremu.vv v8, v8, v16
669 %vc = urem <vscale x 16 x i32> %va, %vb
670 ret <vscale x 16 x i32> %vc
673 define <vscale x 16 x i32> @vremu_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
674 ; CHECK-LABEL: vremu_vx_nxv16i32:
676 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
677 ; CHECK-NEXT: vremu.vx v8, v8, a0
679 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
680 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
681 %vc = urem <vscale x 16 x i32> %va, %splat
682 ret <vscale x 16 x i32> %vc
685 define <vscale x 16 x i32> @vremu_vi_nxv16i32_0(<vscale x 16 x i32> %va) {
686 ; CHECK-LABEL: vremu_vi_nxv16i32_0:
688 ; CHECK-NEXT: lui a0, 131072
689 ; CHECK-NEXT: addi a0, a0, 1
690 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
691 ; CHECK-NEXT: vmulhu.vx v16, v8, a0
692 ; CHECK-NEXT: vsrl.vi v16, v16, 29
693 ; CHECK-NEXT: li a0, -7
694 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
696 %head = insertelement <vscale x 16 x i32> poison, i32 -7, i32 0
697 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
698 %vc = urem <vscale x 16 x i32> %va, %splat
699 ret <vscale x 16 x i32> %vc
702 define <vscale x 1 x i64> @vremu_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
703 ; CHECK-LABEL: vremu_vv_nxv1i64:
705 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
706 ; CHECK-NEXT: vremu.vv v8, v8, v9
708 %vc = urem <vscale x 1 x i64> %va, %vb
709 ret <vscale x 1 x i64> %vc
712 define <vscale x 1 x i64> @vremu_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
713 ; RV32-LABEL: vremu_vx_nxv1i64:
715 ; RV32-NEXT: addi sp, sp, -16
716 ; RV32-NEXT: .cfi_def_cfa_offset 16
717 ; RV32-NEXT: sw a1, 12(sp)
718 ; RV32-NEXT: sw a0, 8(sp)
719 ; RV32-NEXT: addi a0, sp, 8
720 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
721 ; RV32-NEXT: vlse64.v v9, (a0), zero
722 ; RV32-NEXT: vremu.vv v8, v8, v9
723 ; RV32-NEXT: addi sp, sp, 16
726 ; RV64-LABEL: vremu_vx_nxv1i64:
728 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
729 ; RV64-NEXT: vremu.vx v8, v8, a0
731 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
732 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
733 %vc = urem <vscale x 1 x i64> %va, %splat
734 ret <vscale x 1 x i64> %vc
737 define <vscale x 1 x i64> @vremu_vi_nxv1i64_0(<vscale x 1 x i64> %va) {
738 ; RV32-V-LABEL: vremu_vi_nxv1i64_0:
740 ; RV32-V-NEXT: addi sp, sp, -16
741 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
742 ; RV32-V-NEXT: lui a0, 131072
743 ; RV32-V-NEXT: sw a0, 12(sp)
744 ; RV32-V-NEXT: li a0, 1
745 ; RV32-V-NEXT: sw a0, 8(sp)
746 ; RV32-V-NEXT: addi a0, sp, 8
747 ; RV32-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
748 ; RV32-V-NEXT: vlse64.v v9, (a0), zero
749 ; RV32-V-NEXT: vmulhu.vv v9, v8, v9
750 ; RV32-V-NEXT: li a0, 61
751 ; RV32-V-NEXT: vsrl.vx v9, v9, a0
752 ; RV32-V-NEXT: li a0, -7
753 ; RV32-V-NEXT: vnmsac.vx v8, a0, v9
754 ; RV32-V-NEXT: addi sp, sp, 16
757 ; ZVE64X-LABEL: vremu_vi_nxv1i64_0:
759 ; ZVE64X-NEXT: li a0, -7
760 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m1, ta, ma
761 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
764 ; RV64-V-LABEL: vremu_vi_nxv1i64_0:
766 ; RV64-V-NEXT: li a0, 1
767 ; RV64-V-NEXT: slli a0, a0, 61
768 ; RV64-V-NEXT: addi a0, a0, 1
769 ; RV64-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
770 ; RV64-V-NEXT: vmulhu.vx v9, v8, a0
771 ; RV64-V-NEXT: li a0, 61
772 ; RV64-V-NEXT: vsrl.vx v9, v9, a0
773 ; RV64-V-NEXT: li a0, -7
774 ; RV64-V-NEXT: vnmsac.vx v8, a0, v9
776 %head = insertelement <vscale x 1 x i64> poison, i64 -7, i32 0
777 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
778 %vc = urem <vscale x 1 x i64> %va, %splat
779 ret <vscale x 1 x i64> %vc
782 ; fold (urem x, pow2) -> (and x, pow2-1)
783 define <vscale x 1 x i64> @vremu_vi_nxv1i64_1(<vscale x 1 x i64> %va) {
784 ; CHECK-LABEL: vremu_vi_nxv1i64_1:
786 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
787 ; CHECK-NEXT: vand.vi v8, v8, 15
789 %head = insertelement <vscale x 1 x i64> poison, i64 16, i32 0
790 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
791 %vc = urem <vscale x 1 x i64> %va, %splat
792 ret <vscale x 1 x i64> %vc
795 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
796 define <vscale x 1 x i64> @vremu_vi_nxv1i64_2(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
797 ; CHECK-LABEL: vremu_vi_nxv1i64_2:
799 ; CHECK-NEXT: li a0, 16
800 ; CHECK-NEXT: vsetvli a1, zero, e64, m1, ta, ma
801 ; CHECK-NEXT: vmv.v.x v10, a0
802 ; CHECK-NEXT: vsll.vv v9, v10, v9
803 ; CHECK-NEXT: vadd.vi v9, v9, -1
804 ; CHECK-NEXT: vand.vv v8, v8, v9
806 %head = insertelement <vscale x 1 x i64> poison, i64 16, i32 0
807 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
808 %vc = shl <vscale x 1 x i64> %splat, %vb
809 %vd = urem <vscale x 1 x i64> %va, %vc
810 ret <vscale x 1 x i64> %vd
813 define <vscale x 2 x i64> @vremu_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
814 ; CHECK-LABEL: vremu_vv_nxv2i64:
816 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
817 ; CHECK-NEXT: vremu.vv v8, v8, v10
819 %vc = urem <vscale x 2 x i64> %va, %vb
820 ret <vscale x 2 x i64> %vc
823 define <vscale x 2 x i64> @vremu_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
824 ; RV32-LABEL: vremu_vx_nxv2i64:
826 ; RV32-NEXT: addi sp, sp, -16
827 ; RV32-NEXT: .cfi_def_cfa_offset 16
828 ; RV32-NEXT: sw a1, 12(sp)
829 ; RV32-NEXT: sw a0, 8(sp)
830 ; RV32-NEXT: addi a0, sp, 8
831 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
832 ; RV32-NEXT: vlse64.v v10, (a0), zero
833 ; RV32-NEXT: vremu.vv v8, v8, v10
834 ; RV32-NEXT: addi sp, sp, 16
837 ; RV64-LABEL: vremu_vx_nxv2i64:
839 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
840 ; RV64-NEXT: vremu.vx v8, v8, a0
842 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
843 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
844 %vc = urem <vscale x 2 x i64> %va, %splat
845 ret <vscale x 2 x i64> %vc
848 define <vscale x 2 x i64> @vremu_vi_nxv2i64_0(<vscale x 2 x i64> %va) {
849 ; RV32-V-LABEL: vremu_vi_nxv2i64_0:
851 ; RV32-V-NEXT: addi sp, sp, -16
852 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
853 ; RV32-V-NEXT: lui a0, 131072
854 ; RV32-V-NEXT: sw a0, 12(sp)
855 ; RV32-V-NEXT: li a0, 1
856 ; RV32-V-NEXT: sw a0, 8(sp)
857 ; RV32-V-NEXT: addi a0, sp, 8
858 ; RV32-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
859 ; RV32-V-NEXT: vlse64.v v10, (a0), zero
860 ; RV32-V-NEXT: vmulhu.vv v10, v8, v10
861 ; RV32-V-NEXT: li a0, 61
862 ; RV32-V-NEXT: vsrl.vx v10, v10, a0
863 ; RV32-V-NEXT: li a0, -7
864 ; RV32-V-NEXT: vnmsac.vx v8, a0, v10
865 ; RV32-V-NEXT: addi sp, sp, 16
868 ; ZVE64X-LABEL: vremu_vi_nxv2i64_0:
870 ; ZVE64X-NEXT: li a0, -7
871 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m2, ta, ma
872 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
875 ; RV64-V-LABEL: vremu_vi_nxv2i64_0:
877 ; RV64-V-NEXT: li a0, 1
878 ; RV64-V-NEXT: slli a0, a0, 61
879 ; RV64-V-NEXT: addi a0, a0, 1
880 ; RV64-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
881 ; RV64-V-NEXT: vmulhu.vx v10, v8, a0
882 ; RV64-V-NEXT: li a0, 61
883 ; RV64-V-NEXT: vsrl.vx v10, v10, a0
884 ; RV64-V-NEXT: li a0, -7
885 ; RV64-V-NEXT: vnmsac.vx v8, a0, v10
887 %head = insertelement <vscale x 2 x i64> poison, i64 -7, i32 0
888 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
889 %vc = urem <vscale x 2 x i64> %va, %splat
890 ret <vscale x 2 x i64> %vc
893 ; fold (urem x, pow2) -> (and x, pow2-1)
894 define <vscale x 2 x i64> @vremu_vi_nxv2i64_1(<vscale x 2 x i64> %va) {
895 ; CHECK-LABEL: vremu_vi_nxv2i64_1:
897 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
898 ; CHECK-NEXT: vand.vi v8, v8, 15
900 %head = insertelement <vscale x 2 x i64> poison, i64 16, i32 0
901 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
902 %vc = urem <vscale x 2 x i64> %va, %splat
903 ret <vscale x 2 x i64> %vc
906 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
907 define <vscale x 2 x i64> @vremu_vi_nxv2i64_2(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
908 ; CHECK-LABEL: vremu_vi_nxv2i64_2:
910 ; CHECK-NEXT: li a0, 16
911 ; CHECK-NEXT: vsetvli a1, zero, e64, m2, ta, ma
912 ; CHECK-NEXT: vmv.v.x v12, a0
913 ; CHECK-NEXT: vsll.vv v10, v12, v10
914 ; CHECK-NEXT: vadd.vi v10, v10, -1
915 ; CHECK-NEXT: vand.vv v8, v8, v10
917 %head = insertelement <vscale x 2 x i64> poison, i64 16, i32 0
918 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
919 %vc = shl <vscale x 2 x i64> %splat, %vb
920 %vd = urem <vscale x 2 x i64> %va, %vc
921 ret <vscale x 2 x i64> %vd
924 define <vscale x 4 x i64> @vremu_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
925 ; CHECK-LABEL: vremu_vv_nxv4i64:
927 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
928 ; CHECK-NEXT: vremu.vv v8, v8, v12
930 %vc = urem <vscale x 4 x i64> %va, %vb
931 ret <vscale x 4 x i64> %vc
934 define <vscale x 4 x i64> @vremu_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
935 ; RV32-LABEL: vremu_vx_nxv4i64:
937 ; RV32-NEXT: addi sp, sp, -16
938 ; RV32-NEXT: .cfi_def_cfa_offset 16
939 ; RV32-NEXT: sw a1, 12(sp)
940 ; RV32-NEXT: sw a0, 8(sp)
941 ; RV32-NEXT: addi a0, sp, 8
942 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
943 ; RV32-NEXT: vlse64.v v12, (a0), zero
944 ; RV32-NEXT: vremu.vv v8, v8, v12
945 ; RV32-NEXT: addi sp, sp, 16
948 ; RV64-LABEL: vremu_vx_nxv4i64:
950 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
951 ; RV64-NEXT: vremu.vx v8, v8, a0
953 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
954 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
955 %vc = urem <vscale x 4 x i64> %va, %splat
956 ret <vscale x 4 x i64> %vc
959 define <vscale x 4 x i64> @vremu_vi_nxv4i64_0(<vscale x 4 x i64> %va) {
960 ; RV32-V-LABEL: vremu_vi_nxv4i64_0:
962 ; RV32-V-NEXT: addi sp, sp, -16
963 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
964 ; RV32-V-NEXT: lui a0, 131072
965 ; RV32-V-NEXT: sw a0, 12(sp)
966 ; RV32-V-NEXT: li a0, 1
967 ; RV32-V-NEXT: sw a0, 8(sp)
968 ; RV32-V-NEXT: addi a0, sp, 8
969 ; RV32-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
970 ; RV32-V-NEXT: vlse64.v v12, (a0), zero
971 ; RV32-V-NEXT: vmulhu.vv v12, v8, v12
972 ; RV32-V-NEXT: li a0, 61
973 ; RV32-V-NEXT: vsrl.vx v12, v12, a0
974 ; RV32-V-NEXT: li a0, -7
975 ; RV32-V-NEXT: vnmsac.vx v8, a0, v12
976 ; RV32-V-NEXT: addi sp, sp, 16
979 ; ZVE64X-LABEL: vremu_vi_nxv4i64_0:
981 ; ZVE64X-NEXT: li a0, -7
982 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m4, ta, ma
983 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
986 ; RV64-V-LABEL: vremu_vi_nxv4i64_0:
988 ; RV64-V-NEXT: li a0, 1
989 ; RV64-V-NEXT: slli a0, a0, 61
990 ; RV64-V-NEXT: addi a0, a0, 1
991 ; RV64-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
992 ; RV64-V-NEXT: vmulhu.vx v12, v8, a0
993 ; RV64-V-NEXT: li a0, 61
994 ; RV64-V-NEXT: vsrl.vx v12, v12, a0
995 ; RV64-V-NEXT: li a0, -7
996 ; RV64-V-NEXT: vnmsac.vx v8, a0, v12
998 %head = insertelement <vscale x 4 x i64> poison, i64 -7, i32 0
999 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
1000 %vc = urem <vscale x 4 x i64> %va, %splat
1001 ret <vscale x 4 x i64> %vc
1004 ; fold (urem x, pow2) -> (and x, pow2-1)
1005 define <vscale x 4 x i64> @vremu_vi_nxv4i64_1(<vscale x 4 x i64> %va) {
1006 ; CHECK-LABEL: vremu_vi_nxv4i64_1:
1008 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
1009 ; CHECK-NEXT: vand.vi v8, v8, 15
1011 %head = insertelement <vscale x 4 x i64> poison, i64 16, i32 0
1012 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
1013 %vc = urem <vscale x 4 x i64> %va, %splat
1014 ret <vscale x 4 x i64> %vc
1017 ;fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
1018 define <vscale x 4 x i64> @vremu_vi_nxv4i64_2(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
1019 ; CHECK-LABEL: vremu_vi_nxv4i64_2:
1021 ; CHECK-NEXT: li a0, 16
1022 ; CHECK-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1023 ; CHECK-NEXT: vmv.v.x v16, a0
1024 ; CHECK-NEXT: vsll.vv v12, v16, v12
1025 ; CHECK-NEXT: vadd.vi v12, v12, -1
1026 ; CHECK-NEXT: vand.vv v8, v8, v12
1028 %head = insertelement <vscale x 4 x i64> poison, i64 16, i32 0
1029 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
1030 %vc = shl <vscale x 4 x i64> %splat, %vb
1031 %vd = urem <vscale x 4 x i64> %va, %vc
1032 ret <vscale x 4 x i64> %vd
1035 define <vscale x 8 x i64> @vremu_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1036 ; CHECK-LABEL: vremu_vv_nxv8i64:
1038 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1039 ; CHECK-NEXT: vremu.vv v8, v8, v16
1041 %vc = urem <vscale x 8 x i64> %va, %vb
1042 ret <vscale x 8 x i64> %vc
1045 define <vscale x 8 x i64> @vremu_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
1046 ; RV32-LABEL: vremu_vx_nxv8i64:
1048 ; RV32-NEXT: addi sp, sp, -16
1049 ; RV32-NEXT: .cfi_def_cfa_offset 16
1050 ; RV32-NEXT: sw a1, 12(sp)
1051 ; RV32-NEXT: sw a0, 8(sp)
1052 ; RV32-NEXT: addi a0, sp, 8
1053 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1054 ; RV32-NEXT: vlse64.v v16, (a0), zero
1055 ; RV32-NEXT: vremu.vv v8, v8, v16
1056 ; RV32-NEXT: addi sp, sp, 16
1059 ; RV64-LABEL: vremu_vx_nxv8i64:
1061 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1062 ; RV64-NEXT: vremu.vx v8, v8, a0
1064 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
1065 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1066 %vc = urem <vscale x 8 x i64> %va, %splat
1067 ret <vscale x 8 x i64> %vc
1070 define <vscale x 8 x i64> @vremu_vi_nxv8i64_0(<vscale x 8 x i64> %va) {
1071 ; RV32-V-LABEL: vremu_vi_nxv8i64_0:
1073 ; RV32-V-NEXT: addi sp, sp, -16
1074 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1075 ; RV32-V-NEXT: lui a0, 131072
1076 ; RV32-V-NEXT: sw a0, 12(sp)
1077 ; RV32-V-NEXT: li a0, 1
1078 ; RV32-V-NEXT: sw a0, 8(sp)
1079 ; RV32-V-NEXT: addi a0, sp, 8
1080 ; RV32-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1081 ; RV32-V-NEXT: vlse64.v v16, (a0), zero
1082 ; RV32-V-NEXT: vmulhu.vv v16, v8, v16
1083 ; RV32-V-NEXT: li a0, 61
1084 ; RV32-V-NEXT: vsrl.vx v16, v16, a0
1085 ; RV32-V-NEXT: li a0, -7
1086 ; RV32-V-NEXT: vnmsac.vx v8, a0, v16
1087 ; RV32-V-NEXT: addi sp, sp, 16
1090 ; ZVE64X-LABEL: vremu_vi_nxv8i64_0:
1092 ; ZVE64X-NEXT: li a0, -7
1093 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1094 ; ZVE64X-NEXT: vremu.vx v8, v8, a0
1097 ; RV64-V-LABEL: vremu_vi_nxv8i64_0:
1099 ; RV64-V-NEXT: li a0, 1
1100 ; RV64-V-NEXT: slli a0, a0, 61
1101 ; RV64-V-NEXT: addi a0, a0, 1
1102 ; RV64-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1103 ; RV64-V-NEXT: vmulhu.vx v16, v8, a0
1104 ; RV64-V-NEXT: li a0, 61
1105 ; RV64-V-NEXT: vsrl.vx v16, v16, a0
1106 ; RV64-V-NEXT: li a0, -7
1107 ; RV64-V-NEXT: vnmsac.vx v8, a0, v16
1109 %head = insertelement <vscale x 8 x i64> poison, i64 -7, i32 0
1110 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1111 %vc = urem <vscale x 8 x i64> %va, %splat
1112 ret <vscale x 8 x i64> %vc
1115 ; fold (urem x, pow2) -> (and x, pow2-1)
1116 define <vscale x 8 x i64> @vremu_vi_nxv8i64_1(<vscale x 8 x i64> %va) {
1117 ; CHECK-LABEL: vremu_vi_nxv8i64_1:
1119 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1120 ; CHECK-NEXT: vand.vi v8, v8, 15
1122 %head = insertelement <vscale x 8 x i64> poison, i64 16, i32 0
1123 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1124 %vc = urem <vscale x 8 x i64> %va, %splat
1125 ret <vscale x 8 x i64> %vc
1128 ; fold (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1))
1129 define <vscale x 8 x i64> @vremu_vi_nxv8i64_2(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1130 ; CHECK-LABEL: vremu_vi_nxv8i64_2:
1132 ; CHECK-NEXT: li a0, 16
1133 ; CHECK-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1134 ; CHECK-NEXT: vmv.v.x v24, a0
1135 ; CHECK-NEXT: vsll.vv v16, v24, v16
1136 ; CHECK-NEXT: vadd.vi v16, v16, -1
1137 ; CHECK-NEXT: vand.vv v8, v8, v16
1139 %head = insertelement <vscale x 8 x i64> poison, i64 16, i32 0
1140 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1141 %vc = shl <vscale x 8 x i64> %splat, %vb
1142 %vd = urem <vscale x 8 x i64> %va, %vc
1143 ret <vscale x 8 x i64> %vd