1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s --check-prefix=LA64
4 ; RUN: llc --mtriple=loongarch32 -loongarch-check-zero-division < %s \
5 ; RUN: | FileCheck %s --check-prefix=LA32-TRAP
6 ; RUN: llc --mtriple=loongarch64 -loongarch-check-zero-division < %s \
7 ; RUN: | FileCheck %s --check-prefix=LA64-TRAP
9 ;; Test the sdiv/udiv/srem/urem LLVM IR.
11 define i1 @sdiv_i1(i1 %a, i1 %b) {
12 ; LA32-LABEL: sdiv_i1:
13 ; LA32: # %bb.0: # %entry
16 ; LA64-LABEL: sdiv_i1:
17 ; LA64: # %bb.0: # %entry
20 ; LA32-TRAP-LABEL: sdiv_i1:
21 ; LA32-TRAP: # %bb.0: # %entry
24 ; LA64-TRAP-LABEL: sdiv_i1:
25 ; LA64-TRAP: # %bb.0: # %entry
32 define i8 @sdiv_i8(i8 %a, i8 %b) {
33 ; LA32-LABEL: sdiv_i8:
34 ; LA32: # %bb.0: # %entry
35 ; LA32-NEXT: ext.w.b $a1, $a1
36 ; LA32-NEXT: ext.w.b $a0, $a0
37 ; LA32-NEXT: div.w $a0, $a0, $a1
40 ; LA64-LABEL: sdiv_i8:
41 ; LA64: # %bb.0: # %entry
42 ; LA64-NEXT: ext.w.b $a1, $a1
43 ; LA64-NEXT: ext.w.b $a0, $a0
44 ; LA64-NEXT: div.d $a0, $a0, $a1
47 ; LA32-TRAP-LABEL: sdiv_i8:
48 ; LA32-TRAP: # %bb.0: # %entry
49 ; LA32-TRAP-NEXT: ext.w.b $a1, $a1
50 ; LA32-TRAP-NEXT: ext.w.b $a0, $a0
51 ; LA32-TRAP-NEXT: div.w $a0, $a0, $a1
52 ; LA32-TRAP-NEXT: bnez $a1, .LBB1_2
53 ; LA32-TRAP-NEXT: # %bb.1: # %entry
54 ; LA32-TRAP-NEXT: break 7
55 ; LA32-TRAP-NEXT: .LBB1_2: # %entry
58 ; LA64-TRAP-LABEL: sdiv_i8:
59 ; LA64-TRAP: # %bb.0: # %entry
60 ; LA64-TRAP-NEXT: ext.w.b $a1, $a1
61 ; LA64-TRAP-NEXT: ext.w.b $a0, $a0
62 ; LA64-TRAP-NEXT: div.d $a0, $a0, $a1
63 ; LA64-TRAP-NEXT: bnez $a1, .LBB1_2
64 ; LA64-TRAP-NEXT: # %bb.1: # %entry
65 ; LA64-TRAP-NEXT: break 7
66 ; LA64-TRAP-NEXT: .LBB1_2: # %entry
73 define i16 @sdiv_i16(i16 %a, i16 %b) {
74 ; LA32-LABEL: sdiv_i16:
75 ; LA32: # %bb.0: # %entry
76 ; LA32-NEXT: ext.w.h $a1, $a1
77 ; LA32-NEXT: ext.w.h $a0, $a0
78 ; LA32-NEXT: div.w $a0, $a0, $a1
81 ; LA64-LABEL: sdiv_i16:
82 ; LA64: # %bb.0: # %entry
83 ; LA64-NEXT: ext.w.h $a1, $a1
84 ; LA64-NEXT: ext.w.h $a0, $a0
85 ; LA64-NEXT: div.d $a0, $a0, $a1
88 ; LA32-TRAP-LABEL: sdiv_i16:
89 ; LA32-TRAP: # %bb.0: # %entry
90 ; LA32-TRAP-NEXT: ext.w.h $a1, $a1
91 ; LA32-TRAP-NEXT: ext.w.h $a0, $a0
92 ; LA32-TRAP-NEXT: div.w $a0, $a0, $a1
93 ; LA32-TRAP-NEXT: bnez $a1, .LBB2_2
94 ; LA32-TRAP-NEXT: # %bb.1: # %entry
95 ; LA32-TRAP-NEXT: break 7
96 ; LA32-TRAP-NEXT: .LBB2_2: # %entry
99 ; LA64-TRAP-LABEL: sdiv_i16:
100 ; LA64-TRAP: # %bb.0: # %entry
101 ; LA64-TRAP-NEXT: ext.w.h $a1, $a1
102 ; LA64-TRAP-NEXT: ext.w.h $a0, $a0
103 ; LA64-TRAP-NEXT: div.d $a0, $a0, $a1
104 ; LA64-TRAP-NEXT: bnez $a1, .LBB2_2
105 ; LA64-TRAP-NEXT: # %bb.1: # %entry
106 ; LA64-TRAP-NEXT: break 7
107 ; LA64-TRAP-NEXT: .LBB2_2: # %entry
108 ; LA64-TRAP-NEXT: ret
114 define i32 @sdiv_i32(i32 %a, i32 %b) {
115 ; LA32-LABEL: sdiv_i32:
116 ; LA32: # %bb.0: # %entry
117 ; LA32-NEXT: div.w $a0, $a0, $a1
120 ; LA64-LABEL: sdiv_i32:
121 ; LA64: # %bb.0: # %entry
122 ; LA64-NEXT: addi.w $a1, $a1, 0
123 ; LA64-NEXT: addi.w $a0, $a0, 0
124 ; LA64-NEXT: div.d $a0, $a0, $a1
127 ; LA32-TRAP-LABEL: sdiv_i32:
128 ; LA32-TRAP: # %bb.0: # %entry
129 ; LA32-TRAP-NEXT: div.w $a0, $a0, $a1
130 ; LA32-TRAP-NEXT: bnez $a1, .LBB3_2
131 ; LA32-TRAP-NEXT: # %bb.1: # %entry
132 ; LA32-TRAP-NEXT: break 7
133 ; LA32-TRAP-NEXT: .LBB3_2: # %entry
134 ; LA32-TRAP-NEXT: ret
136 ; LA64-TRAP-LABEL: sdiv_i32:
137 ; LA64-TRAP: # %bb.0: # %entry
138 ; LA64-TRAP-NEXT: addi.w $a1, $a1, 0
139 ; LA64-TRAP-NEXT: addi.w $a0, $a0, 0
140 ; LA64-TRAP-NEXT: div.d $a0, $a0, $a1
141 ; LA64-TRAP-NEXT: bnez $a1, .LBB3_2
142 ; LA64-TRAP-NEXT: # %bb.1: # %entry
143 ; LA64-TRAP-NEXT: break 7
144 ; LA64-TRAP-NEXT: .LBB3_2: # %entry
145 ; LA64-TRAP-NEXT: ret
151 define i64 @sdiv_i64(i64 %a, i64 %b) {
152 ; LA32-LABEL: sdiv_i64:
153 ; LA32: # %bb.0: # %entry
154 ; LA32-NEXT: addi.w $sp, $sp, -16
155 ; LA32-NEXT: .cfi_def_cfa_offset 16
156 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
157 ; LA32-NEXT: .cfi_offset 1, -4
158 ; LA32-NEXT: bl %plt(__divdi3)
159 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
160 ; LA32-NEXT: addi.w $sp, $sp, 16
163 ; LA64-LABEL: sdiv_i64:
164 ; LA64: # %bb.0: # %entry
165 ; LA64-NEXT: div.d $a0, $a0, $a1
168 ; LA32-TRAP-LABEL: sdiv_i64:
169 ; LA32-TRAP: # %bb.0: # %entry
170 ; LA32-TRAP-NEXT: addi.w $sp, $sp, -16
171 ; LA32-TRAP-NEXT: .cfi_def_cfa_offset 16
172 ; LA32-TRAP-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
173 ; LA32-TRAP-NEXT: .cfi_offset 1, -4
174 ; LA32-TRAP-NEXT: bl %plt(__divdi3)
175 ; LA32-TRAP-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
176 ; LA32-TRAP-NEXT: addi.w $sp, $sp, 16
177 ; LA32-TRAP-NEXT: ret
179 ; LA64-TRAP-LABEL: sdiv_i64:
180 ; LA64-TRAP: # %bb.0: # %entry
181 ; LA64-TRAP-NEXT: div.d $a0, $a0, $a1
182 ; LA64-TRAP-NEXT: bnez $a1, .LBB4_2
183 ; LA64-TRAP-NEXT: # %bb.1: # %entry
184 ; LA64-TRAP-NEXT: break 7
185 ; LA64-TRAP-NEXT: .LBB4_2: # %entry
186 ; LA64-TRAP-NEXT: ret
192 define i1 @udiv_i1(i1 %a, i1 %b) {
193 ; LA32-LABEL: udiv_i1:
194 ; LA32: # %bb.0: # %entry
197 ; LA64-LABEL: udiv_i1:
198 ; LA64: # %bb.0: # %entry
201 ; LA32-TRAP-LABEL: udiv_i1:
202 ; LA32-TRAP: # %bb.0: # %entry
203 ; LA32-TRAP-NEXT: ret
205 ; LA64-TRAP-LABEL: udiv_i1:
206 ; LA64-TRAP: # %bb.0: # %entry
207 ; LA64-TRAP-NEXT: ret
213 define i8 @udiv_i8(i8 %a, i8 %b) {
214 ; LA32-LABEL: udiv_i8:
215 ; LA32: # %bb.0: # %entry
216 ; LA32-NEXT: andi $a1, $a1, 255
217 ; LA32-NEXT: andi $a0, $a0, 255
218 ; LA32-NEXT: div.wu $a0, $a0, $a1
221 ; LA64-LABEL: udiv_i8:
222 ; LA64: # %bb.0: # %entry
223 ; LA64-NEXT: andi $a1, $a1, 255
224 ; LA64-NEXT: andi $a0, $a0, 255
225 ; LA64-NEXT: div.du $a0, $a0, $a1
228 ; LA32-TRAP-LABEL: udiv_i8:
229 ; LA32-TRAP: # %bb.0: # %entry
230 ; LA32-TRAP-NEXT: andi $a1, $a1, 255
231 ; LA32-TRAP-NEXT: andi $a0, $a0, 255
232 ; LA32-TRAP-NEXT: div.wu $a0, $a0, $a1
233 ; LA32-TRAP-NEXT: bnez $a1, .LBB6_2
234 ; LA32-TRAP-NEXT: # %bb.1: # %entry
235 ; LA32-TRAP-NEXT: break 7
236 ; LA32-TRAP-NEXT: .LBB6_2: # %entry
237 ; LA32-TRAP-NEXT: ret
239 ; LA64-TRAP-LABEL: udiv_i8:
240 ; LA64-TRAP: # %bb.0: # %entry
241 ; LA64-TRAP-NEXT: andi $a1, $a1, 255
242 ; LA64-TRAP-NEXT: andi $a0, $a0, 255
243 ; LA64-TRAP-NEXT: div.du $a0, $a0, $a1
244 ; LA64-TRAP-NEXT: bnez $a1, .LBB6_2
245 ; LA64-TRAP-NEXT: # %bb.1: # %entry
246 ; LA64-TRAP-NEXT: break 7
247 ; LA64-TRAP-NEXT: .LBB6_2: # %entry
248 ; LA64-TRAP-NEXT: ret
254 define i16 @udiv_i16(i16 %a, i16 %b) {
255 ; LA32-LABEL: udiv_i16:
256 ; LA32: # %bb.0: # %entry
257 ; LA32-NEXT: bstrpick.w $a1, $a1, 15, 0
258 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
259 ; LA32-NEXT: div.wu $a0, $a0, $a1
262 ; LA64-LABEL: udiv_i16:
263 ; LA64: # %bb.0: # %entry
264 ; LA64-NEXT: bstrpick.d $a1, $a1, 15, 0
265 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
266 ; LA64-NEXT: div.du $a0, $a0, $a1
269 ; LA32-TRAP-LABEL: udiv_i16:
270 ; LA32-TRAP: # %bb.0: # %entry
271 ; LA32-TRAP-NEXT: bstrpick.w $a1, $a1, 15, 0
272 ; LA32-TRAP-NEXT: bstrpick.w $a0, $a0, 15, 0
273 ; LA32-TRAP-NEXT: div.wu $a0, $a0, $a1
274 ; LA32-TRAP-NEXT: bnez $a1, .LBB7_2
275 ; LA32-TRAP-NEXT: # %bb.1: # %entry
276 ; LA32-TRAP-NEXT: break 7
277 ; LA32-TRAP-NEXT: .LBB7_2: # %entry
278 ; LA32-TRAP-NEXT: ret
280 ; LA64-TRAP-LABEL: udiv_i16:
281 ; LA64-TRAP: # %bb.0: # %entry
282 ; LA64-TRAP-NEXT: bstrpick.d $a1, $a1, 15, 0
283 ; LA64-TRAP-NEXT: bstrpick.d $a0, $a0, 15, 0
284 ; LA64-TRAP-NEXT: div.du $a0, $a0, $a1
285 ; LA64-TRAP-NEXT: bnez $a1, .LBB7_2
286 ; LA64-TRAP-NEXT: # %bb.1: # %entry
287 ; LA64-TRAP-NEXT: break 7
288 ; LA64-TRAP-NEXT: .LBB7_2: # %entry
289 ; LA64-TRAP-NEXT: ret
295 define i32 @udiv_i32(i32 %a, i32 %b) {
296 ; LA32-LABEL: udiv_i32:
297 ; LA32: # %bb.0: # %entry
298 ; LA32-NEXT: div.wu $a0, $a0, $a1
301 ; LA64-LABEL: udiv_i32:
302 ; LA64: # %bb.0: # %entry
303 ; LA64-NEXT: bstrpick.d $a1, $a1, 31, 0
304 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 0
305 ; LA64-NEXT: div.du $a0, $a0, $a1
308 ; LA32-TRAP-LABEL: udiv_i32:
309 ; LA32-TRAP: # %bb.0: # %entry
310 ; LA32-TRAP-NEXT: div.wu $a0, $a0, $a1
311 ; LA32-TRAP-NEXT: bnez $a1, .LBB8_2
312 ; LA32-TRAP-NEXT: # %bb.1: # %entry
313 ; LA32-TRAP-NEXT: break 7
314 ; LA32-TRAP-NEXT: .LBB8_2: # %entry
315 ; LA32-TRAP-NEXT: ret
317 ; LA64-TRAP-LABEL: udiv_i32:
318 ; LA64-TRAP: # %bb.0: # %entry
319 ; LA64-TRAP-NEXT: bstrpick.d $a1, $a1, 31, 0
320 ; LA64-TRAP-NEXT: bstrpick.d $a0, $a0, 31, 0
321 ; LA64-TRAP-NEXT: div.du $a0, $a0, $a1
322 ; LA64-TRAP-NEXT: bnez $a1, .LBB8_2
323 ; LA64-TRAP-NEXT: # %bb.1: # %entry
324 ; LA64-TRAP-NEXT: break 7
325 ; LA64-TRAP-NEXT: .LBB8_2: # %entry
326 ; LA64-TRAP-NEXT: ret
332 define i64 @udiv_i64(i64 %a, i64 %b) {
333 ; LA32-LABEL: udiv_i64:
334 ; LA32: # %bb.0: # %entry
335 ; LA32-NEXT: addi.w $sp, $sp, -16
336 ; LA32-NEXT: .cfi_def_cfa_offset 16
337 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
338 ; LA32-NEXT: .cfi_offset 1, -4
339 ; LA32-NEXT: bl %plt(__udivdi3)
340 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
341 ; LA32-NEXT: addi.w $sp, $sp, 16
344 ; LA64-LABEL: udiv_i64:
345 ; LA64: # %bb.0: # %entry
346 ; LA64-NEXT: div.du $a0, $a0, $a1
349 ; LA32-TRAP-LABEL: udiv_i64:
350 ; LA32-TRAP: # %bb.0: # %entry
351 ; LA32-TRAP-NEXT: addi.w $sp, $sp, -16
352 ; LA32-TRAP-NEXT: .cfi_def_cfa_offset 16
353 ; LA32-TRAP-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
354 ; LA32-TRAP-NEXT: .cfi_offset 1, -4
355 ; LA32-TRAP-NEXT: bl %plt(__udivdi3)
356 ; LA32-TRAP-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
357 ; LA32-TRAP-NEXT: addi.w $sp, $sp, 16
358 ; LA32-TRAP-NEXT: ret
360 ; LA64-TRAP-LABEL: udiv_i64:
361 ; LA64-TRAP: # %bb.0: # %entry
362 ; LA64-TRAP-NEXT: div.du $a0, $a0, $a1
363 ; LA64-TRAP-NEXT: bnez $a1, .LBB9_2
364 ; LA64-TRAP-NEXT: # %bb.1: # %entry
365 ; LA64-TRAP-NEXT: break 7
366 ; LA64-TRAP-NEXT: .LBB9_2: # %entry
367 ; LA64-TRAP-NEXT: ret
373 define i1 @srem_i1(i1 %a, i1 %b) {
374 ; LA32-LABEL: srem_i1:
375 ; LA32: # %bb.0: # %entry
376 ; LA32-NEXT: move $a0, $zero
379 ; LA64-LABEL: srem_i1:
380 ; LA64: # %bb.0: # %entry
381 ; LA64-NEXT: move $a0, $zero
384 ; LA32-TRAP-LABEL: srem_i1:
385 ; LA32-TRAP: # %bb.0: # %entry
386 ; LA32-TRAP-NEXT: move $a0, $zero
387 ; LA32-TRAP-NEXT: ret
389 ; LA64-TRAP-LABEL: srem_i1:
390 ; LA64-TRAP: # %bb.0: # %entry
391 ; LA64-TRAP-NEXT: move $a0, $zero
392 ; LA64-TRAP-NEXT: ret
398 define i8 @srem_i8(i8 %a, i8 %b) {
399 ; LA32-LABEL: srem_i8:
400 ; LA32: # %bb.0: # %entry
401 ; LA32-NEXT: ext.w.b $a1, $a1
402 ; LA32-NEXT: ext.w.b $a0, $a0
403 ; LA32-NEXT: mod.w $a0, $a0, $a1
406 ; LA64-LABEL: srem_i8:
407 ; LA64: # %bb.0: # %entry
408 ; LA64-NEXT: ext.w.b $a1, $a1
409 ; LA64-NEXT: ext.w.b $a0, $a0
410 ; LA64-NEXT: mod.d $a0, $a0, $a1
413 ; LA32-TRAP-LABEL: srem_i8:
414 ; LA32-TRAP: # %bb.0: # %entry
415 ; LA32-TRAP-NEXT: ext.w.b $a1, $a1
416 ; LA32-TRAP-NEXT: ext.w.b $a0, $a0
417 ; LA32-TRAP-NEXT: mod.w $a0, $a0, $a1
418 ; LA32-TRAP-NEXT: bnez $a1, .LBB11_2
419 ; LA32-TRAP-NEXT: # %bb.1: # %entry
420 ; LA32-TRAP-NEXT: break 7
421 ; LA32-TRAP-NEXT: .LBB11_2: # %entry
422 ; LA32-TRAP-NEXT: ret
424 ; LA64-TRAP-LABEL: srem_i8:
425 ; LA64-TRAP: # %bb.0: # %entry
426 ; LA64-TRAP-NEXT: ext.w.b $a1, $a1
427 ; LA64-TRAP-NEXT: ext.w.b $a0, $a0
428 ; LA64-TRAP-NEXT: mod.d $a0, $a0, $a1
429 ; LA64-TRAP-NEXT: bnez $a1, .LBB11_2
430 ; LA64-TRAP-NEXT: # %bb.1: # %entry
431 ; LA64-TRAP-NEXT: break 7
432 ; LA64-TRAP-NEXT: .LBB11_2: # %entry
433 ; LA64-TRAP-NEXT: ret
439 define i16 @srem_i16(i16 %a, i16 %b) {
440 ; LA32-LABEL: srem_i16:
441 ; LA32: # %bb.0: # %entry
442 ; LA32-NEXT: ext.w.h $a1, $a1
443 ; LA32-NEXT: ext.w.h $a0, $a0
444 ; LA32-NEXT: mod.w $a0, $a0, $a1
447 ; LA64-LABEL: srem_i16:
448 ; LA64: # %bb.0: # %entry
449 ; LA64-NEXT: ext.w.h $a1, $a1
450 ; LA64-NEXT: ext.w.h $a0, $a0
451 ; LA64-NEXT: mod.d $a0, $a0, $a1
454 ; LA32-TRAP-LABEL: srem_i16:
455 ; LA32-TRAP: # %bb.0: # %entry
456 ; LA32-TRAP-NEXT: ext.w.h $a1, $a1
457 ; LA32-TRAP-NEXT: ext.w.h $a0, $a0
458 ; LA32-TRAP-NEXT: mod.w $a0, $a0, $a1
459 ; LA32-TRAP-NEXT: bnez $a1, .LBB12_2
460 ; LA32-TRAP-NEXT: # %bb.1: # %entry
461 ; LA32-TRAP-NEXT: break 7
462 ; LA32-TRAP-NEXT: .LBB12_2: # %entry
463 ; LA32-TRAP-NEXT: ret
465 ; LA64-TRAP-LABEL: srem_i16:
466 ; LA64-TRAP: # %bb.0: # %entry
467 ; LA64-TRAP-NEXT: ext.w.h $a1, $a1
468 ; LA64-TRAP-NEXT: ext.w.h $a0, $a0
469 ; LA64-TRAP-NEXT: mod.d $a0, $a0, $a1
470 ; LA64-TRAP-NEXT: bnez $a1, .LBB12_2
471 ; LA64-TRAP-NEXT: # %bb.1: # %entry
472 ; LA64-TRAP-NEXT: break 7
473 ; LA64-TRAP-NEXT: .LBB12_2: # %entry
474 ; LA64-TRAP-NEXT: ret
480 define i32 @srem_i32(i32 %a, i32 %b) {
481 ; LA32-LABEL: srem_i32:
482 ; LA32: # %bb.0: # %entry
483 ; LA32-NEXT: mod.w $a0, $a0, $a1
486 ; LA64-LABEL: srem_i32:
487 ; LA64: # %bb.0: # %entry
488 ; LA64-NEXT: addi.w $a1, $a1, 0
489 ; LA64-NEXT: addi.w $a0, $a0, 0
490 ; LA64-NEXT: mod.d $a0, $a0, $a1
493 ; LA32-TRAP-LABEL: srem_i32:
494 ; LA32-TRAP: # %bb.0: # %entry
495 ; LA32-TRAP-NEXT: mod.w $a0, $a0, $a1
496 ; LA32-TRAP-NEXT: bnez $a1, .LBB13_2
497 ; LA32-TRAP-NEXT: # %bb.1: # %entry
498 ; LA32-TRAP-NEXT: break 7
499 ; LA32-TRAP-NEXT: .LBB13_2: # %entry
500 ; LA32-TRAP-NEXT: ret
502 ; LA64-TRAP-LABEL: srem_i32:
503 ; LA64-TRAP: # %bb.0: # %entry
504 ; LA64-TRAP-NEXT: addi.w $a1, $a1, 0
505 ; LA64-TRAP-NEXT: addi.w $a0, $a0, 0
506 ; LA64-TRAP-NEXT: mod.d $a0, $a0, $a1
507 ; LA64-TRAP-NEXT: bnez $a1, .LBB13_2
508 ; LA64-TRAP-NEXT: # %bb.1: # %entry
509 ; LA64-TRAP-NEXT: break 7
510 ; LA64-TRAP-NEXT: .LBB13_2: # %entry
511 ; LA64-TRAP-NEXT: ret
517 define i64 @srem_i64(i64 %a, i64 %b) {
518 ; LA32-LABEL: srem_i64:
519 ; LA32: # %bb.0: # %entry
520 ; LA32-NEXT: addi.w $sp, $sp, -16
521 ; LA32-NEXT: .cfi_def_cfa_offset 16
522 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
523 ; LA32-NEXT: .cfi_offset 1, -4
524 ; LA32-NEXT: bl %plt(__moddi3)
525 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
526 ; LA32-NEXT: addi.w $sp, $sp, 16
529 ; LA64-LABEL: srem_i64:
530 ; LA64: # %bb.0: # %entry
531 ; LA64-NEXT: mod.d $a0, $a0, $a1
534 ; LA32-TRAP-LABEL: srem_i64:
535 ; LA32-TRAP: # %bb.0: # %entry
536 ; LA32-TRAP-NEXT: addi.w $sp, $sp, -16
537 ; LA32-TRAP-NEXT: .cfi_def_cfa_offset 16
538 ; LA32-TRAP-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
539 ; LA32-TRAP-NEXT: .cfi_offset 1, -4
540 ; LA32-TRAP-NEXT: bl %plt(__moddi3)
541 ; LA32-TRAP-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
542 ; LA32-TRAP-NEXT: addi.w $sp, $sp, 16
543 ; LA32-TRAP-NEXT: ret
545 ; LA64-TRAP-LABEL: srem_i64:
546 ; LA64-TRAP: # %bb.0: # %entry
547 ; LA64-TRAP-NEXT: mod.d $a0, $a0, $a1
548 ; LA64-TRAP-NEXT: bnez $a1, .LBB14_2
549 ; LA64-TRAP-NEXT: # %bb.1: # %entry
550 ; LA64-TRAP-NEXT: break 7
551 ; LA64-TRAP-NEXT: .LBB14_2: # %entry
552 ; LA64-TRAP-NEXT: ret
558 define i1 @urem_i1(i1 %a, i1 %b) {
559 ; LA32-LABEL: urem_i1:
560 ; LA32: # %bb.0: # %entry
561 ; LA32-NEXT: move $a0, $zero
564 ; LA64-LABEL: urem_i1:
565 ; LA64: # %bb.0: # %entry
566 ; LA64-NEXT: move $a0, $zero
569 ; LA32-TRAP-LABEL: urem_i1:
570 ; LA32-TRAP: # %bb.0: # %entry
571 ; LA32-TRAP-NEXT: move $a0, $zero
572 ; LA32-TRAP-NEXT: ret
574 ; LA64-TRAP-LABEL: urem_i1:
575 ; LA64-TRAP: # %bb.0: # %entry
576 ; LA64-TRAP-NEXT: move $a0, $zero
577 ; LA64-TRAP-NEXT: ret
583 define i8 @urem_i8(i8 %a, i8 %b) {
584 ; LA32-LABEL: urem_i8:
585 ; LA32: # %bb.0: # %entry
586 ; LA32-NEXT: andi $a1, $a1, 255
587 ; LA32-NEXT: andi $a0, $a0, 255
588 ; LA32-NEXT: mod.wu $a0, $a0, $a1
591 ; LA64-LABEL: urem_i8:
592 ; LA64: # %bb.0: # %entry
593 ; LA64-NEXT: andi $a1, $a1, 255
594 ; LA64-NEXT: andi $a0, $a0, 255
595 ; LA64-NEXT: mod.du $a0, $a0, $a1
598 ; LA32-TRAP-LABEL: urem_i8:
599 ; LA32-TRAP: # %bb.0: # %entry
600 ; LA32-TRAP-NEXT: andi $a1, $a1, 255
601 ; LA32-TRAP-NEXT: andi $a0, $a0, 255
602 ; LA32-TRAP-NEXT: mod.wu $a0, $a0, $a1
603 ; LA32-TRAP-NEXT: bnez $a1, .LBB16_2
604 ; LA32-TRAP-NEXT: # %bb.1: # %entry
605 ; LA32-TRAP-NEXT: break 7
606 ; LA32-TRAP-NEXT: .LBB16_2: # %entry
607 ; LA32-TRAP-NEXT: ret
609 ; LA64-TRAP-LABEL: urem_i8:
610 ; LA64-TRAP: # %bb.0: # %entry
611 ; LA64-TRAP-NEXT: andi $a1, $a1, 255
612 ; LA64-TRAP-NEXT: andi $a0, $a0, 255
613 ; LA64-TRAP-NEXT: mod.du $a0, $a0, $a1
614 ; LA64-TRAP-NEXT: bnez $a1, .LBB16_2
615 ; LA64-TRAP-NEXT: # %bb.1: # %entry
616 ; LA64-TRAP-NEXT: break 7
617 ; LA64-TRAP-NEXT: .LBB16_2: # %entry
618 ; LA64-TRAP-NEXT: ret
624 define i16 @urem_i16(i16 %a, i16 %b) {
625 ; LA32-LABEL: urem_i16:
626 ; LA32: # %bb.0: # %entry
627 ; LA32-NEXT: bstrpick.w $a1, $a1, 15, 0
628 ; LA32-NEXT: bstrpick.w $a0, $a0, 15, 0
629 ; LA32-NEXT: mod.wu $a0, $a0, $a1
632 ; LA64-LABEL: urem_i16:
633 ; LA64: # %bb.0: # %entry
634 ; LA64-NEXT: bstrpick.d $a1, $a1, 15, 0
635 ; LA64-NEXT: bstrpick.d $a0, $a0, 15, 0
636 ; LA64-NEXT: mod.du $a0, $a0, $a1
639 ; LA32-TRAP-LABEL: urem_i16:
640 ; LA32-TRAP: # %bb.0: # %entry
641 ; LA32-TRAP-NEXT: bstrpick.w $a1, $a1, 15, 0
642 ; LA32-TRAP-NEXT: bstrpick.w $a0, $a0, 15, 0
643 ; LA32-TRAP-NEXT: mod.wu $a0, $a0, $a1
644 ; LA32-TRAP-NEXT: bnez $a1, .LBB17_2
645 ; LA32-TRAP-NEXT: # %bb.1: # %entry
646 ; LA32-TRAP-NEXT: break 7
647 ; LA32-TRAP-NEXT: .LBB17_2: # %entry
648 ; LA32-TRAP-NEXT: ret
650 ; LA64-TRAP-LABEL: urem_i16:
651 ; LA64-TRAP: # %bb.0: # %entry
652 ; LA64-TRAP-NEXT: bstrpick.d $a1, $a1, 15, 0
653 ; LA64-TRAP-NEXT: bstrpick.d $a0, $a0, 15, 0
654 ; LA64-TRAP-NEXT: mod.du $a0, $a0, $a1
655 ; LA64-TRAP-NEXT: bnez $a1, .LBB17_2
656 ; LA64-TRAP-NEXT: # %bb.1: # %entry
657 ; LA64-TRAP-NEXT: break 7
658 ; LA64-TRAP-NEXT: .LBB17_2: # %entry
659 ; LA64-TRAP-NEXT: ret
665 define i32 @urem_i32(i32 %a, i32 %b) {
666 ; LA32-LABEL: urem_i32:
667 ; LA32: # %bb.0: # %entry
668 ; LA32-NEXT: mod.wu $a0, $a0, $a1
671 ; LA64-LABEL: urem_i32:
672 ; LA64: # %bb.0: # %entry
673 ; LA64-NEXT: bstrpick.d $a1, $a1, 31, 0
674 ; LA64-NEXT: bstrpick.d $a0, $a0, 31, 0
675 ; LA64-NEXT: mod.du $a0, $a0, $a1
678 ; LA32-TRAP-LABEL: urem_i32:
679 ; LA32-TRAP: # %bb.0: # %entry
680 ; LA32-TRAP-NEXT: mod.wu $a0, $a0, $a1
681 ; LA32-TRAP-NEXT: bnez $a1, .LBB18_2
682 ; LA32-TRAP-NEXT: # %bb.1: # %entry
683 ; LA32-TRAP-NEXT: break 7
684 ; LA32-TRAP-NEXT: .LBB18_2: # %entry
685 ; LA32-TRAP-NEXT: ret
687 ; LA64-TRAP-LABEL: urem_i32:
688 ; LA64-TRAP: # %bb.0: # %entry
689 ; LA64-TRAP-NEXT: bstrpick.d $a1, $a1, 31, 0
690 ; LA64-TRAP-NEXT: bstrpick.d $a0, $a0, 31, 0
691 ; LA64-TRAP-NEXT: mod.du $a0, $a0, $a1
692 ; LA64-TRAP-NEXT: bnez $a1, .LBB18_2
693 ; LA64-TRAP-NEXT: # %bb.1: # %entry
694 ; LA64-TRAP-NEXT: break 7
695 ; LA64-TRAP-NEXT: .LBB18_2: # %entry
696 ; LA64-TRAP-NEXT: ret
702 define i64 @urem_i64(i64 %a, i64 %b) {
703 ; LA32-LABEL: urem_i64:
704 ; LA32: # %bb.0: # %entry
705 ; LA32-NEXT: addi.w $sp, $sp, -16
706 ; LA32-NEXT: .cfi_def_cfa_offset 16
707 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
708 ; LA32-NEXT: .cfi_offset 1, -4
709 ; LA32-NEXT: bl %plt(__umoddi3)
710 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
711 ; LA32-NEXT: addi.w $sp, $sp, 16
714 ; LA64-LABEL: urem_i64:
715 ; LA64: # %bb.0: # %entry
716 ; LA64-NEXT: mod.du $a0, $a0, $a1
719 ; LA32-TRAP-LABEL: urem_i64:
720 ; LA32-TRAP: # %bb.0: # %entry
721 ; LA32-TRAP-NEXT: addi.w $sp, $sp, -16
722 ; LA32-TRAP-NEXT: .cfi_def_cfa_offset 16
723 ; LA32-TRAP-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
724 ; LA32-TRAP-NEXT: .cfi_offset 1, -4
725 ; LA32-TRAP-NEXT: bl %plt(__umoddi3)
726 ; LA32-TRAP-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
727 ; LA32-TRAP-NEXT: addi.w $sp, $sp, 16
728 ; LA32-TRAP-NEXT: ret
730 ; LA64-TRAP-LABEL: urem_i64:
731 ; LA64-TRAP: # %bb.0: # %entry
732 ; LA64-TRAP-NEXT: mod.du $a0, $a0, $a1
733 ; LA64-TRAP-NEXT: bnez $a1, .LBB19_2
734 ; LA64-TRAP-NEXT: # %bb.1: # %entry
735 ; LA64-TRAP-NEXT: break 7
736 ; LA64-TRAP-NEXT: .LBB19_2: # %entry
737 ; LA64-TRAP-NEXT: ret