1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=RV32
3 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=RV64
4 ; RUN: llc -mtriple=riscv32 -mattr=+m < %s | FileCheck %s --check-prefixes=RV32M
5 ; RUN: llc -mtriple=riscv64 -mattr=+m < %s | FileCheck %s --check-prefixes=RV64M
6 ; RUN: llc -mtriple=riscv32 -mattr=+m,+v -riscv-v-vector-bits-min=128 < %s | FileCheck %s --check-prefixes=RV32MV
7 ; RUN: llc -mtriple=riscv64 -mattr=+m,+v -riscv-v-vector-bits-min=128 < %s | FileCheck %s --check-prefixes=RV64MV
9 define i1 @test_urem_odd(i13 %X) nounwind {
10 ; RV32-LABEL: test_urem_odd:
12 ; RV32-NEXT: addi sp, sp, -16
13 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
14 ; RV32-NEXT: lui a1, 1
15 ; RV32-NEXT: addi a1, a1, -819
16 ; RV32-NEXT: call __mulsi3@plt
17 ; RV32-NEXT: slli a0, a0, 19
18 ; RV32-NEXT: srli a0, a0, 19
19 ; RV32-NEXT: sltiu a0, a0, 1639
20 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
21 ; RV32-NEXT: addi sp, sp, 16
24 ; RV64-LABEL: test_urem_odd:
26 ; RV64-NEXT: addi sp, sp, -16
27 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
28 ; RV64-NEXT: lui a1, 1
29 ; RV64-NEXT: addiw a1, a1, -819
30 ; RV64-NEXT: call __muldi3@plt
31 ; RV64-NEXT: slli a0, a0, 51
32 ; RV64-NEXT: srli a0, a0, 51
33 ; RV64-NEXT: sltiu a0, a0, 1639
34 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
35 ; RV64-NEXT: addi sp, sp, 16
38 ; RV32M-LABEL: test_urem_odd:
40 ; RV32M-NEXT: lui a1, 1
41 ; RV32M-NEXT: addi a1, a1, -819
42 ; RV32M-NEXT: mul a0, a0, a1
43 ; RV32M-NEXT: slli a0, a0, 19
44 ; RV32M-NEXT: srli a0, a0, 19
45 ; RV32M-NEXT: sltiu a0, a0, 1639
48 ; RV64M-LABEL: test_urem_odd:
50 ; RV64M-NEXT: lui a1, 1
51 ; RV64M-NEXT: addiw a1, a1, -819
52 ; RV64M-NEXT: mulw a0, a0, a1
53 ; RV64M-NEXT: slli a0, a0, 51
54 ; RV64M-NEXT: srli a0, a0, 51
55 ; RV64M-NEXT: sltiu a0, a0, 1639
58 ; RV32MV-LABEL: test_urem_odd:
60 ; RV32MV-NEXT: lui a1, 1
61 ; RV32MV-NEXT: addi a1, a1, -819
62 ; RV32MV-NEXT: mul a0, a0, a1
63 ; RV32MV-NEXT: slli a0, a0, 19
64 ; RV32MV-NEXT: srli a0, a0, 19
65 ; RV32MV-NEXT: sltiu a0, a0, 1639
68 ; RV64MV-LABEL: test_urem_odd:
70 ; RV64MV-NEXT: lui a1, 1
71 ; RV64MV-NEXT: addiw a1, a1, -819
72 ; RV64MV-NEXT: mulw a0, a0, a1
73 ; RV64MV-NEXT: slli a0, a0, 51
74 ; RV64MV-NEXT: srli a0, a0, 51
75 ; RV64MV-NEXT: sltiu a0, a0, 1639
77 %urem = urem i13 %X, 5
78 %cmp = icmp eq i13 %urem, 0
82 define i1 @test_urem_even(i27 %X) nounwind {
83 ; RV32-LABEL: test_urem_even:
85 ; RV32-NEXT: addi sp, sp, -16
86 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
87 ; RV32-NEXT: lui a1, 28087
88 ; RV32-NEXT: addi a1, a1, -585
89 ; RV32-NEXT: call __mulsi3@plt
90 ; RV32-NEXT: slli a1, a0, 26
91 ; RV32-NEXT: slli a0, a0, 5
92 ; RV32-NEXT: srli a0, a0, 6
93 ; RV32-NEXT: or a0, a0, a1
94 ; RV32-NEXT: slli a0, a0, 5
95 ; RV32-NEXT: srli a0, a0, 5
96 ; RV32-NEXT: lui a1, 2341
97 ; RV32-NEXT: addi a1, a1, -1755
98 ; RV32-NEXT: sltu a0, a0, a1
99 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
100 ; RV32-NEXT: addi sp, sp, 16
103 ; RV64-LABEL: test_urem_even:
105 ; RV64-NEXT: addi sp, sp, -16
106 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
107 ; RV64-NEXT: lui a1, 28087
108 ; RV64-NEXT: addiw a1, a1, -585
109 ; RV64-NEXT: call __muldi3@plt
110 ; RV64-NEXT: slli a1, a0, 26
111 ; RV64-NEXT: slli a0, a0, 37
112 ; RV64-NEXT: srli a0, a0, 38
113 ; RV64-NEXT: or a0, a0, a1
114 ; RV64-NEXT: slli a0, a0, 37
115 ; RV64-NEXT: srli a0, a0, 37
116 ; RV64-NEXT: lui a1, 2341
117 ; RV64-NEXT: addiw a1, a1, -1755
118 ; RV64-NEXT: sltu a0, a0, a1
119 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
120 ; RV64-NEXT: addi sp, sp, 16
123 ; RV32M-LABEL: test_urem_even:
125 ; RV32M-NEXT: lui a1, 28087
126 ; RV32M-NEXT: addi a1, a1, -585
127 ; RV32M-NEXT: mul a0, a0, a1
128 ; RV32M-NEXT: slli a1, a0, 26
129 ; RV32M-NEXT: slli a0, a0, 5
130 ; RV32M-NEXT: srli a0, a0, 6
131 ; RV32M-NEXT: or a0, a0, a1
132 ; RV32M-NEXT: slli a0, a0, 5
133 ; RV32M-NEXT: srli a0, a0, 5
134 ; RV32M-NEXT: lui a1, 2341
135 ; RV32M-NEXT: addi a1, a1, -1755
136 ; RV32M-NEXT: sltu a0, a0, a1
139 ; RV64M-LABEL: test_urem_even:
141 ; RV64M-NEXT: lui a1, 28087
142 ; RV64M-NEXT: addiw a1, a1, -585
143 ; RV64M-NEXT: mul a0, a0, a1
144 ; RV64M-NEXT: slli a1, a0, 26
145 ; RV64M-NEXT: slli a0, a0, 37
146 ; RV64M-NEXT: srli a0, a0, 38
147 ; RV64M-NEXT: or a0, a0, a1
148 ; RV64M-NEXT: slli a0, a0, 37
149 ; RV64M-NEXT: srli a0, a0, 37
150 ; RV64M-NEXT: lui a1, 2341
151 ; RV64M-NEXT: addiw a1, a1, -1755
152 ; RV64M-NEXT: sltu a0, a0, a1
155 ; RV32MV-LABEL: test_urem_even:
157 ; RV32MV-NEXT: lui a1, 28087
158 ; RV32MV-NEXT: addi a1, a1, -585
159 ; RV32MV-NEXT: mul a0, a0, a1
160 ; RV32MV-NEXT: slli a1, a0, 26
161 ; RV32MV-NEXT: slli a0, a0, 5
162 ; RV32MV-NEXT: srli a0, a0, 6
163 ; RV32MV-NEXT: or a0, a0, a1
164 ; RV32MV-NEXT: slli a0, a0, 5
165 ; RV32MV-NEXT: srli a0, a0, 5
166 ; RV32MV-NEXT: lui a1, 2341
167 ; RV32MV-NEXT: addi a1, a1, -1755
168 ; RV32MV-NEXT: sltu a0, a0, a1
171 ; RV64MV-LABEL: test_urem_even:
173 ; RV64MV-NEXT: lui a1, 28087
174 ; RV64MV-NEXT: addiw a1, a1, -585
175 ; RV64MV-NEXT: mul a0, a0, a1
176 ; RV64MV-NEXT: slli a1, a0, 26
177 ; RV64MV-NEXT: slli a0, a0, 37
178 ; RV64MV-NEXT: srli a0, a0, 38
179 ; RV64MV-NEXT: or a0, a0, a1
180 ; RV64MV-NEXT: slli a0, a0, 37
181 ; RV64MV-NEXT: srli a0, a0, 37
182 ; RV64MV-NEXT: lui a1, 2341
183 ; RV64MV-NEXT: addiw a1, a1, -1755
184 ; RV64MV-NEXT: sltu a0, a0, a1
186 %urem = urem i27 %X, 14
187 %cmp = icmp eq i27 %urem, 0
191 define i1 @test_urem_odd_setne(i4 %X) nounwind {
192 ; RV32-LABEL: test_urem_odd_setne:
194 ; RV32-NEXT: slli a1, a0, 1
195 ; RV32-NEXT: add a0, a1, a0
196 ; RV32-NEXT: neg a0, a0
197 ; RV32-NEXT: andi a0, a0, 15
198 ; RV32-NEXT: sltiu a0, a0, 4
199 ; RV32-NEXT: xori a0, a0, 1
202 ; RV64-LABEL: test_urem_odd_setne:
204 ; RV64-NEXT: slliw a1, a0, 1
205 ; RV64-NEXT: addw a0, a1, a0
206 ; RV64-NEXT: negw a0, a0
207 ; RV64-NEXT: andi a0, a0, 15
208 ; RV64-NEXT: sltiu a0, a0, 4
209 ; RV64-NEXT: xori a0, a0, 1
212 ; RV32M-LABEL: test_urem_odd_setne:
214 ; RV32M-NEXT: slli a1, a0, 1
215 ; RV32M-NEXT: add a0, a1, a0
216 ; RV32M-NEXT: neg a0, a0
217 ; RV32M-NEXT: andi a0, a0, 15
218 ; RV32M-NEXT: sltiu a0, a0, 4
219 ; RV32M-NEXT: xori a0, a0, 1
222 ; RV64M-LABEL: test_urem_odd_setne:
224 ; RV64M-NEXT: slliw a1, a0, 1
225 ; RV64M-NEXT: addw a0, a1, a0
226 ; RV64M-NEXT: negw a0, a0
227 ; RV64M-NEXT: andi a0, a0, 15
228 ; RV64M-NEXT: sltiu a0, a0, 4
229 ; RV64M-NEXT: xori a0, a0, 1
232 ; RV32MV-LABEL: test_urem_odd_setne:
234 ; RV32MV-NEXT: slli a1, a0, 1
235 ; RV32MV-NEXT: add a0, a1, a0
236 ; RV32MV-NEXT: neg a0, a0
237 ; RV32MV-NEXT: andi a0, a0, 15
238 ; RV32MV-NEXT: sltiu a0, a0, 4
239 ; RV32MV-NEXT: xori a0, a0, 1
242 ; RV64MV-LABEL: test_urem_odd_setne:
244 ; RV64MV-NEXT: slliw a1, a0, 1
245 ; RV64MV-NEXT: addw a0, a1, a0
246 ; RV64MV-NEXT: negw a0, a0
247 ; RV64MV-NEXT: andi a0, a0, 15
248 ; RV64MV-NEXT: sltiu a0, a0, 4
249 ; RV64MV-NEXT: xori a0, a0, 1
251 %urem = urem i4 %X, 5
252 %cmp = icmp ne i4 %urem, 0
256 define i1 @test_urem_negative_odd(i9 %X) nounwind {
257 ; RV32-LABEL: test_urem_negative_odd:
259 ; RV32-NEXT: addi sp, sp, -16
260 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
261 ; RV32-NEXT: li a1, 307
262 ; RV32-NEXT: call __mulsi3@plt
263 ; RV32-NEXT: andi a0, a0, 511
264 ; RV32-NEXT: sltiu a0, a0, 2
265 ; RV32-NEXT: xori a0, a0, 1
266 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
267 ; RV32-NEXT: addi sp, sp, 16
270 ; RV64-LABEL: test_urem_negative_odd:
272 ; RV64-NEXT: addi sp, sp, -16
273 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
274 ; RV64-NEXT: li a1, 307
275 ; RV64-NEXT: call __muldi3@plt
276 ; RV64-NEXT: andi a0, a0, 511
277 ; RV64-NEXT: sltiu a0, a0, 2
278 ; RV64-NEXT: xori a0, a0, 1
279 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
280 ; RV64-NEXT: addi sp, sp, 16
283 ; RV32M-LABEL: test_urem_negative_odd:
285 ; RV32M-NEXT: li a1, 307
286 ; RV32M-NEXT: mul a0, a0, a1
287 ; RV32M-NEXT: andi a0, a0, 511
288 ; RV32M-NEXT: sltiu a0, a0, 2
289 ; RV32M-NEXT: xori a0, a0, 1
292 ; RV64M-LABEL: test_urem_negative_odd:
294 ; RV64M-NEXT: li a1, 307
295 ; RV64M-NEXT: mulw a0, a0, a1
296 ; RV64M-NEXT: andi a0, a0, 511
297 ; RV64M-NEXT: sltiu a0, a0, 2
298 ; RV64M-NEXT: xori a0, a0, 1
301 ; RV32MV-LABEL: test_urem_negative_odd:
303 ; RV32MV-NEXT: li a1, 307
304 ; RV32MV-NEXT: mul a0, a0, a1
305 ; RV32MV-NEXT: andi a0, a0, 511
306 ; RV32MV-NEXT: sltiu a0, a0, 2
307 ; RV32MV-NEXT: xori a0, a0, 1
310 ; RV64MV-LABEL: test_urem_negative_odd:
312 ; RV64MV-NEXT: li a1, 307
313 ; RV64MV-NEXT: mulw a0, a0, a1
314 ; RV64MV-NEXT: andi a0, a0, 511
315 ; RV64MV-NEXT: sltiu a0, a0, 2
316 ; RV64MV-NEXT: xori a0, a0, 1
318 %urem = urem i9 %X, -5
319 %cmp = icmp ne i9 %urem, 0
323 define void @test_urem_vec(<3 x i11>* %X) nounwind {
324 ; RV32-LABEL: test_urem_vec:
326 ; RV32-NEXT: addi sp, sp, -32
327 ; RV32-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
328 ; RV32-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
329 ; RV32-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
330 ; RV32-NEXT: sw s2, 16(sp) # 4-byte Folded Spill
331 ; RV32-NEXT: sw s3, 12(sp) # 4-byte Folded Spill
332 ; RV32-NEXT: mv s0, a0
333 ; RV32-NEXT: lb a0, 4(a0)
334 ; RV32-NEXT: lw a1, 0(s0)
335 ; RV32-NEXT: slli a0, a0, 10
336 ; RV32-NEXT: srli a2, a1, 22
337 ; RV32-NEXT: or s1, a2, a0
338 ; RV32-NEXT: srli s2, a1, 11
339 ; RV32-NEXT: andi a0, a1, 2047
340 ; RV32-NEXT: li a1, 683
341 ; RV32-NEXT: call __mulsi3@plt
342 ; RV32-NEXT: slli a1, a0, 10
343 ; RV32-NEXT: slli a0, a0, 21
344 ; RV32-NEXT: srli a0, a0, 22
345 ; RV32-NEXT: or a0, a0, a1
346 ; RV32-NEXT: andi a0, a0, 2047
347 ; RV32-NEXT: sltiu s3, a0, 342
348 ; RV32-NEXT: li a1, 819
349 ; RV32-NEXT: mv a0, s1
350 ; RV32-NEXT: call __mulsi3@plt
351 ; RV32-NEXT: addi a0, a0, -1638
352 ; RV32-NEXT: andi a0, a0, 2047
353 ; RV32-NEXT: sltiu s1, a0, 2
354 ; RV32-NEXT: li a1, 1463
355 ; RV32-NEXT: mv a0, s2
356 ; RV32-NEXT: call __mulsi3@plt
357 ; RV32-NEXT: addi a0, a0, -1463
358 ; RV32-NEXT: andi a0, a0, 2047
359 ; RV32-NEXT: sltiu a0, a0, 293
360 ; RV32-NEXT: addi a1, s3, -1
361 ; RV32-NEXT: addi a0, a0, -1
362 ; RV32-NEXT: addi a2, s1, -1
363 ; RV32-NEXT: slli a3, a2, 21
364 ; RV32-NEXT: srli a3, a3, 31
365 ; RV32-NEXT: sb a3, 4(s0)
366 ; RV32-NEXT: andi a1, a1, 2047
367 ; RV32-NEXT: andi a0, a0, 2047
368 ; RV32-NEXT: slli a0, a0, 11
369 ; RV32-NEXT: or a0, a1, a0
370 ; RV32-NEXT: slli a1, a2, 22
371 ; RV32-NEXT: or a0, a0, a1
372 ; RV32-NEXT: sw a0, 0(s0)
373 ; RV32-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
374 ; RV32-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
375 ; RV32-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
376 ; RV32-NEXT: lw s2, 16(sp) # 4-byte Folded Reload
377 ; RV32-NEXT: lw s3, 12(sp) # 4-byte Folded Reload
378 ; RV32-NEXT: addi sp, sp, 32
381 ; RV64-LABEL: test_urem_vec:
383 ; RV64-NEXT: addi sp, sp, -48
384 ; RV64-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
385 ; RV64-NEXT: sd s0, 32(sp) # 8-byte Folded Spill
386 ; RV64-NEXT: sd s1, 24(sp) # 8-byte Folded Spill
387 ; RV64-NEXT: sd s2, 16(sp) # 8-byte Folded Spill
388 ; RV64-NEXT: sd s3, 8(sp) # 8-byte Folded Spill
389 ; RV64-NEXT: mv s0, a0
390 ; RV64-NEXT: lbu a0, 4(a0)
391 ; RV64-NEXT: lwu a1, 0(s0)
392 ; RV64-NEXT: slli a0, a0, 32
393 ; RV64-NEXT: or a0, a1, a0
394 ; RV64-NEXT: srli s1, a0, 22
395 ; RV64-NEXT: srli s2, a0, 11
396 ; RV64-NEXT: andi a0, a0, 2047
397 ; RV64-NEXT: li a1, 683
398 ; RV64-NEXT: call __muldi3@plt
399 ; RV64-NEXT: slli a1, a0, 10
400 ; RV64-NEXT: slli a0, a0, 53
401 ; RV64-NEXT: srli a0, a0, 54
402 ; RV64-NEXT: or a0, a0, a1
403 ; RV64-NEXT: andi a0, a0, 2047
404 ; RV64-NEXT: sltiu s3, a0, 342
405 ; RV64-NEXT: li a1, 1463
406 ; RV64-NEXT: mv a0, s2
407 ; RV64-NEXT: call __muldi3@plt
408 ; RV64-NEXT: addiw a0, a0, -1463
409 ; RV64-NEXT: andi a0, a0, 2047
410 ; RV64-NEXT: sltiu s2, a0, 293
411 ; RV64-NEXT: li a1, 819
412 ; RV64-NEXT: mv a0, s1
413 ; RV64-NEXT: call __muldi3@plt
414 ; RV64-NEXT: addiw a0, a0, -1638
415 ; RV64-NEXT: andi a0, a0, 2047
416 ; RV64-NEXT: sltiu a0, a0, 2
417 ; RV64-NEXT: addiw a1, s3, -1
418 ; RV64-NEXT: addi a0, a0, -1
419 ; RV64-NEXT: addiw a2, s2, -1
420 ; RV64-NEXT: andi a1, a1, 2047
421 ; RV64-NEXT: andi a2, a2, 2047
422 ; RV64-NEXT: slli a2, a2, 11
423 ; RV64-NEXT: or a1, a1, a2
424 ; RV64-NEXT: slli a0, a0, 22
425 ; RV64-NEXT: or a0, a1, a0
426 ; RV64-NEXT: sw a0, 0(s0)
427 ; RV64-NEXT: slli a0, a0, 31
428 ; RV64-NEXT: srli a0, a0, 63
429 ; RV64-NEXT: sb a0, 4(s0)
430 ; RV64-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
431 ; RV64-NEXT: ld s0, 32(sp) # 8-byte Folded Reload
432 ; RV64-NEXT: ld s1, 24(sp) # 8-byte Folded Reload
433 ; RV64-NEXT: ld s2, 16(sp) # 8-byte Folded Reload
434 ; RV64-NEXT: ld s3, 8(sp) # 8-byte Folded Reload
435 ; RV64-NEXT: addi sp, sp, 48
438 ; RV32M-LABEL: test_urem_vec:
440 ; RV32M-NEXT: lb a1, 4(a0)
441 ; RV32M-NEXT: lw a2, 0(a0)
442 ; RV32M-NEXT: slli a1, a1, 10
443 ; RV32M-NEXT: srli a3, a2, 22
444 ; RV32M-NEXT: or a1, a3, a1
445 ; RV32M-NEXT: srli a3, a2, 11
446 ; RV32M-NEXT: andi a2, a2, 2047
447 ; RV32M-NEXT: li a4, 683
448 ; RV32M-NEXT: mul a2, a2, a4
449 ; RV32M-NEXT: slli a4, a2, 10
450 ; RV32M-NEXT: slli a2, a2, 21
451 ; RV32M-NEXT: srli a2, a2, 22
452 ; RV32M-NEXT: or a2, a2, a4
453 ; RV32M-NEXT: andi a2, a2, 2047
454 ; RV32M-NEXT: sltiu a2, a2, 342
455 ; RV32M-NEXT: li a4, 819
456 ; RV32M-NEXT: mul a1, a1, a4
457 ; RV32M-NEXT: addi a1, a1, -1638
458 ; RV32M-NEXT: andi a1, a1, 2047
459 ; RV32M-NEXT: sltiu a1, a1, 2
460 ; RV32M-NEXT: li a4, 1463
461 ; RV32M-NEXT: mul a3, a3, a4
462 ; RV32M-NEXT: addi a3, a3, -1463
463 ; RV32M-NEXT: andi a3, a3, 2047
464 ; RV32M-NEXT: sltiu a3, a3, 293
465 ; RV32M-NEXT: addi a2, a2, -1
466 ; RV32M-NEXT: addi a3, a3, -1
467 ; RV32M-NEXT: addi a1, a1, -1
468 ; RV32M-NEXT: slli a4, a1, 21
469 ; RV32M-NEXT: srli a4, a4, 31
470 ; RV32M-NEXT: sb a4, 4(a0)
471 ; RV32M-NEXT: andi a2, a2, 2047
472 ; RV32M-NEXT: andi a3, a3, 2047
473 ; RV32M-NEXT: slli a3, a3, 11
474 ; RV32M-NEXT: or a2, a2, a3
475 ; RV32M-NEXT: slli a1, a1, 22
476 ; RV32M-NEXT: or a1, a2, a1
477 ; RV32M-NEXT: sw a1, 0(a0)
480 ; RV64M-LABEL: test_urem_vec:
482 ; RV64M-NEXT: lbu a1, 4(a0)
483 ; RV64M-NEXT: lwu a2, 0(a0)
484 ; RV64M-NEXT: slli a1, a1, 32
485 ; RV64M-NEXT: or a1, a2, a1
486 ; RV64M-NEXT: srli a2, a1, 22
487 ; RV64M-NEXT: srli a3, a1, 11
488 ; RV64M-NEXT: andi a1, a1, 2047
489 ; RV64M-NEXT: li a4, 683
490 ; RV64M-NEXT: mul a1, a1, a4
491 ; RV64M-NEXT: slli a4, a1, 10
492 ; RV64M-NEXT: slli a1, a1, 53
493 ; RV64M-NEXT: srli a1, a1, 54
494 ; RV64M-NEXT: or a1, a1, a4
495 ; RV64M-NEXT: andi a1, a1, 2047
496 ; RV64M-NEXT: sltiu a1, a1, 342
497 ; RV64M-NEXT: li a4, 1463
498 ; RV64M-NEXT: mulw a3, a3, a4
499 ; RV64M-NEXT: addiw a3, a3, -1463
500 ; RV64M-NEXT: andi a3, a3, 2047
501 ; RV64M-NEXT: sltiu a3, a3, 293
502 ; RV64M-NEXT: li a4, 819
503 ; RV64M-NEXT: mulw a2, a2, a4
504 ; RV64M-NEXT: addiw a2, a2, -1638
505 ; RV64M-NEXT: andi a2, a2, 2047
506 ; RV64M-NEXT: sltiu a2, a2, 2
507 ; RV64M-NEXT: addiw a1, a1, -1
508 ; RV64M-NEXT: addi a2, a2, -1
509 ; RV64M-NEXT: addiw a3, a3, -1
510 ; RV64M-NEXT: andi a1, a1, 2047
511 ; RV64M-NEXT: andi a3, a3, 2047
512 ; RV64M-NEXT: slli a3, a3, 11
513 ; RV64M-NEXT: or a1, a1, a3
514 ; RV64M-NEXT: slli a2, a2, 22
515 ; RV64M-NEXT: or a1, a1, a2
516 ; RV64M-NEXT: sw a1, 0(a0)
517 ; RV64M-NEXT: slli a1, a1, 31
518 ; RV64M-NEXT: srli a1, a1, 63
519 ; RV64M-NEXT: sb a1, 4(a0)
522 ; RV32MV-LABEL: test_urem_vec:
524 ; RV32MV-NEXT: addi sp, sp, -16
525 ; RV32MV-NEXT: lw a1, 0(a0)
526 ; RV32MV-NEXT: andi a2, a1, 2047
527 ; RV32MV-NEXT: sh a2, 8(sp)
528 ; RV32MV-NEXT: slli a2, a1, 10
529 ; RV32MV-NEXT: srli a2, a2, 21
530 ; RV32MV-NEXT: sh a2, 10(sp)
531 ; RV32MV-NEXT: lb a2, 4(a0)
532 ; RV32MV-NEXT: slli a2, a2, 10
533 ; RV32MV-NEXT: srli a1, a1, 22
534 ; RV32MV-NEXT: or a1, a1, a2
535 ; RV32MV-NEXT: andi a1, a1, 2047
536 ; RV32MV-NEXT: sh a1, 12(sp)
537 ; RV32MV-NEXT: addi a1, sp, 8
538 ; RV32MV-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
539 ; RV32MV-NEXT: vle16.v v8, (a1)
540 ; RV32MV-NEXT: vmv.v.i v9, 10
541 ; RV32MV-NEXT: li a1, 9
542 ; RV32MV-NEXT: vsetvli zero, zero, e16, mf2, tu, mu
543 ; RV32MV-NEXT: vmv.s.x v9, a1
544 ; RV32MV-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
545 ; RV32MV-NEXT: lui a1, %hi(.LCPI4_0)
546 ; RV32MV-NEXT: addi a1, a1, %lo(.LCPI4_0)
547 ; RV32MV-NEXT: vle16.v v10, (a1)
548 ; RV32MV-NEXT: vid.v v11
549 ; RV32MV-NEXT: vsub.vv v8, v8, v11
550 ; RV32MV-NEXT: vmul.vv v8, v8, v10
551 ; RV32MV-NEXT: vadd.vv v10, v8, v8
552 ; RV32MV-NEXT: vsll.vv v9, v10, v9
553 ; RV32MV-NEXT: vmv.v.i v10, 0
554 ; RV32MV-NEXT: li a1, 1
555 ; RV32MV-NEXT: vsetvli zero, zero, e16, mf2, tu, mu
556 ; RV32MV-NEXT: vmv1r.v v11, v10
557 ; RV32MV-NEXT: vmv.s.x v11, a1
558 ; RV32MV-NEXT: li a1, 2047
559 ; RV32MV-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
560 ; RV32MV-NEXT: vand.vx v8, v8, a1
561 ; RV32MV-NEXT: lui a2, %hi(.LCPI4_1)
562 ; RV32MV-NEXT: addi a2, a2, %lo(.LCPI4_1)
563 ; RV32MV-NEXT: vle16.v v12, (a2)
564 ; RV32MV-NEXT: vsrl.vv v8, v8, v11
565 ; RV32MV-NEXT: vor.vv v8, v8, v9
566 ; RV32MV-NEXT: vand.vx v8, v8, a1
567 ; RV32MV-NEXT: vmsltu.vv v0, v12, v8
568 ; RV32MV-NEXT: vmerge.vim v8, v10, -1, v0
569 ; RV32MV-NEXT: vsetivli zero, 1, e16, mf2, ta, mu
570 ; RV32MV-NEXT: vslidedown.vi v9, v8, 2
571 ; RV32MV-NEXT: vmv.x.s a1, v9
572 ; RV32MV-NEXT: slli a2, a1, 21
573 ; RV32MV-NEXT: srli a2, a2, 31
574 ; RV32MV-NEXT: sb a2, 4(a0)
575 ; RV32MV-NEXT: vmv.x.s a2, v8
576 ; RV32MV-NEXT: andi a2, a2, 2047
577 ; RV32MV-NEXT: vslidedown.vi v8, v8, 1
578 ; RV32MV-NEXT: vmv.x.s a3, v8
579 ; RV32MV-NEXT: andi a3, a3, 2047
580 ; RV32MV-NEXT: slli a3, a3, 11
581 ; RV32MV-NEXT: or a2, a2, a3
582 ; RV32MV-NEXT: slli a1, a1, 22
583 ; RV32MV-NEXT: or a1, a2, a1
584 ; RV32MV-NEXT: sw a1, 0(a0)
585 ; RV32MV-NEXT: addi sp, sp, 16
588 ; RV64MV-LABEL: test_urem_vec:
590 ; RV64MV-NEXT: addi sp, sp, -16
591 ; RV64MV-NEXT: lbu a1, 4(a0)
592 ; RV64MV-NEXT: lwu a2, 0(a0)
593 ; RV64MV-NEXT: slli a1, a1, 32
594 ; RV64MV-NEXT: or a1, a2, a1
595 ; RV64MV-NEXT: srli a2, a1, 22
596 ; RV64MV-NEXT: sh a2, 12(sp)
597 ; RV64MV-NEXT: andi a2, a1, 2047
598 ; RV64MV-NEXT: sh a2, 8(sp)
599 ; RV64MV-NEXT: slli a1, a1, 42
600 ; RV64MV-NEXT: srli a1, a1, 53
601 ; RV64MV-NEXT: sh a1, 10(sp)
602 ; RV64MV-NEXT: addi a1, sp, 8
603 ; RV64MV-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
604 ; RV64MV-NEXT: vle16.v v8, (a1)
605 ; RV64MV-NEXT: vmv.v.i v9, 10
606 ; RV64MV-NEXT: li a1, 9
607 ; RV64MV-NEXT: vsetvli zero, zero, e16, mf2, tu, mu
608 ; RV64MV-NEXT: vmv.s.x v9, a1
609 ; RV64MV-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
610 ; RV64MV-NEXT: lui a1, %hi(.LCPI4_0)
611 ; RV64MV-NEXT: addi a1, a1, %lo(.LCPI4_0)
612 ; RV64MV-NEXT: vle16.v v10, (a1)
613 ; RV64MV-NEXT: vid.v v11
614 ; RV64MV-NEXT: vsub.vv v8, v8, v11
615 ; RV64MV-NEXT: vmul.vv v8, v8, v10
616 ; RV64MV-NEXT: vadd.vv v10, v8, v8
617 ; RV64MV-NEXT: vsll.vv v9, v10, v9
618 ; RV64MV-NEXT: vmv.v.i v10, 0
619 ; RV64MV-NEXT: li a1, 1
620 ; RV64MV-NEXT: vsetvli zero, zero, e16, mf2, tu, mu
621 ; RV64MV-NEXT: vmv1r.v v11, v10
622 ; RV64MV-NEXT: vmv.s.x v11, a1
623 ; RV64MV-NEXT: li a1, 2047
624 ; RV64MV-NEXT: vsetvli zero, zero, e16, mf2, ta, mu
625 ; RV64MV-NEXT: vand.vx v8, v8, a1
626 ; RV64MV-NEXT: lui a2, %hi(.LCPI4_1)
627 ; RV64MV-NEXT: addi a2, a2, %lo(.LCPI4_1)
628 ; RV64MV-NEXT: vle16.v v12, (a2)
629 ; RV64MV-NEXT: vsrl.vv v8, v8, v11
630 ; RV64MV-NEXT: vor.vv v8, v8, v9
631 ; RV64MV-NEXT: vand.vx v8, v8, a1
632 ; RV64MV-NEXT: vmsltu.vv v0, v12, v8
633 ; RV64MV-NEXT: vmerge.vim v8, v10, -1, v0
634 ; RV64MV-NEXT: vmv.x.s a1, v8
635 ; RV64MV-NEXT: andi a1, a1, 2047
636 ; RV64MV-NEXT: vsetivli zero, 1, e16, mf2, ta, mu
637 ; RV64MV-NEXT: vslidedown.vi v9, v8, 1
638 ; RV64MV-NEXT: vmv.x.s a2, v9
639 ; RV64MV-NEXT: andi a2, a2, 2047
640 ; RV64MV-NEXT: slli a2, a2, 11
641 ; RV64MV-NEXT: or a1, a1, a2
642 ; RV64MV-NEXT: vslidedown.vi v8, v8, 2
643 ; RV64MV-NEXT: vmv.x.s a2, v8
644 ; RV64MV-NEXT: slli a2, a2, 22
645 ; RV64MV-NEXT: or a1, a1, a2
646 ; RV64MV-NEXT: sw a1, 0(a0)
647 ; RV64MV-NEXT: slli a1, a1, 31
648 ; RV64MV-NEXT: srli a1, a1, 63
649 ; RV64MV-NEXT: sb a1, 4(a0)
650 ; RV64MV-NEXT: addi sp, sp, 16
652 %ld = load <3 x i11>, <3 x i11>* %X
653 %urem = urem <3 x i11> %ld, <i11 6, i11 7, i11 -5>
654 %cmp = icmp ne <3 x i11> %urem, <i11 0, i11 1, i11 2>
655 %ext = sext <3 x i1> %cmp to <3 x i11>
656 store <3 x i11> %ext, <3 x i11>* %X