1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=riscv32 -mattr=+m | FileCheck %s --check-prefixes=RISCV32
4 define { i128, i8 } @muloti_test(i128 %l, i128 %r) #0 {
5 ; RISCV32-LABEL: muloti_test:
6 ; RISCV32: # %bb.0: # %start
7 ; RISCV32-NEXT: addi sp, sp, -32
8 ; RISCV32-NEXT: sw s0, 28(sp) # 4-byte Folded Spill
9 ; RISCV32-NEXT: sw s1, 24(sp) # 4-byte Folded Spill
10 ; RISCV32-NEXT: sw s2, 20(sp) # 4-byte Folded Spill
11 ; RISCV32-NEXT: sw s3, 16(sp) # 4-byte Folded Spill
12 ; RISCV32-NEXT: sw s4, 12(sp) # 4-byte Folded Spill
13 ; RISCV32-NEXT: lw a3, 12(a1)
14 ; RISCV32-NEXT: lw a7, 12(a2)
15 ; RISCV32-NEXT: lw a6, 8(a1)
16 ; RISCV32-NEXT: lw a4, 0(a2)
17 ; RISCV32-NEXT: lw a5, 0(a1)
18 ; RISCV32-NEXT: lw t2, 4(a1)
19 ; RISCV32-NEXT: lw t0, 8(a2)
20 ; RISCV32-NEXT: lw a2, 4(a2)
21 ; RISCV32-NEXT: mulhu a1, a5, a4
22 ; RISCV32-NEXT: mul t1, t2, a4
23 ; RISCV32-NEXT: add a1, t1, a1
24 ; RISCV32-NEXT: sltu t1, a1, t1
25 ; RISCV32-NEXT: mulhu t3, t2, a4
26 ; RISCV32-NEXT: add t4, t3, t1
27 ; RISCV32-NEXT: mul t1, a5, a2
28 ; RISCV32-NEXT: add a1, t1, a1
29 ; RISCV32-NEXT: sltu t1, a1, t1
30 ; RISCV32-NEXT: mulhu t3, a5, a2
31 ; RISCV32-NEXT: add t1, t3, t1
32 ; RISCV32-NEXT: add t5, t4, t1
33 ; RISCV32-NEXT: mul t6, t2, a2
34 ; RISCV32-NEXT: add s0, t6, t5
35 ; RISCV32-NEXT: mul t1, t0, a5
36 ; RISCV32-NEXT: mul s3, a6, a4
37 ; RISCV32-NEXT: add s4, s3, t1
38 ; RISCV32-NEXT: add t1, s0, s4
39 ; RISCV32-NEXT: sltu t3, t1, s0
40 ; RISCV32-NEXT: sltu s0, s0, t6
41 ; RISCV32-NEXT: sltu t4, t5, t4
42 ; RISCV32-NEXT: mulhu t5, t2, a2
43 ; RISCV32-NEXT: add t4, t5, t4
44 ; RISCV32-NEXT: add s0, t4, s0
45 ; RISCV32-NEXT: mul t4, t2, t0
46 ; RISCV32-NEXT: mul t5, a7, a5
47 ; RISCV32-NEXT: add t4, t5, t4
48 ; RISCV32-NEXT: mulhu s1, t0, a5
49 ; RISCV32-NEXT: add s2, s1, t4
50 ; RISCV32-NEXT: mul t4, a2, a6
51 ; RISCV32-NEXT: mul t5, a3, a4
52 ; RISCV32-NEXT: add t4, t5, t4
53 ; RISCV32-NEXT: mulhu t5, a6, a4
54 ; RISCV32-NEXT: add t6, t5, t4
55 ; RISCV32-NEXT: add t4, t6, s2
56 ; RISCV32-NEXT: sltu s3, s4, s3
57 ; RISCV32-NEXT: add t4, t4, s3
58 ; RISCV32-NEXT: add t4, s0, t4
59 ; RISCV32-NEXT: add t4, t4, t3
60 ; RISCV32-NEXT: beq t4, s0, .LBB0_2
61 ; RISCV32-NEXT: # %bb.1: # %start
62 ; RISCV32-NEXT: sltu t3, t4, s0
63 ; RISCV32-NEXT: .LBB0_2: # %start
64 ; RISCV32-NEXT: sltu s0, s2, s1
65 ; RISCV32-NEXT: snez s1, t2
66 ; RISCV32-NEXT: snez s2, a7
67 ; RISCV32-NEXT: and s1, s2, s1
68 ; RISCV32-NEXT: mulhu s2, a7, a5
69 ; RISCV32-NEXT: snez s2, s2
70 ; RISCV32-NEXT: or s1, s1, s2
71 ; RISCV32-NEXT: mulhu t2, t2, t0
72 ; RISCV32-NEXT: snez t2, t2
73 ; RISCV32-NEXT: or t2, s1, t2
74 ; RISCV32-NEXT: or t2, t2, s0
75 ; RISCV32-NEXT: sltu t5, t6, t5
76 ; RISCV32-NEXT: snez t6, a2
77 ; RISCV32-NEXT: snez s0, a3
78 ; RISCV32-NEXT: and t6, s0, t6
79 ; RISCV32-NEXT: mulhu s0, a3, a4
80 ; RISCV32-NEXT: snez s0, s0
81 ; RISCV32-NEXT: or t6, t6, s0
82 ; RISCV32-NEXT: mulhu a2, a2, a6
83 ; RISCV32-NEXT: snez a2, a2
84 ; RISCV32-NEXT: or a2, t6, a2
85 ; RISCV32-NEXT: or a2, a2, t5
86 ; RISCV32-NEXT: or a7, t0, a7
87 ; RISCV32-NEXT: snez a7, a7
88 ; RISCV32-NEXT: or a3, a6, a3
89 ; RISCV32-NEXT: snez a3, a3
90 ; RISCV32-NEXT: and a3, a3, a7
91 ; RISCV32-NEXT: or a2, a3, a2
92 ; RISCV32-NEXT: or a3, t2, t3
93 ; RISCV32-NEXT: or a2, a2, a3
94 ; RISCV32-NEXT: mul a3, a5, a4
95 ; RISCV32-NEXT: andi a2, a2, 1
96 ; RISCV32-NEXT: sw a3, 0(a0)
97 ; RISCV32-NEXT: sw a1, 4(a0)
98 ; RISCV32-NEXT: sw t1, 8(a0)
99 ; RISCV32-NEXT: sw t4, 12(a0)
100 ; RISCV32-NEXT: sb a2, 16(a0)
101 ; RISCV32-NEXT: lw s0, 28(sp) # 4-byte Folded Reload
102 ; RISCV32-NEXT: lw s1, 24(sp) # 4-byte Folded Reload
103 ; RISCV32-NEXT: lw s2, 20(sp) # 4-byte Folded Reload
104 ; RISCV32-NEXT: lw s3, 16(sp) # 4-byte Folded Reload
105 ; RISCV32-NEXT: lw s4, 12(sp) # 4-byte Folded Reload
106 ; RISCV32-NEXT: addi sp, sp, 32
109 %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %l, i128 %r) #2
110 %1 = extractvalue { i128, i1 } %0, 0
111 %2 = extractvalue { i128, i1 } %0, 1
112 %3 = zext i1 %2 to i8
113 %4 = insertvalue { i128, i8 } undef, i128 %1, 0
114 %5 = insertvalue { i128, i8 } %4, i8 %3, 1
118 ; Function Attrs: nounwind readnone speculatable
119 declare { i128, i1 } @llvm.umul.with.overflow.i128(i128, i128) #1
121 attributes #0 = { nounwind readnone }
122 attributes #1 = { nounwind readnone speculatable }
123 attributes #2 = { nounwind }