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> @vrem_vv_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb) {
8 ; CHECK-LABEL: vrem_vv_nxv1i8:
10 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
11 ; CHECK-NEXT: vrem.vv v8, v8, v9
13 %vc = srem <vscale x 1 x i8> %va, %vb
14 ret <vscale x 1 x i8> %vc
17 define <vscale x 1 x i8> @vrem_vx_nxv1i8(<vscale x 1 x i8> %va, i8 signext %b) {
18 ; CHECK-LABEL: vrem_vx_nxv1i8:
20 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
21 ; CHECK-NEXT: vrem.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 = srem <vscale x 1 x i8> %va, %splat
26 ret <vscale x 1 x i8> %vc
29 define <vscale x 1 x i8> @vrem_vi_nxv1i8_0(<vscale x 1 x i8> %va) {
30 ; CHECK-LABEL: vrem_vi_nxv1i8_0:
32 ; CHECK-NEXT: li a0, 109
33 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
34 ; CHECK-NEXT: vmulh.vx v9, v8, a0
35 ; CHECK-NEXT: vsub.vv v9, v9, v8
36 ; CHECK-NEXT: vsra.vi v9, v9, 2
37 ; CHECK-NEXT: vsrl.vi v10, v9, 7
38 ; CHECK-NEXT: vadd.vv v9, v9, v10
39 ; CHECK-NEXT: li a0, -7
40 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
42 %vc = srem <vscale x 1 x i8> %va, splat (i8 -7)
43 ret <vscale x 1 x i8> %vc
46 define <vscale x 1 x i8> @vrem_vv_nxv1i8_sext_twice(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb) {
47 ; CHECK-LABEL: vrem_vv_nxv1i8_sext_twice:
49 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
50 ; CHECK-NEXT: vrem.vv v8, v8, v9
52 %sext_va = sext <vscale x 1 x i8> %va to <vscale x 1 x i16>
53 %sext_vb = sext <vscale x 1 x i8> %vb to <vscale x 1 x i16>
54 %vc_ext = srem <vscale x 1 x i16> %sext_va, %sext_vb
55 %vc = trunc <vscale x 1 x i16> %vc_ext to <vscale x 1 x i8>
56 ret <vscale x 1 x i8> %vc
59 define <vscale x 2 x i8> @vrem_vv_nxv2i8(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
60 ; CHECK-LABEL: vrem_vv_nxv2i8:
62 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
63 ; CHECK-NEXT: vrem.vv v8, v8, v9
65 %vc = srem <vscale x 2 x i8> %va, %vb
66 ret <vscale x 2 x i8> %vc
69 define <vscale x 2 x i8> @vrem_vx_nxv2i8(<vscale x 2 x i8> %va, i8 signext %b) {
70 ; CHECK-LABEL: vrem_vx_nxv2i8:
72 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
73 ; CHECK-NEXT: vrem.vx v8, v8, a0
75 %head = insertelement <vscale x 2 x i8> poison, i8 %b, i32 0
76 %splat = shufflevector <vscale x 2 x i8> %head, <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer
77 %vc = srem <vscale x 2 x i8> %va, %splat
78 ret <vscale x 2 x i8> %vc
81 define <vscale x 2 x i8> @vrem_vi_nxv2i8_0(<vscale x 2 x i8> %va) {
82 ; CHECK-LABEL: vrem_vi_nxv2i8_0:
84 ; CHECK-NEXT: li a0, 109
85 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
86 ; CHECK-NEXT: vmulh.vx v9, v8, a0
87 ; CHECK-NEXT: vsub.vv v9, v9, v8
88 ; CHECK-NEXT: vsra.vi v9, v9, 2
89 ; CHECK-NEXT: vsrl.vi v10, v9, 7
90 ; CHECK-NEXT: vadd.vv v9, v9, v10
91 ; CHECK-NEXT: li a0, -7
92 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
94 %vc = srem <vscale x 2 x i8> %va, splat (i8 -7)
95 ret <vscale x 2 x i8> %vc
98 define <vscale x 2 x i8> @vrem_vv_nxv2i8_sext_twice(<vscale x 2 x i8> %va, <vscale x 2 x i8> %vb) {
99 ; CHECK-LABEL: vrem_vv_nxv2i8_sext_twice:
101 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
102 ; CHECK-NEXT: vrem.vv v8, v8, v9
104 %sext_va = sext <vscale x 2 x i8> %va to <vscale x 2 x i16>
105 %sext_vb = sext <vscale x 2 x i8> %vb to <vscale x 2 x i16>
106 %vc_ext = srem <vscale x 2 x i16> %sext_va, %sext_vb
107 %vc = trunc <vscale x 2 x i16> %vc_ext to <vscale x 2 x i8>
108 ret <vscale x 2 x i8> %vc
111 define <vscale x 4 x i8> @vrem_vv_nxv4i8(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
112 ; CHECK-LABEL: vrem_vv_nxv4i8:
114 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
115 ; CHECK-NEXT: vrem.vv v8, v8, v9
117 %vc = srem <vscale x 4 x i8> %va, %vb
118 ret <vscale x 4 x i8> %vc
121 define <vscale x 4 x i8> @vrem_vx_nxv4i8(<vscale x 4 x i8> %va, i8 signext %b) {
122 ; CHECK-LABEL: vrem_vx_nxv4i8:
124 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
125 ; CHECK-NEXT: vrem.vx v8, v8, a0
127 %head = insertelement <vscale x 4 x i8> poison, i8 %b, i32 0
128 %splat = shufflevector <vscale x 4 x i8> %head, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
129 %vc = srem <vscale x 4 x i8> %va, %splat
130 ret <vscale x 4 x i8> %vc
133 define <vscale x 4 x i8> @vrem_vi_nxv4i8_0(<vscale x 4 x i8> %va) {
134 ; CHECK-LABEL: vrem_vi_nxv4i8_0:
136 ; CHECK-NEXT: li a0, 109
137 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
138 ; CHECK-NEXT: vmulh.vx v9, v8, a0
139 ; CHECK-NEXT: vsub.vv v9, v9, v8
140 ; CHECK-NEXT: vsra.vi v9, v9, 2
141 ; CHECK-NEXT: vsrl.vi v10, v9, 7
142 ; CHECK-NEXT: vadd.vv v9, v9, v10
143 ; CHECK-NEXT: li a0, -7
144 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
146 %vc = srem <vscale x 4 x i8> %va, splat (i8 -7)
147 ret <vscale x 4 x i8> %vc
150 define <vscale x 4 x i8> @vrem_vv_nxv4i8_sext_twice(<vscale x 4 x i8> %va, <vscale x 4 x i8> %vb) {
151 ; CHECK-LABEL: vrem_vv_nxv4i8_sext_twice:
153 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
154 ; CHECK-NEXT: vrem.vv v8, v8, v9
156 %sext_va = sext <vscale x 4 x i8> %va to <vscale x 4 x i16>
157 %sext_vb = sext <vscale x 4 x i8> %vb to <vscale x 4 x i16>
158 %vc_ext = srem <vscale x 4 x i16> %sext_va, %sext_vb
159 %vc = trunc <vscale x 4 x i16> %vc_ext to <vscale x 4 x i8>
160 ret <vscale x 4 x i8> %vc
163 define <vscale x 8 x i8> @vrem_vv_nxv8i8(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
164 ; CHECK-LABEL: vrem_vv_nxv8i8:
166 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
167 ; CHECK-NEXT: vrem.vv v8, v8, v9
169 %vc = srem <vscale x 8 x i8> %va, %vb
170 ret <vscale x 8 x i8> %vc
173 define <vscale x 8 x i8> @vrem_vx_nxv8i8(<vscale x 8 x i8> %va, i8 signext %b) {
174 ; CHECK-LABEL: vrem_vx_nxv8i8:
176 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
177 ; CHECK-NEXT: vrem.vx v8, v8, a0
179 %head = insertelement <vscale x 8 x i8> poison, i8 %b, i32 0
180 %splat = shufflevector <vscale x 8 x i8> %head, <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
181 %vc = srem <vscale x 8 x i8> %va, %splat
182 ret <vscale x 8 x i8> %vc
185 define <vscale x 8 x i8> @vrem_vi_nxv8i8_0(<vscale x 8 x i8> %va) {
186 ; CHECK-LABEL: vrem_vi_nxv8i8_0:
188 ; CHECK-NEXT: li a0, 109
189 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
190 ; CHECK-NEXT: vmulh.vx v9, v8, a0
191 ; CHECK-NEXT: vsub.vv v9, v9, v8
192 ; CHECK-NEXT: vsra.vi v9, v9, 2
193 ; CHECK-NEXT: vsrl.vi v10, v9, 7
194 ; CHECK-NEXT: vadd.vv v9, v9, v10
195 ; CHECK-NEXT: li a0, -7
196 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
198 %vc = srem <vscale x 8 x i8> %va, splat (i8 -7)
199 ret <vscale x 8 x i8> %vc
202 define <vscale x 8 x i8> @vrem_vv_nxv8i8_sext_twice(<vscale x 8 x i8> %va, <vscale x 8 x i8> %vb) {
203 ; CHECK-LABEL: vrem_vv_nxv8i8_sext_twice:
205 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
206 ; CHECK-NEXT: vrem.vv v8, v8, v9
208 %sext_va = sext <vscale x 8 x i8> %va to <vscale x 8 x i16>
209 %sext_vb = sext <vscale x 8 x i8> %vb to <vscale x 8 x i16>
210 %vc_ext = srem <vscale x 8 x i16> %sext_va, %sext_vb
211 %vc = trunc <vscale x 8 x i16> %vc_ext to <vscale x 8 x i8>
212 ret <vscale x 8 x i8> %vc
215 define <vscale x 16 x i8> @vrem_vv_nxv16i8(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
216 ; CHECK-LABEL: vrem_vv_nxv16i8:
218 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
219 ; CHECK-NEXT: vrem.vv v8, v8, v10
221 %vc = srem <vscale x 16 x i8> %va, %vb
222 ret <vscale x 16 x i8> %vc
225 define <vscale x 16 x i8> @vrem_vx_nxv16i8(<vscale x 16 x i8> %va, i8 signext %b) {
226 ; CHECK-LABEL: vrem_vx_nxv16i8:
228 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
229 ; CHECK-NEXT: vrem.vx v8, v8, a0
231 %head = insertelement <vscale x 16 x i8> poison, i8 %b, i32 0
232 %splat = shufflevector <vscale x 16 x i8> %head, <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
233 %vc = srem <vscale x 16 x i8> %va, %splat
234 ret <vscale x 16 x i8> %vc
237 define <vscale x 16 x i8> @vrem_vi_nxv16i8_0(<vscale x 16 x i8> %va) {
238 ; CHECK-LABEL: vrem_vi_nxv16i8_0:
240 ; CHECK-NEXT: li a0, 109
241 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
242 ; CHECK-NEXT: vmulh.vx v10, v8, a0
243 ; CHECK-NEXT: vsub.vv v10, v10, v8
244 ; CHECK-NEXT: vsra.vi v10, v10, 2
245 ; CHECK-NEXT: vsrl.vi v12, v10, 7
246 ; CHECK-NEXT: vadd.vv v10, v10, v12
247 ; CHECK-NEXT: li a0, -7
248 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
250 %vc = srem <vscale x 16 x i8> %va, splat (i8 -7)
251 ret <vscale x 16 x i8> %vc
254 define <vscale x 16 x i8> @vrem_vv_nxv16i8_sext_twice(<vscale x 16 x i8> %va, <vscale x 16 x i8> %vb) {
255 ; CHECK-LABEL: vrem_vv_nxv16i8_sext_twice:
257 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
258 ; CHECK-NEXT: vrem.vv v8, v8, v10
260 %sext_va = sext <vscale x 16 x i8> %va to <vscale x 16 x i16>
261 %sext_vb = sext <vscale x 16 x i8> %vb to <vscale x 16 x i16>
262 %vc_ext = srem <vscale x 16 x i16> %sext_va, %sext_vb
263 %vc = trunc <vscale x 16 x i16> %vc_ext to <vscale x 16 x i8>
264 ret <vscale x 16 x i8> %vc
267 define <vscale x 32 x i8> @vrem_vv_nxv32i8(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
268 ; CHECK-LABEL: vrem_vv_nxv32i8:
270 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
271 ; CHECK-NEXT: vrem.vv v8, v8, v12
273 %vc = srem <vscale x 32 x i8> %va, %vb
274 ret <vscale x 32 x i8> %vc
277 define <vscale x 32 x i8> @vrem_vx_nxv32i8(<vscale x 32 x i8> %va, i8 signext %b) {
278 ; CHECK-LABEL: vrem_vx_nxv32i8:
280 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
281 ; CHECK-NEXT: vrem.vx v8, v8, a0
283 %head = insertelement <vscale x 32 x i8> poison, i8 %b, i32 0
284 %splat = shufflevector <vscale x 32 x i8> %head, <vscale x 32 x i8> poison, <vscale x 32 x i32> zeroinitializer
285 %vc = srem <vscale x 32 x i8> %va, %splat
286 ret <vscale x 32 x i8> %vc
289 define <vscale x 32 x i8> @vrem_vi_nxv32i8_0(<vscale x 32 x i8> %va) {
290 ; CHECK-LABEL: vrem_vi_nxv32i8_0:
292 ; CHECK-NEXT: li a0, 109
293 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
294 ; CHECK-NEXT: vmulh.vx v12, v8, a0
295 ; CHECK-NEXT: vsub.vv v12, v12, v8
296 ; CHECK-NEXT: vsra.vi v12, v12, 2
297 ; CHECK-NEXT: vsrl.vi v16, v12, 7
298 ; CHECK-NEXT: vadd.vv v12, v12, v16
299 ; CHECK-NEXT: li a0, -7
300 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
302 %vc = srem <vscale x 32 x i8> %va, splat (i8 -7)
303 ret <vscale x 32 x i8> %vc
306 define <vscale x 32 x i8> @vrem_vv_nxv32i8_sext_twice(<vscale x 32 x i8> %va, <vscale x 32 x i8> %vb) {
307 ; CHECK-LABEL: vrem_vv_nxv32i8_sext_twice:
309 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
310 ; CHECK-NEXT: vrem.vv v8, v8, v12
312 %sext_va = sext <vscale x 32 x i8> %va to <vscale x 32 x i16>
313 %sext_vb = sext <vscale x 32 x i8> %vb to <vscale x 32 x i16>
314 %vc_ext = srem <vscale x 32 x i16> %sext_va, %sext_vb
315 %vc = trunc <vscale x 32 x i16> %vc_ext to <vscale x 32 x i8>
316 ret <vscale x 32 x i8> %vc
319 define <vscale x 64 x i8> @vrem_vv_nxv64i8(<vscale x 64 x i8> %va, <vscale x 64 x i8> %vb) {
320 ; CHECK-LABEL: vrem_vv_nxv64i8:
322 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
323 ; CHECK-NEXT: vrem.vv v8, v8, v16
325 %vc = srem <vscale x 64 x i8> %va, %vb
326 ret <vscale x 64 x i8> %vc
329 define <vscale x 64 x i8> @vrem_vx_nxv64i8(<vscale x 64 x i8> %va, i8 signext %b) {
330 ; CHECK-LABEL: vrem_vx_nxv64i8:
332 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
333 ; CHECK-NEXT: vrem.vx v8, v8, a0
335 %head = insertelement <vscale x 64 x i8> poison, i8 %b, i32 0
336 %splat = shufflevector <vscale x 64 x i8> %head, <vscale x 64 x i8> poison, <vscale x 64 x i32> zeroinitializer
337 %vc = srem <vscale x 64 x i8> %va, %splat
338 ret <vscale x 64 x i8> %vc
341 define <vscale x 64 x i8> @vrem_vi_nxv64i8_0(<vscale x 64 x i8> %va) {
342 ; CHECK-LABEL: vrem_vi_nxv64i8_0:
344 ; CHECK-NEXT: li a0, 109
345 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
346 ; CHECK-NEXT: vmulh.vx v16, v8, a0
347 ; CHECK-NEXT: vsub.vv v16, v16, v8
348 ; CHECK-NEXT: vsra.vi v16, v16, 2
349 ; CHECK-NEXT: vsrl.vi v24, v16, 7
350 ; CHECK-NEXT: vadd.vv v16, v16, v24
351 ; CHECK-NEXT: li a0, -7
352 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
354 %vc = srem <vscale x 64 x i8> %va, splat (i8 -7)
355 ret <vscale x 64 x i8> %vc
358 define <vscale x 1 x i16> @vrem_vv_nxv1i16(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
359 ; CHECK-LABEL: vrem_vv_nxv1i16:
361 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
362 ; CHECK-NEXT: vrem.vv v8, v8, v9
364 %vc = srem <vscale x 1 x i16> %va, %vb
365 ret <vscale x 1 x i16> %vc
368 define <vscale x 1 x i16> @vrem_vx_nxv1i16(<vscale x 1 x i16> %va, i16 signext %b) {
369 ; CHECK-LABEL: vrem_vx_nxv1i16:
371 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
372 ; CHECK-NEXT: vrem.vx v8, v8, a0
374 %head = insertelement <vscale x 1 x i16> poison, i16 %b, i32 0
375 %splat = shufflevector <vscale x 1 x i16> %head, <vscale x 1 x i16> poison, <vscale x 1 x i32> zeroinitializer
376 %vc = srem <vscale x 1 x i16> %va, %splat
377 ret <vscale x 1 x i16> %vc
380 define <vscale x 1 x i16> @vrem_vi_nxv1i16_0(<vscale x 1 x i16> %va) {
381 ; CHECK-LABEL: vrem_vi_nxv1i16_0:
383 ; CHECK-NEXT: lui a0, 1048571
384 ; CHECK-NEXT: addi a0, a0, 1755
385 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
386 ; CHECK-NEXT: vmulh.vx v9, v8, a0
387 ; CHECK-NEXT: vsra.vi v9, v9, 1
388 ; CHECK-NEXT: vsrl.vi v10, v9, 15
389 ; CHECK-NEXT: vadd.vv v9, v9, v10
390 ; CHECK-NEXT: li a0, -7
391 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
393 %vc = srem <vscale x 1 x i16> %va, splat (i16 -7)
394 ret <vscale x 1 x i16> %vc
397 define <vscale x 1 x i16> @vrem_vv_nxv1i16_sext_twice(<vscale x 1 x i16> %va, <vscale x 1 x i16> %vb) {
398 ; CHECK-LABEL: vrem_vv_nxv1i16_sext_twice:
400 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
401 ; CHECK-NEXT: vrem.vv v8, v8, v9
403 %sext_va = sext <vscale x 1 x i16> %va to <vscale x 1 x i32>
404 %sext_vb = sext <vscale x 1 x i16> %vb to <vscale x 1 x i32>
405 %vc_ext = srem <vscale x 1 x i32> %sext_va, %sext_vb
406 %vc = trunc <vscale x 1 x i32> %vc_ext to <vscale x 1 x i16>
407 ret <vscale x 1 x i16> %vc
410 define <vscale x 2 x i16> @vrem_vv_nxv2i16(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
411 ; CHECK-LABEL: vrem_vv_nxv2i16:
413 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
414 ; CHECK-NEXT: vrem.vv v8, v8, v9
416 %vc = srem <vscale x 2 x i16> %va, %vb
417 ret <vscale x 2 x i16> %vc
420 define <vscale x 2 x i16> @vrem_vx_nxv2i16(<vscale x 2 x i16> %va, i16 signext %b) {
421 ; CHECK-LABEL: vrem_vx_nxv2i16:
423 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
424 ; CHECK-NEXT: vrem.vx v8, v8, a0
426 %head = insertelement <vscale x 2 x i16> poison, i16 %b, i32 0
427 %splat = shufflevector <vscale x 2 x i16> %head, <vscale x 2 x i16> poison, <vscale x 2 x i32> zeroinitializer
428 %vc = srem <vscale x 2 x i16> %va, %splat
429 ret <vscale x 2 x i16> %vc
432 define <vscale x 2 x i16> @vrem_vi_nxv2i16_0(<vscale x 2 x i16> %va) {
433 ; CHECK-LABEL: vrem_vi_nxv2i16_0:
435 ; CHECK-NEXT: lui a0, 1048571
436 ; CHECK-NEXT: addi a0, a0, 1755
437 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
438 ; CHECK-NEXT: vmulh.vx v9, v8, a0
439 ; CHECK-NEXT: vsra.vi v9, v9, 1
440 ; CHECK-NEXT: vsrl.vi v10, v9, 15
441 ; CHECK-NEXT: vadd.vv v9, v9, v10
442 ; CHECK-NEXT: li a0, -7
443 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
445 %vc = srem <vscale x 2 x i16> %va, splat (i16 -7)
446 ret <vscale x 2 x i16> %vc
449 define <vscale x 2 x i16> @vrem_vv_nxv2i16_sext_twice(<vscale x 2 x i16> %va, <vscale x 2 x i16> %vb) {
450 ; CHECK-LABEL: vrem_vv_nxv2i16_sext_twice:
452 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
453 ; CHECK-NEXT: vrem.vv v8, v8, v9
455 %sext_va = sext <vscale x 2 x i16> %va to <vscale x 2 x i32>
456 %sext_vb = sext <vscale x 2 x i16> %vb to <vscale x 2 x i32>
457 %vc_ext = srem <vscale x 2 x i32> %sext_va, %sext_vb
458 %vc = trunc <vscale x 2 x i32> %vc_ext to <vscale x 2 x i16>
459 ret <vscale x 2 x i16> %vc
462 define <vscale x 4 x i16> @vrem_vv_nxv4i16(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
463 ; CHECK-LABEL: vrem_vv_nxv4i16:
465 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
466 ; CHECK-NEXT: vrem.vv v8, v8, v9
468 %vc = srem <vscale x 4 x i16> %va, %vb
469 ret <vscale x 4 x i16> %vc
472 define <vscale x 4 x i16> @vrem_vx_nxv4i16(<vscale x 4 x i16> %va, i16 signext %b) {
473 ; CHECK-LABEL: vrem_vx_nxv4i16:
475 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
476 ; CHECK-NEXT: vrem.vx v8, v8, a0
478 %head = insertelement <vscale x 4 x i16> poison, i16 %b, i32 0
479 %splat = shufflevector <vscale x 4 x i16> %head, <vscale x 4 x i16> poison, <vscale x 4 x i32> zeroinitializer
480 %vc = srem <vscale x 4 x i16> %va, %splat
481 ret <vscale x 4 x i16> %vc
484 define <vscale x 4 x i16> @vrem_vi_nxv4i16_0(<vscale x 4 x i16> %va) {
485 ; CHECK-LABEL: vrem_vi_nxv4i16_0:
487 ; CHECK-NEXT: lui a0, 1048571
488 ; CHECK-NEXT: addi a0, a0, 1755
489 ; CHECK-NEXT: vsetvli a1, zero, e16, m1, ta, ma
490 ; CHECK-NEXT: vmulh.vx v9, v8, a0
491 ; CHECK-NEXT: vsra.vi v9, v9, 1
492 ; CHECK-NEXT: vsrl.vi v10, v9, 15
493 ; CHECK-NEXT: vadd.vv v9, v9, v10
494 ; CHECK-NEXT: li a0, -7
495 ; CHECK-NEXT: vnmsac.vx v8, a0, v9
497 %vc = srem <vscale x 4 x i16> %va, splat (i16 -7)
498 ret <vscale x 4 x i16> %vc
501 define <vscale x 4 x i16> @vrem_vv_nxv4i16_sext_twice(<vscale x 4 x i16> %va, <vscale x 4 x i16> %vb) {
502 ; CHECK-LABEL: vrem_vv_nxv4i16_sext_twice:
504 ; CHECK-NEXT: vsetvli a0, zero, e16, m1, ta, ma
505 ; CHECK-NEXT: vrem.vv v8, v8, v9
507 %sext_va = sext <vscale x 4 x i16> %va to <vscale x 4 x i32>
508 %sext_vb = sext <vscale x 4 x i16> %vb to <vscale x 4 x i32>
509 %vc_ext = srem <vscale x 4 x i32> %sext_va, %sext_vb
510 %vc = trunc <vscale x 4 x i32> %vc_ext to <vscale x 4 x i16>
511 ret <vscale x 4 x i16> %vc
514 define <vscale x 8 x i16> @vrem_vv_nxv8i16(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
515 ; CHECK-LABEL: vrem_vv_nxv8i16:
517 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
518 ; CHECK-NEXT: vrem.vv v8, v8, v10
520 %vc = srem <vscale x 8 x i16> %va, %vb
521 ret <vscale x 8 x i16> %vc
524 define <vscale x 8 x i16> @vrem_vx_nxv8i16(<vscale x 8 x i16> %va, i16 signext %b) {
525 ; CHECK-LABEL: vrem_vx_nxv8i16:
527 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
528 ; CHECK-NEXT: vrem.vx v8, v8, a0
530 %head = insertelement <vscale x 8 x i16> poison, i16 %b, i32 0
531 %splat = shufflevector <vscale x 8 x i16> %head, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
532 %vc = srem <vscale x 8 x i16> %va, %splat
533 ret <vscale x 8 x i16> %vc
536 define <vscale x 8 x i16> @vrem_vi_nxv8i16_0(<vscale x 8 x i16> %va) {
537 ; CHECK-LABEL: vrem_vi_nxv8i16_0:
539 ; CHECK-NEXT: lui a0, 1048571
540 ; CHECK-NEXT: addi a0, a0, 1755
541 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
542 ; CHECK-NEXT: vmulh.vx v10, v8, a0
543 ; CHECK-NEXT: vsra.vi v10, v10, 1
544 ; CHECK-NEXT: vsrl.vi v12, v10, 15
545 ; CHECK-NEXT: vadd.vv v10, v10, v12
546 ; CHECK-NEXT: li a0, -7
547 ; CHECK-NEXT: vnmsac.vx v8, a0, v10
549 %vc = srem <vscale x 8 x i16> %va, splat (i16 -7)
550 ret <vscale x 8 x i16> %vc
553 define <vscale x 8 x i16> @vrem_vv_nxv8i16_sext_twice(<vscale x 8 x i16> %va, <vscale x 8 x i16> %vb) {
554 ; CHECK-LABEL: vrem_vv_nxv8i16_sext_twice:
556 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
557 ; CHECK-NEXT: vrem.vv v8, v8, v10
559 %sext_va = sext <vscale x 8 x i16> %va to <vscale x 8 x i32>
560 %sext_vb = sext <vscale x 8 x i16> %vb to <vscale x 8 x i32>
561 %vc_ext = srem <vscale x 8 x i32> %sext_va, %sext_vb
562 %vc = trunc <vscale x 8 x i32> %vc_ext to <vscale x 8 x i16>
563 ret <vscale x 8 x i16> %vc
566 define <vscale x 16 x i16> @vrem_vv_nxv16i16(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
567 ; CHECK-LABEL: vrem_vv_nxv16i16:
569 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
570 ; CHECK-NEXT: vrem.vv v8, v8, v12
572 %vc = srem <vscale x 16 x i16> %va, %vb
573 ret <vscale x 16 x i16> %vc
576 define <vscale x 16 x i16> @vrem_vx_nxv16i16(<vscale x 16 x i16> %va, i16 signext %b) {
577 ; CHECK-LABEL: vrem_vx_nxv16i16:
579 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
580 ; CHECK-NEXT: vrem.vx v8, v8, a0
582 %head = insertelement <vscale x 16 x i16> poison, i16 %b, i32 0
583 %splat = shufflevector <vscale x 16 x i16> %head, <vscale x 16 x i16> poison, <vscale x 16 x i32> zeroinitializer
584 %vc = srem <vscale x 16 x i16> %va, %splat
585 ret <vscale x 16 x i16> %vc
588 define <vscale x 16 x i16> @vrem_vi_nxv16i16_0(<vscale x 16 x i16> %va) {
589 ; CHECK-LABEL: vrem_vi_nxv16i16_0:
591 ; CHECK-NEXT: lui a0, 1048571
592 ; CHECK-NEXT: addi a0, a0, 1755
593 ; CHECK-NEXT: vsetvli a1, zero, e16, m4, ta, ma
594 ; CHECK-NEXT: vmulh.vx v12, v8, a0
595 ; CHECK-NEXT: vsra.vi v12, v12, 1
596 ; CHECK-NEXT: vsrl.vi v16, v12, 15
597 ; CHECK-NEXT: vadd.vv v12, v12, v16
598 ; CHECK-NEXT: li a0, -7
599 ; CHECK-NEXT: vnmsac.vx v8, a0, v12
601 %vc = srem <vscale x 16 x i16> %va, splat (i16 -7)
602 ret <vscale x 16 x i16> %vc
605 define <vscale x 16 x i16> @vrem_vv_nxv16i16_sext_twice(<vscale x 16 x i16> %va, <vscale x 16 x i16> %vb) {
606 ; CHECK-LABEL: vrem_vv_nxv16i16_sext_twice:
608 ; CHECK-NEXT: vsetvli a0, zero, e16, m4, ta, ma
609 ; CHECK-NEXT: vrem.vv v8, v8, v12
611 %sext_va = sext <vscale x 16 x i16> %va to <vscale x 16 x i32>
612 %sext_vb = sext <vscale x 16 x i16> %vb to <vscale x 16 x i32>
613 %vc_ext = srem <vscale x 16 x i32> %sext_va, %sext_vb
614 %vc = trunc <vscale x 16 x i32> %vc_ext to <vscale x 16 x i16>
615 ret <vscale x 16 x i16> %vc
618 define <vscale x 32 x i16> @vrem_vv_nxv32i16(<vscale x 32 x i16> %va, <vscale x 32 x i16> %vb) {
619 ; CHECK-LABEL: vrem_vv_nxv32i16:
621 ; CHECK-NEXT: vsetvli a0, zero, e16, m8, ta, ma
622 ; CHECK-NEXT: vrem.vv v8, v8, v16
624 %vc = srem <vscale x 32 x i16> %va, %vb
625 ret <vscale x 32 x i16> %vc
628 define <vscale x 32 x i16> @vrem_vx_nxv32i16(<vscale x 32 x i16> %va, i16 signext %b) {
629 ; CHECK-LABEL: vrem_vx_nxv32i16:
631 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
632 ; CHECK-NEXT: vrem.vx v8, v8, a0
634 %head = insertelement <vscale x 32 x i16> poison, i16 %b, i32 0
635 %splat = shufflevector <vscale x 32 x i16> %head, <vscale x 32 x i16> poison, <vscale x 32 x i32> zeroinitializer
636 %vc = srem <vscale x 32 x i16> %va, %splat
637 ret <vscale x 32 x i16> %vc
640 define <vscale x 32 x i16> @vrem_vi_nxv32i16_0(<vscale x 32 x i16> %va) {
641 ; CHECK-LABEL: vrem_vi_nxv32i16_0:
643 ; CHECK-NEXT: lui a0, 1048571
644 ; CHECK-NEXT: addi a0, a0, 1755
645 ; CHECK-NEXT: vsetvli a1, zero, e16, m8, ta, ma
646 ; CHECK-NEXT: vmulh.vx v16, v8, a0
647 ; CHECK-NEXT: vsra.vi v16, v16, 1
648 ; CHECK-NEXT: vsrl.vi v24, v16, 15
649 ; CHECK-NEXT: vadd.vv v16, v16, v24
650 ; CHECK-NEXT: li a0, -7
651 ; CHECK-NEXT: vnmsac.vx v8, a0, v16
653 %vc = srem <vscale x 32 x i16> %va, splat (i16 -7)
654 ret <vscale x 32 x i16> %vc
657 define <vscale x 1 x i32> @vrem_vv_nxv1i32(<vscale x 1 x i32> %va, <vscale x 1 x i32> %vb) {
658 ; CHECK-LABEL: vrem_vv_nxv1i32:
660 ; CHECK-NEXT: vsetvli a0, zero, e32, mf2, ta, ma
661 ; CHECK-NEXT: vrem.vv v8, v8, v9
663 %vc = srem <vscale x 1 x i32> %va, %vb
664 ret <vscale x 1 x i32> %vc
667 define <vscale x 1 x i32> @vrem_vx_nxv1i32(<vscale x 1 x i32> %va, i32 signext %b) {
668 ; CHECK-LABEL: vrem_vx_nxv1i32:
670 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
671 ; CHECK-NEXT: vrem.vx v8, v8, a0
673 %head = insertelement <vscale x 1 x i32> poison, i32 %b, i32 0
674 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer
675 %vc = srem <vscale x 1 x i32> %va, %splat
676 ret <vscale x 1 x i32> %vc
679 define <vscale x 1 x i32> @vrem_vi_nxv1i32_0(<vscale x 1 x i32> %va) {
680 ; RV32-LABEL: vrem_vi_nxv1i32_0:
682 ; RV32-NEXT: lui a0, 449390
683 ; RV32-NEXT: addi a0, a0, -1171
684 ; RV32-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
685 ; RV32-NEXT: vmulh.vx v9, v8, a0
686 ; RV32-NEXT: vsub.vv v9, v9, v8
687 ; RV32-NEXT: vsrl.vi v10, v9, 31
688 ; RV32-NEXT: vsra.vi v9, v9, 2
689 ; RV32-NEXT: vadd.vv v9, v9, v10
690 ; RV32-NEXT: li a0, -7
691 ; RV32-NEXT: vnmsac.vx v8, a0, v9
694 ; RV64-LABEL: vrem_vi_nxv1i32_0:
696 ; RV64-NEXT: lui a0, 449390
697 ; RV64-NEXT: addi a0, a0, -1171
698 ; RV64-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
699 ; RV64-NEXT: vmulh.vx v9, v8, a0
700 ; RV64-NEXT: vsub.vv v9, v9, v8
701 ; RV64-NEXT: vsra.vi v9, v9, 2
702 ; RV64-NEXT: vsrl.vi v10, v9, 31
703 ; RV64-NEXT: vadd.vv v9, v9, v10
704 ; RV64-NEXT: li a0, -7
705 ; RV64-NEXT: vnmsac.vx v8, a0, v9
707 %vc = srem <vscale x 1 x i32> %va, splat (i32 -7)
708 ret <vscale x 1 x i32> %vc
711 define <vscale x 2 x i32> @vrem_vv_nxv2i32(<vscale x 2 x i32> %va, <vscale x 2 x i32> %vb) {
712 ; CHECK-LABEL: vrem_vv_nxv2i32:
714 ; CHECK-NEXT: vsetvli a0, zero, e32, m1, ta, ma
715 ; CHECK-NEXT: vrem.vv v8, v8, v9
717 %vc = srem <vscale x 2 x i32> %va, %vb
718 ret <vscale x 2 x i32> %vc
721 define <vscale x 2 x i32> @vrem_vx_nxv2i32(<vscale x 2 x i32> %va, i32 signext %b) {
722 ; CHECK-LABEL: vrem_vx_nxv2i32:
724 ; CHECK-NEXT: vsetvli a1, zero, e32, m1, ta, ma
725 ; CHECK-NEXT: vrem.vx v8, v8, a0
727 %head = insertelement <vscale x 2 x i32> poison, i32 %b, i32 0
728 %splat = shufflevector <vscale x 2 x i32> %head, <vscale x 2 x i32> poison, <vscale x 2 x i32> zeroinitializer
729 %vc = srem <vscale x 2 x i32> %va, %splat
730 ret <vscale x 2 x i32> %vc
733 define <vscale x 2 x i32> @vrem_vi_nxv2i32_0(<vscale x 2 x i32> %va) {
734 ; RV32-LABEL: vrem_vi_nxv2i32_0:
736 ; RV32-NEXT: lui a0, 449390
737 ; RV32-NEXT: addi a0, a0, -1171
738 ; RV32-NEXT: vsetvli a1, zero, e32, m1, ta, ma
739 ; RV32-NEXT: vmulh.vx v9, v8, a0
740 ; RV32-NEXT: vsub.vv v9, v9, v8
741 ; RV32-NEXT: vsrl.vi v10, v9, 31
742 ; RV32-NEXT: vsra.vi v9, v9, 2
743 ; RV32-NEXT: vadd.vv v9, v9, v10
744 ; RV32-NEXT: li a0, -7
745 ; RV32-NEXT: vnmsac.vx v8, a0, v9
748 ; RV64-LABEL: vrem_vi_nxv2i32_0:
750 ; RV64-NEXT: lui a0, 449390
751 ; RV64-NEXT: addi a0, a0, -1171
752 ; RV64-NEXT: vsetvli a1, zero, e32, m1, ta, ma
753 ; RV64-NEXT: vmulh.vx v9, v8, a0
754 ; RV64-NEXT: vsub.vv v9, v9, v8
755 ; RV64-NEXT: vsra.vi v9, v9, 2
756 ; RV64-NEXT: vsrl.vi v10, v9, 31
757 ; RV64-NEXT: vadd.vv v9, v9, v10
758 ; RV64-NEXT: li a0, -7
759 ; RV64-NEXT: vnmsac.vx v8, a0, v9
761 %vc = srem <vscale x 2 x i32> %va, splat (i32 -7)
762 ret <vscale x 2 x i32> %vc
765 define <vscale x 4 x i32> @vrem_vv_nxv4i32(<vscale x 4 x i32> %va, <vscale x 4 x i32> %vb) {
766 ; CHECK-LABEL: vrem_vv_nxv4i32:
768 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
769 ; CHECK-NEXT: vrem.vv v8, v8, v10
771 %vc = srem <vscale x 4 x i32> %va, %vb
772 ret <vscale x 4 x i32> %vc
775 define <vscale x 4 x i32> @vrem_vx_nxv4i32(<vscale x 4 x i32> %va, i32 signext %b) {
776 ; CHECK-LABEL: vrem_vx_nxv4i32:
778 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
779 ; CHECK-NEXT: vrem.vx v8, v8, a0
781 %head = insertelement <vscale x 4 x i32> poison, i32 %b, i32 0
782 %splat = shufflevector <vscale x 4 x i32> %head, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
783 %vc = srem <vscale x 4 x i32> %va, %splat
784 ret <vscale x 4 x i32> %vc
787 define <vscale x 4 x i32> @vrem_vi_nxv4i32_0(<vscale x 4 x i32> %va) {
788 ; RV32-LABEL: vrem_vi_nxv4i32_0:
790 ; RV32-NEXT: lui a0, 449390
791 ; RV32-NEXT: addi a0, a0, -1171
792 ; RV32-NEXT: vsetvli a1, zero, e32, m2, ta, ma
793 ; RV32-NEXT: vmulh.vx v10, v8, a0
794 ; RV32-NEXT: vsub.vv v10, v10, v8
795 ; RV32-NEXT: vsrl.vi v12, v10, 31
796 ; RV32-NEXT: vsra.vi v10, v10, 2
797 ; RV32-NEXT: vadd.vv v10, v10, v12
798 ; RV32-NEXT: li a0, -7
799 ; RV32-NEXT: vnmsac.vx v8, a0, v10
802 ; RV64-LABEL: vrem_vi_nxv4i32_0:
804 ; RV64-NEXT: lui a0, 449390
805 ; RV64-NEXT: addi a0, a0, -1171
806 ; RV64-NEXT: vsetvli a1, zero, e32, m2, ta, ma
807 ; RV64-NEXT: vmulh.vx v10, v8, a0
808 ; RV64-NEXT: vsub.vv v10, v10, v8
809 ; RV64-NEXT: vsra.vi v10, v10, 2
810 ; RV64-NEXT: vsrl.vi v12, v10, 31
811 ; RV64-NEXT: vadd.vv v10, v10, v12
812 ; RV64-NEXT: li a0, -7
813 ; RV64-NEXT: vnmsac.vx v8, a0, v10
815 %vc = srem <vscale x 4 x i32> %va, splat (i32 -7)
816 ret <vscale x 4 x i32> %vc
819 define <vscale x 8 x i32> @vrem_vv_nxv8i32(<vscale x 8 x i32> %va, <vscale x 8 x i32> %vb) {
820 ; CHECK-LABEL: vrem_vv_nxv8i32:
822 ; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, ma
823 ; CHECK-NEXT: vrem.vv v8, v8, v12
825 %vc = srem <vscale x 8 x i32> %va, %vb
826 ret <vscale x 8 x i32> %vc
829 define <vscale x 8 x i32> @vrem_vx_nxv8i32(<vscale x 8 x i32> %va, i32 signext %b) {
830 ; CHECK-LABEL: vrem_vx_nxv8i32:
832 ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
833 ; CHECK-NEXT: vrem.vx v8, v8, a0
835 %head = insertelement <vscale x 8 x i32> poison, i32 %b, i32 0
836 %splat = shufflevector <vscale x 8 x i32> %head, <vscale x 8 x i32> poison, <vscale x 8 x i32> zeroinitializer
837 %vc = srem <vscale x 8 x i32> %va, %splat
838 ret <vscale x 8 x i32> %vc
841 define <vscale x 8 x i32> @vrem_vi_nxv8i32_0(<vscale x 8 x i32> %va) {
842 ; RV32-LABEL: vrem_vi_nxv8i32_0:
844 ; RV32-NEXT: lui a0, 449390
845 ; RV32-NEXT: addi a0, a0, -1171
846 ; RV32-NEXT: vsetvli a1, zero, e32, m4, ta, ma
847 ; RV32-NEXT: vmulh.vx v12, v8, a0
848 ; RV32-NEXT: vsub.vv v12, v12, v8
849 ; RV32-NEXT: vsrl.vi v16, v12, 31
850 ; RV32-NEXT: vsra.vi v12, v12, 2
851 ; RV32-NEXT: vadd.vv v12, v12, v16
852 ; RV32-NEXT: li a0, -7
853 ; RV32-NEXT: vnmsac.vx v8, a0, v12
856 ; RV64-LABEL: vrem_vi_nxv8i32_0:
858 ; RV64-NEXT: lui a0, 449390
859 ; RV64-NEXT: addi a0, a0, -1171
860 ; RV64-NEXT: vsetvli a1, zero, e32, m4, ta, ma
861 ; RV64-NEXT: vmulh.vx v12, v8, a0
862 ; RV64-NEXT: vsub.vv v12, v12, v8
863 ; RV64-NEXT: vsra.vi v12, v12, 2
864 ; RV64-NEXT: vsrl.vi v16, v12, 31
865 ; RV64-NEXT: vadd.vv v12, v12, v16
866 ; RV64-NEXT: li a0, -7
867 ; RV64-NEXT: vnmsac.vx v8, a0, v12
869 %vc = srem <vscale x 8 x i32> %va, splat (i32 -7)
870 ret <vscale x 8 x i32> %vc
873 define <vscale x 16 x i32> @vrem_vv_nxv16i32(<vscale x 16 x i32> %va, <vscale x 16 x i32> %vb) {
874 ; CHECK-LABEL: vrem_vv_nxv16i32:
876 ; CHECK-NEXT: vsetvli a0, zero, e32, m8, ta, ma
877 ; CHECK-NEXT: vrem.vv v8, v8, v16
879 %vc = srem <vscale x 16 x i32> %va, %vb
880 ret <vscale x 16 x i32> %vc
883 define <vscale x 16 x i32> @vrem_vx_nxv16i32(<vscale x 16 x i32> %va, i32 signext %b) {
884 ; CHECK-LABEL: vrem_vx_nxv16i32:
886 ; CHECK-NEXT: vsetvli a1, zero, e32, m8, ta, ma
887 ; CHECK-NEXT: vrem.vx v8, v8, a0
889 %head = insertelement <vscale x 16 x i32> poison, i32 %b, i32 0
890 %splat = shufflevector <vscale x 16 x i32> %head, <vscale x 16 x i32> poison, <vscale x 16 x i32> zeroinitializer
891 %vc = srem <vscale x 16 x i32> %va, %splat
892 ret <vscale x 16 x i32> %vc
895 define <vscale x 16 x i32> @vrem_vi_nxv16i32_0(<vscale x 16 x i32> %va) {
896 ; RV32-LABEL: vrem_vi_nxv16i32_0:
898 ; RV32-NEXT: lui a0, 449390
899 ; RV32-NEXT: addi a0, a0, -1171
900 ; RV32-NEXT: vsetvli a1, zero, e32, m8, ta, ma
901 ; RV32-NEXT: vmulh.vx v16, v8, a0
902 ; RV32-NEXT: vsub.vv v16, v16, v8
903 ; RV32-NEXT: vsrl.vi v24, v16, 31
904 ; RV32-NEXT: vsra.vi v16, v16, 2
905 ; RV32-NEXT: vadd.vv v16, v16, v24
906 ; RV32-NEXT: li a0, -7
907 ; RV32-NEXT: vnmsac.vx v8, a0, v16
910 ; RV64-LABEL: vrem_vi_nxv16i32_0:
912 ; RV64-NEXT: lui a0, 449390
913 ; RV64-NEXT: addi a0, a0, -1171
914 ; RV64-NEXT: vsetvli a1, zero, e32, m8, ta, ma
915 ; RV64-NEXT: vmulh.vx v16, v8, a0
916 ; RV64-NEXT: vsub.vv v16, v16, v8
917 ; RV64-NEXT: vsra.vi v16, v16, 2
918 ; RV64-NEXT: vsrl.vi v24, v16, 31
919 ; RV64-NEXT: vadd.vv v16, v16, v24
920 ; RV64-NEXT: li a0, -7
921 ; RV64-NEXT: vnmsac.vx v8, a0, v16
923 %vc = srem <vscale x 16 x i32> %va, splat (i32 -7)
924 ret <vscale x 16 x i32> %vc
927 define <vscale x 1 x i64> @vrem_vv_nxv1i64(<vscale x 1 x i64> %va, <vscale x 1 x i64> %vb) {
928 ; CHECK-LABEL: vrem_vv_nxv1i64:
930 ; CHECK-NEXT: vsetvli a0, zero, e64, m1, ta, ma
931 ; CHECK-NEXT: vrem.vv v8, v8, v9
933 %vc = srem <vscale x 1 x i64> %va, %vb
934 ret <vscale x 1 x i64> %vc
937 define <vscale x 1 x i64> @vrem_vx_nxv1i64(<vscale x 1 x i64> %va, i64 %b) {
938 ; RV32-LABEL: vrem_vx_nxv1i64:
940 ; RV32-NEXT: addi sp, sp, -16
941 ; RV32-NEXT: .cfi_def_cfa_offset 16
942 ; RV32-NEXT: sw a1, 12(sp)
943 ; RV32-NEXT: sw a0, 8(sp)
944 ; RV32-NEXT: addi a0, sp, 8
945 ; RV32-NEXT: vsetvli a1, zero, e64, m1, ta, ma
946 ; RV32-NEXT: vlse64.v v9, (a0), zero
947 ; RV32-NEXT: vrem.vv v8, v8, v9
948 ; RV32-NEXT: addi sp, sp, 16
951 ; RV64-LABEL: vrem_vx_nxv1i64:
953 ; RV64-NEXT: vsetvli a1, zero, e64, m1, ta, ma
954 ; RV64-NEXT: vrem.vx v8, v8, a0
956 %head = insertelement <vscale x 1 x i64> poison, i64 %b, i32 0
957 %splat = shufflevector <vscale x 1 x i64> %head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
958 %vc = srem <vscale x 1 x i64> %va, %splat
959 ret <vscale x 1 x i64> %vc
962 define <vscale x 1 x i64> @vrem_vi_nxv1i64_0(<vscale x 1 x i64> %va) {
963 ; RV32-V-LABEL: vrem_vi_nxv1i64_0:
965 ; RV32-V-NEXT: addi sp, sp, -16
966 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
967 ; RV32-V-NEXT: lui a0, 748983
968 ; RV32-V-NEXT: addi a0, a0, -586
969 ; RV32-V-NEXT: sw a0, 12(sp)
970 ; RV32-V-NEXT: lui a0, 898779
971 ; RV32-V-NEXT: addi a0, a0, 1755
972 ; RV32-V-NEXT: sw a0, 8(sp)
973 ; RV32-V-NEXT: addi a0, sp, 8
974 ; RV32-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
975 ; RV32-V-NEXT: vlse64.v v9, (a0), zero
976 ; RV32-V-NEXT: vmulh.vv v9, v8, v9
977 ; RV32-V-NEXT: li a0, 63
978 ; RV32-V-NEXT: vsrl.vx v10, v9, a0
979 ; RV32-V-NEXT: vsra.vi v9, v9, 1
980 ; RV32-V-NEXT: vadd.vv v9, v9, v10
981 ; RV32-V-NEXT: li a0, -7
982 ; RV32-V-NEXT: vnmsac.vx v8, a0, v9
983 ; RV32-V-NEXT: addi sp, sp, 16
986 ; ZVE64X-LABEL: vrem_vi_nxv1i64_0:
988 ; ZVE64X-NEXT: li a0, -7
989 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m1, ta, ma
990 ; ZVE64X-NEXT: vrem.vx v8, v8, a0
993 ; RV64-V-LABEL: vrem_vi_nxv1i64_0:
995 ; RV64-V-NEXT: lui a0, %hi(.LCPI67_0)
996 ; RV64-V-NEXT: ld a0, %lo(.LCPI67_0)(a0)
997 ; RV64-V-NEXT: vsetvli a1, zero, e64, m1, ta, ma
998 ; RV64-V-NEXT: vmulh.vx v9, v8, a0
999 ; RV64-V-NEXT: li a0, 63
1000 ; RV64-V-NEXT: vsrl.vx v10, v9, a0
1001 ; RV64-V-NEXT: vsra.vi v9, v9, 1
1002 ; RV64-V-NEXT: vadd.vv v9, v9, v10
1003 ; RV64-V-NEXT: li a0, -7
1004 ; RV64-V-NEXT: vnmsac.vx v8, a0, v9
1006 %vc = srem <vscale x 1 x i64> %va, splat (i64 -7)
1007 ret <vscale x 1 x i64> %vc
1010 define <vscale x 2 x i64> @vrem_vv_nxv2i64(<vscale x 2 x i64> %va, <vscale x 2 x i64> %vb) {
1011 ; CHECK-LABEL: vrem_vv_nxv2i64:
1013 ; CHECK-NEXT: vsetvli a0, zero, e64, m2, ta, ma
1014 ; CHECK-NEXT: vrem.vv v8, v8, v10
1016 %vc = srem <vscale x 2 x i64> %va, %vb
1017 ret <vscale x 2 x i64> %vc
1020 define <vscale x 2 x i64> @vrem_vx_nxv2i64(<vscale x 2 x i64> %va, i64 %b) {
1021 ; RV32-LABEL: vrem_vx_nxv2i64:
1023 ; RV32-NEXT: addi sp, sp, -16
1024 ; RV32-NEXT: .cfi_def_cfa_offset 16
1025 ; RV32-NEXT: sw a1, 12(sp)
1026 ; RV32-NEXT: sw a0, 8(sp)
1027 ; RV32-NEXT: addi a0, sp, 8
1028 ; RV32-NEXT: vsetvli a1, zero, e64, m2, ta, ma
1029 ; RV32-NEXT: vlse64.v v10, (a0), zero
1030 ; RV32-NEXT: vrem.vv v8, v8, v10
1031 ; RV32-NEXT: addi sp, sp, 16
1034 ; RV64-LABEL: vrem_vx_nxv2i64:
1036 ; RV64-NEXT: vsetvli a1, zero, e64, m2, ta, ma
1037 ; RV64-NEXT: vrem.vx v8, v8, a0
1039 %head = insertelement <vscale x 2 x i64> poison, i64 %b, i32 0
1040 %splat = shufflevector <vscale x 2 x i64> %head, <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
1041 %vc = srem <vscale x 2 x i64> %va, %splat
1042 ret <vscale x 2 x i64> %vc
1045 define <vscale x 2 x i64> @vrem_vi_nxv2i64_0(<vscale x 2 x i64> %va) {
1046 ; RV32-V-LABEL: vrem_vi_nxv2i64_0:
1048 ; RV32-V-NEXT: addi sp, sp, -16
1049 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1050 ; RV32-V-NEXT: lui a0, 748983
1051 ; RV32-V-NEXT: addi a0, a0, -586
1052 ; RV32-V-NEXT: sw a0, 12(sp)
1053 ; RV32-V-NEXT: lui a0, 898779
1054 ; RV32-V-NEXT: addi a0, a0, 1755
1055 ; RV32-V-NEXT: sw a0, 8(sp)
1056 ; RV32-V-NEXT: addi a0, sp, 8
1057 ; RV32-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
1058 ; RV32-V-NEXT: vlse64.v v10, (a0), zero
1059 ; RV32-V-NEXT: vmulh.vv v10, v8, v10
1060 ; RV32-V-NEXT: li a0, 63
1061 ; RV32-V-NEXT: vsrl.vx v12, v10, a0
1062 ; RV32-V-NEXT: vsra.vi v10, v10, 1
1063 ; RV32-V-NEXT: vadd.vv v10, v10, v12
1064 ; RV32-V-NEXT: li a0, -7
1065 ; RV32-V-NEXT: vnmsac.vx v8, a0, v10
1066 ; RV32-V-NEXT: addi sp, sp, 16
1069 ; ZVE64X-LABEL: vrem_vi_nxv2i64_0:
1071 ; ZVE64X-NEXT: li a0, -7
1072 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m2, ta, ma
1073 ; ZVE64X-NEXT: vrem.vx v8, v8, a0
1076 ; RV64-V-LABEL: vrem_vi_nxv2i64_0:
1078 ; RV64-V-NEXT: lui a0, %hi(.LCPI70_0)
1079 ; RV64-V-NEXT: ld a0, %lo(.LCPI70_0)(a0)
1080 ; RV64-V-NEXT: vsetvli a1, zero, e64, m2, ta, ma
1081 ; RV64-V-NEXT: vmulh.vx v10, v8, a0
1082 ; RV64-V-NEXT: li a0, 63
1083 ; RV64-V-NEXT: vsrl.vx v12, v10, a0
1084 ; RV64-V-NEXT: vsra.vi v10, v10, 1
1085 ; RV64-V-NEXT: vadd.vv v10, v10, v12
1086 ; RV64-V-NEXT: li a0, -7
1087 ; RV64-V-NEXT: vnmsac.vx v8, a0, v10
1089 %vc = srem <vscale x 2 x i64> %va, splat (i64 -7)
1090 ret <vscale x 2 x i64> %vc
1093 define <vscale x 4 x i64> @vrem_vv_nxv4i64(<vscale x 4 x i64> %va, <vscale x 4 x i64> %vb) {
1094 ; CHECK-LABEL: vrem_vv_nxv4i64:
1096 ; CHECK-NEXT: vsetvli a0, zero, e64, m4, ta, ma
1097 ; CHECK-NEXT: vrem.vv v8, v8, v12
1099 %vc = srem <vscale x 4 x i64> %va, %vb
1100 ret <vscale x 4 x i64> %vc
1103 define <vscale x 4 x i64> @vrem_vx_nxv4i64(<vscale x 4 x i64> %va, i64 %b) {
1104 ; RV32-LABEL: vrem_vx_nxv4i64:
1106 ; RV32-NEXT: addi sp, sp, -16
1107 ; RV32-NEXT: .cfi_def_cfa_offset 16
1108 ; RV32-NEXT: sw a1, 12(sp)
1109 ; RV32-NEXT: sw a0, 8(sp)
1110 ; RV32-NEXT: addi a0, sp, 8
1111 ; RV32-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1112 ; RV32-NEXT: vlse64.v v12, (a0), zero
1113 ; RV32-NEXT: vrem.vv v8, v8, v12
1114 ; RV32-NEXT: addi sp, sp, 16
1117 ; RV64-LABEL: vrem_vx_nxv4i64:
1119 ; RV64-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1120 ; RV64-NEXT: vrem.vx v8, v8, a0
1122 %head = insertelement <vscale x 4 x i64> poison, i64 %b, i32 0
1123 %splat = shufflevector <vscale x 4 x i64> %head, <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
1124 %vc = srem <vscale x 4 x i64> %va, %splat
1125 ret <vscale x 4 x i64> %vc
1128 define <vscale x 4 x i64> @vrem_vi_nxv4i64_0(<vscale x 4 x i64> %va) {
1129 ; RV32-V-LABEL: vrem_vi_nxv4i64_0:
1131 ; RV32-V-NEXT: addi sp, sp, -16
1132 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1133 ; RV32-V-NEXT: lui a0, 748983
1134 ; RV32-V-NEXT: addi a0, a0, -586
1135 ; RV32-V-NEXT: sw a0, 12(sp)
1136 ; RV32-V-NEXT: lui a0, 898779
1137 ; RV32-V-NEXT: addi a0, a0, 1755
1138 ; RV32-V-NEXT: sw a0, 8(sp)
1139 ; RV32-V-NEXT: addi a0, sp, 8
1140 ; RV32-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1141 ; RV32-V-NEXT: vlse64.v v12, (a0), zero
1142 ; RV32-V-NEXT: vmulh.vv v12, v8, v12
1143 ; RV32-V-NEXT: li a0, 63
1144 ; RV32-V-NEXT: vsrl.vx v16, v12, a0
1145 ; RV32-V-NEXT: vsra.vi v12, v12, 1
1146 ; RV32-V-NEXT: vadd.vv v12, v12, v16
1147 ; RV32-V-NEXT: li a0, -7
1148 ; RV32-V-NEXT: vnmsac.vx v8, a0, v12
1149 ; RV32-V-NEXT: addi sp, sp, 16
1152 ; ZVE64X-LABEL: vrem_vi_nxv4i64_0:
1154 ; ZVE64X-NEXT: li a0, -7
1155 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1156 ; ZVE64X-NEXT: vrem.vx v8, v8, a0
1159 ; RV64-V-LABEL: vrem_vi_nxv4i64_0:
1161 ; RV64-V-NEXT: lui a0, %hi(.LCPI73_0)
1162 ; RV64-V-NEXT: ld a0, %lo(.LCPI73_0)(a0)
1163 ; RV64-V-NEXT: vsetvli a1, zero, e64, m4, ta, ma
1164 ; RV64-V-NEXT: vmulh.vx v12, v8, a0
1165 ; RV64-V-NEXT: li a0, 63
1166 ; RV64-V-NEXT: vsrl.vx v16, v12, a0
1167 ; RV64-V-NEXT: vsra.vi v12, v12, 1
1168 ; RV64-V-NEXT: vadd.vv v12, v12, v16
1169 ; RV64-V-NEXT: li a0, -7
1170 ; RV64-V-NEXT: vnmsac.vx v8, a0, v12
1172 %vc = srem <vscale x 4 x i64> %va, splat (i64 -7)
1173 ret <vscale x 4 x i64> %vc
1176 define <vscale x 8 x i64> @vrem_vv_nxv8i64(<vscale x 8 x i64> %va, <vscale x 8 x i64> %vb) {
1177 ; CHECK-LABEL: vrem_vv_nxv8i64:
1179 ; CHECK-NEXT: vsetvli a0, zero, e64, m8, ta, ma
1180 ; CHECK-NEXT: vrem.vv v8, v8, v16
1182 %vc = srem <vscale x 8 x i64> %va, %vb
1183 ret <vscale x 8 x i64> %vc
1186 define <vscale x 8 x i64> @vrem_vx_nxv8i64(<vscale x 8 x i64> %va, i64 %b) {
1187 ; RV32-LABEL: vrem_vx_nxv8i64:
1189 ; RV32-NEXT: addi sp, sp, -16
1190 ; RV32-NEXT: .cfi_def_cfa_offset 16
1191 ; RV32-NEXT: sw a1, 12(sp)
1192 ; RV32-NEXT: sw a0, 8(sp)
1193 ; RV32-NEXT: addi a0, sp, 8
1194 ; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1195 ; RV32-NEXT: vlse64.v v16, (a0), zero
1196 ; RV32-NEXT: vrem.vv v8, v8, v16
1197 ; RV32-NEXT: addi sp, sp, 16
1200 ; RV64-LABEL: vrem_vx_nxv8i64:
1202 ; RV64-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1203 ; RV64-NEXT: vrem.vx v8, v8, a0
1205 %head = insertelement <vscale x 8 x i64> poison, i64 %b, i32 0
1206 %splat = shufflevector <vscale x 8 x i64> %head, <vscale x 8 x i64> poison, <vscale x 8 x i32> zeroinitializer
1207 %vc = srem <vscale x 8 x i64> %va, %splat
1208 ret <vscale x 8 x i64> %vc
1211 define <vscale x 8 x i64> @vrem_vi_nxv8i64_0(<vscale x 8 x i64> %va) {
1212 ; RV32-V-LABEL: vrem_vi_nxv8i64_0:
1214 ; RV32-V-NEXT: addi sp, sp, -16
1215 ; RV32-V-NEXT: .cfi_def_cfa_offset 16
1216 ; RV32-V-NEXT: lui a0, 748983
1217 ; RV32-V-NEXT: addi a0, a0, -586
1218 ; RV32-V-NEXT: sw a0, 12(sp)
1219 ; RV32-V-NEXT: lui a0, 898779
1220 ; RV32-V-NEXT: addi a0, a0, 1755
1221 ; RV32-V-NEXT: sw a0, 8(sp)
1222 ; RV32-V-NEXT: addi a0, sp, 8
1223 ; RV32-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1224 ; RV32-V-NEXT: vlse64.v v16, (a0), zero
1225 ; RV32-V-NEXT: vmulh.vv v16, v8, v16
1226 ; RV32-V-NEXT: li a0, 63
1227 ; RV32-V-NEXT: vsrl.vx v24, v16, a0
1228 ; RV32-V-NEXT: vsra.vi v16, v16, 1
1229 ; RV32-V-NEXT: vadd.vv v16, v16, v24
1230 ; RV32-V-NEXT: li a0, -7
1231 ; RV32-V-NEXT: vnmsac.vx v8, a0, v16
1232 ; RV32-V-NEXT: addi sp, sp, 16
1235 ; ZVE64X-LABEL: vrem_vi_nxv8i64_0:
1237 ; ZVE64X-NEXT: li a0, -7
1238 ; ZVE64X-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1239 ; ZVE64X-NEXT: vrem.vx v8, v8, a0
1242 ; RV64-V-LABEL: vrem_vi_nxv8i64_0:
1244 ; RV64-V-NEXT: lui a0, %hi(.LCPI76_0)
1245 ; RV64-V-NEXT: ld a0, %lo(.LCPI76_0)(a0)
1246 ; RV64-V-NEXT: vsetvli a1, zero, e64, m8, ta, ma
1247 ; RV64-V-NEXT: vmulh.vx v16, v8, a0
1248 ; RV64-V-NEXT: li a0, 63
1249 ; RV64-V-NEXT: vsrl.vx v24, v16, a0
1250 ; RV64-V-NEXT: vsra.vi v16, v16, 1
1251 ; RV64-V-NEXT: vadd.vv v16, v16, v24
1252 ; RV64-V-NEXT: li a0, -7
1253 ; RV64-V-NEXT: vnmsac.vx v8, a0, v16
1255 %vc = srem <vscale x 8 x i64> %va, splat (i64 -7)
1256 ret <vscale x 8 x i64> %vc