xref: /llvm-project/llvm/test/CodeGen/LoongArch/smul-with-overflow.ll (revision e30a4fc3e20bf5d9cc2f5bfcb61b4eb0e686a193)
17414c0dbShev; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
29d4f7f44Swanglei; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
39d4f7f44Swanglei; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
47414c0dbShev
57414c0dbShevdefine zeroext i1 @smuloi64(i64 %v1, i64 %v2, ptr %res) {
67414c0dbShev; LA32-LABEL: smuloi64:
77414c0dbShev; LA32:       # %bb.0:
8a5c90e48Swanglei; LA32-NEXT:    mulh.wu $a5, $a0, $a2
9a5c90e48Swanglei; LA32-NEXT:    mul.w $a6, $a1, $a2
10a5c90e48Swanglei; LA32-NEXT:    add.w $a5, $a6, $a5
11a5c90e48Swanglei; LA32-NEXT:    sltu $a6, $a5, $a6
12a5c90e48Swanglei; LA32-NEXT:    mulh.wu $a7, $a1, $a2
13*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $t0, $a1, 31
14*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t0, $t0, $a2
15*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a7, $a7, $t0
160d9f557bShev; LA32-NEXT:    add.w $a6, $a7, $a6
17*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $a7, $a0, $a3
18*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $t0, $a3, 31
19*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t0, $a0, $t0
20*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a7, $a7, $t0
21*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t0, $a0, $a3
22*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a5, $t0, $a5
23*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t0, $a5, $t0
24*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a7, $a7, $t0
25*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t0, $a6, $a7
26*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t1, $t0, $a6
27*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $a6, $a6, 31
28*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $a7, $a7, 31
29*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a6, $a6, $a7
30*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a6, $a6, $t1
31*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.w $a7, $a1, $a3
32a5c90e48Swanglei; LA32-NEXT:    add.w $a6, $a7, $a6
33*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $a1, $a1, $a3
34*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a3, $a1, $t0
35*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $a1, $a3, $a1
36a5c90e48Swanglei; LA32-NEXT:    add.w $a1, $a6, $a1
37*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $a6, $a5, 31
38*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a1, $a1, $a6
39*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a3, $a3, $a6
40a5c90e48Swanglei; LA32-NEXT:    or $a1, $a3, $a1
41a5c90e48Swanglei; LA32-NEXT:    sltu $a1, $zero, $a1
420d9f557bShev; LA32-NEXT:    mul.w $a0, $a0, $a2
430d9f557bShev; LA32-NEXT:    st.w $a0, $a4, 0
44a5c90e48Swanglei; LA32-NEXT:    st.w $a5, $a4, 4
45a5c90e48Swanglei; LA32-NEXT:    move $a0, $a1
467414c0dbShev; LA32-NEXT:    ret
477414c0dbShev;
487414c0dbShev; LA64-LABEL: smuloi64:
497414c0dbShev; LA64:       # %bb.0:
50a5c90e48Swanglei; LA64-NEXT:    mulh.d $a3, $a0, $a1
51a5c90e48Swanglei; LA64-NEXT:    mul.d $a1, $a0, $a1
52a5c90e48Swanglei; LA64-NEXT:    srai.d $a0, $a1, 63
53a5c90e48Swanglei; LA64-NEXT:    xor $a0, $a3, $a0
547414c0dbShev; LA64-NEXT:    sltu $a0, $zero, $a0
55a5c90e48Swanglei; LA64-NEXT:    st.d $a1, $a2, 0
567414c0dbShev; LA64-NEXT:    ret
577414c0dbShev  %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
587414c0dbShev  %val = extractvalue {i64, i1} %t, 0
597414c0dbShev  %obit = extractvalue {i64, i1} %t, 1
607414c0dbShev  store i64 %val, ptr %res
617414c0dbShev  ret i1 %obit
627414c0dbShev}
637414c0dbShev
647414c0dbShevdefine zeroext i1 @smuloi128(i128 %v1, i128 %v2, ptr %res) {
657414c0dbShev; LA32-LABEL: smuloi128:
667414c0dbShev; LA32:       # %bb.0:
67*e30a4fc3SCraig Topper; LA32-NEXT:    addi.w $sp, $sp, -48
68*e30a4fc3SCraig Topper; LA32-NEXT:    .cfi_def_cfa_offset 48
69*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $ra, $sp, 44 # 4-byte Folded Spill
70*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $fp, $sp, 40 # 4-byte Folded Spill
71*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s0, $sp, 36 # 4-byte Folded Spill
72*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s1, $sp, 32 # 4-byte Folded Spill
73*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s2, $sp, 28 # 4-byte Folded Spill
74*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s3, $sp, 24 # 4-byte Folded Spill
75*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s4, $sp, 20 # 4-byte Folded Spill
76*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s5, $sp, 16 # 4-byte Folded Spill
77*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s6, $sp, 12 # 4-byte Folded Spill
78*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s7, $sp, 8 # 4-byte Folded Spill
79*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $s8, $sp, 4 # 4-byte Folded Spill
807414c0dbShev; LA32-NEXT:    .cfi_offset 1, -4
817414c0dbShev; LA32-NEXT:    .cfi_offset 22, -8
820d9f557bShev; LA32-NEXT:    .cfi_offset 23, -12
830d9f557bShev; LA32-NEXT:    .cfi_offset 24, -16
840d9f557bShev; LA32-NEXT:    .cfi_offset 25, -20
850d9f557bShev; LA32-NEXT:    .cfi_offset 26, -24
860d9f557bShev; LA32-NEXT:    .cfi_offset 27, -28
870d9f557bShev; LA32-NEXT:    .cfi_offset 28, -32
880d9f557bShev; LA32-NEXT:    .cfi_offset 29, -36
890d9f557bShev; LA32-NEXT:    .cfi_offset 30, -40
900d9f557bShev; LA32-NEXT:    .cfi_offset 31, -44
91*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $a5, $a1, 12
92*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $a6, $a1, 8
93*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $t1, $a0, 4
94*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $a3, $a1, 0
95*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $a7, $a0, 8
96*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $t0, $a0, 12
97*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $a4, $a0, 0
98*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $t2, $a1, 4
99*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $a0, $a7, $a3
100*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $a1, $t0, $a3
101a5c90e48Swanglei; LA32-NEXT:    add.w $a0, $a1, $a0
102a5c90e48Swanglei; LA32-NEXT:    sltu $a1, $a0, $a1
103*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t3, $t0, $a3
104*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $t3, $a1
105*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t3, $a7, $t2
106*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t4, $t3, $a0
107*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $a0, $t4, $t3
108*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t3, $a7, $t2
109*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $t3, $a0
110*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $a1, $a0
111*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t5, $t0, $t2
112*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $t5, $t3
113*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $a0, $t0, 31
114*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t7, $a3, $a0
115*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $t6, $t7
116*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $fp, $t8, $t6
117*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t5, $t6, $t5
118*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $a1, $t3, $a1
119*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t3, $t0, $t2
120*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $t3, $a1
121*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $a1, $t5
122*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t3, $a3, $a0
123*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $t3, $t7
124*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t5, $t2, $a0
125*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $t3, $t5
126*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $a1, $t3
127*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $a1, $fp
128*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $a1, $a4, $a3
129*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t5, $t1, $a3
130*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $t5, $a1
131*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t5, $a1, $t5
132*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t6, $t1, $a3
133*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t5, $t6, $t5
134*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t6, $a4, $t2
135*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a1, $t6, $a1
136*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t6, $a1, $t6
137*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t7, $a4, $t2
138*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $t7, $t6
139*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $t5, $t6
140*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t7, $t1, $t2
141*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $fp, $t7, $t6
142*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $fp, $t7
143*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t5, $t6, $t5
144*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t2, $t1, $t2
145*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t2, $t2, $t5
146*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t2, $t2, $t7
147a5c90e48Swanglei; LA32-NEXT:    add.w $t2, $t4, $t2
148*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t5, $a7, $a3
149*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $t5, $fp
150*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t5, $t6, $t5
151*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t2, $t2, $t5
152*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $t2, $t4
153*e30a4fc3SCraig Topper; LA32-NEXT:    xor $t4, $t2, $t4
154*e30a4fc3SCraig Topper; LA32-NEXT:    sltui $t4, $t4, 1
155*e30a4fc3SCraig Topper; LA32-NEXT:    masknez $t7, $t7, $t4
156*e30a4fc3SCraig Topper; LA32-NEXT:    maskeqz $t4, $t5, $t4
157*e30a4fc3SCraig Topper; LA32-NEXT:    or $t4, $t4, $t7
158*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t5, $t8, $t4
159*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t4, $t5, $t8
160*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t4, $t3, $t4
161*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t3, $a4, $a6
162*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t7, $t1, $a6
163*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $t7, $t3
164*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $t3, $t7
165*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t8, $t1, $a6
166a5c90e48Swanglei; LA32-NEXT:    add.w $t7, $t8, $t7
167*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t8, $a4, $a5
168*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $fp, $t8, $t3
169*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t3, $fp, $t8
170*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t8, $a4, $a5
171*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t3, $t8, $t3
172*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $t7, $t3
173*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s0, $t1, $a5
174*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s1, $s0, $t8
175*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $t3, $a5, 31
176*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s2, $t3, $a4
177*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s3, $s1, $s2
178*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s4, $s3, $s1
179*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s0, $s1, $s0
180*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $t8, $t7
181*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t8, $t1, $a5
182*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t7, $t8, $t7
183*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t7, $t7, $s0
184*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t1, $t3, $t1
185*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t8, $t3, $a4
186*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t1, $t8, $t1
187*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t1, $t1, $s2
188*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t1, $t7, $t1
189*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t7, $t1, $s4
190*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t2, $fp, $t2
191*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $t8, $a4, $a6
192*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t1, $t8, $t6
193*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t6, $t1, $t8
194*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t2, $t2, $t6
195*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t8, $t2, $fp
196*e30a4fc3SCraig Topper; LA32-NEXT:    xor $fp, $t2, $fp
197a5c90e48Swanglei; LA32-NEXT:    sltui $fp, $fp, 1
198*e30a4fc3SCraig Topper; LA32-NEXT:    masknez $t8, $t8, $fp
199*e30a4fc3SCraig Topper; LA32-NEXT:    maskeqz $t6, $t6, $fp
200*e30a4fc3SCraig Topper; LA32-NEXT:    or $t6, $t6, $t8
201*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $s3, $t6
202*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t8, $t6, $s3
203*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t7, $t7, $t8
204*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $t4, $t7
205*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $t5, $t6
206*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $fp, $t6, $t5
207*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $t8, $fp
208*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $t5, $a7, $a6
209*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s0, $t0, $a6
210*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s1, $s0, $t5
211*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s2, $a7, $a5
212*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s3, $s2, $s1
213*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s4, $s3, $t8
214*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s5, $a7, $a6
215*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t5, $s5, $t6
216*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s5, $t5, $s5
217*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t6, $s4, $s5
218*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s4, $t6, $s3
219*e30a4fc3SCraig Topper; LA32-NEXT:    xor $s6, $t6, $s3
220*e30a4fc3SCraig Topper; LA32-NEXT:    sltui $s6, $s6, 1
221*e30a4fc3SCraig Topper; LA32-NEXT:    masknez $s4, $s4, $s6
222*e30a4fc3SCraig Topper; LA32-NEXT:    maskeqz $s5, $s5, $s6
223*e30a4fc3SCraig Topper; LA32-NEXT:    or $s4, $s5, $s4
224*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s5, $t8, $t4
225*e30a4fc3SCraig Topper; LA32-NEXT:    xor $t8, $t8, $t4
226*e30a4fc3SCraig Topper; LA32-NEXT:    sltui $t8, $t8, 1
227*e30a4fc3SCraig Topper; LA32-NEXT:    masknez $s5, $s5, $t8
228*e30a4fc3SCraig Topper; LA32-NEXT:    maskeqz $t8, $fp, $t8
229*e30a4fc3SCraig Topper; LA32-NEXT:    or $t8, $t8, $s5
230*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $t4, $t4, 31
231*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $t7, $t7, 31
232*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t7, $t4, $t7
233*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $t7, $t8
234*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $fp, $s1, $s0
235*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $s0, $t0, $a6
236*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $fp, $s0, $fp
237*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $s0, $s3, $s2
238*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $s1, $a7, $a5
239*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s0, $s1, $s0
240*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s0, $fp, $s0
241*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s1, $t0, $a5
242*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s2, $s1, $s0
243*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s3, $a6, $a0
244*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $s5, $t3, $a7
245*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s6, $s5, $s3
246*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s7, $s2, $s6
247*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s8, $s7, $t8
248*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $s4, $s8, $s4
249*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $ra, $s4, $s8
250*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t4, $t7, $t4
251*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t4, $t7, $t4
252*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $t8, $t7
253*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t4, $t4, $t7
254*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t7, $s7, $s2
255*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $t8, $s2, $s1
256*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $fp, $s0, $fp
257*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $s0, $t0, $a5
258*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $fp, $s0, $fp
259*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $t8, $fp, $t8
260*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $a6, $a6, $a0
261*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a6, $a6, $s3
262*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $a0, $a5, $a0
263*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a6, $a0
264*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $a5, $t3, $t0
265*e30a4fc3SCraig Topper; LA32-NEXT:    mulh.wu $a6, $t3, $a7
266*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a5, $a6, $a5
267*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a5, $a5, $s5
268*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a5, $a0
269*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $a5, $s6, $s5
270*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a0, $a5
271*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $t8, $a0
272*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a0, $t7
273*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a0, $t4
274*e30a4fc3SCraig Topper; LA32-NEXT:    sltu $a5, $s8, $s7
275*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a0, $a5
276*e30a4fc3SCraig Topper; LA32-NEXT:    add.w $a0, $a0, $ra
277*e30a4fc3SCraig Topper; LA32-NEXT:    srai.w $a5, $t2, 31
278*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a0, $a0, $a5
279*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a6, $t6, $a5
280*e30a4fc3SCraig Topper; LA32-NEXT:    or $a0, $a6, $a0
281*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a6, $s4, $a5
282*e30a4fc3SCraig Topper; LA32-NEXT:    xor $a5, $t5, $a5
283*e30a4fc3SCraig Topper; LA32-NEXT:    or $a5, $a5, $a6
284*e30a4fc3SCraig Topper; LA32-NEXT:    or $a0, $a5, $a0
2857414c0dbShev; LA32-NEXT:    sltu $a0, $zero, $a0
286*e30a4fc3SCraig Topper; LA32-NEXT:    mul.w $a3, $a4, $a3
287*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $a3, $a2, 0
288*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $a1, $a2, 4
289*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $t1, $a2, 8
290*e30a4fc3SCraig Topper; LA32-NEXT:    st.w $t2, $a2, 12
291*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s8, $sp, 4 # 4-byte Folded Reload
292*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s7, $sp, 8 # 4-byte Folded Reload
293*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s6, $sp, 12 # 4-byte Folded Reload
294*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s5, $sp, 16 # 4-byte Folded Reload
295*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s4, $sp, 20 # 4-byte Folded Reload
296*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s3, $sp, 24 # 4-byte Folded Reload
297*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s2, $sp, 28 # 4-byte Folded Reload
298*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s1, $sp, 32 # 4-byte Folded Reload
299*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $s0, $sp, 36 # 4-byte Folded Reload
300*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $fp, $sp, 40 # 4-byte Folded Reload
301*e30a4fc3SCraig Topper; LA32-NEXT:    ld.w $ra, $sp, 44 # 4-byte Folded Reload
302*e30a4fc3SCraig Topper; LA32-NEXT:    addi.w $sp, $sp, 48
3037414c0dbShev; LA32-NEXT:    ret
3047414c0dbShev;
3057414c0dbShev; LA64-LABEL: smuloi128:
3067414c0dbShev; LA64:       # %bb.0:
307a5c90e48Swanglei; LA64-NEXT:    mulh.du $a5, $a0, $a2
308a5c90e48Swanglei; LA64-NEXT:    mul.d $a6, $a1, $a2
309a5c90e48Swanglei; LA64-NEXT:    add.d $a5, $a6, $a5
310a5c90e48Swanglei; LA64-NEXT:    sltu $a6, $a5, $a6
311a5c90e48Swanglei; LA64-NEXT:    mulh.du $a7, $a1, $a2
312*e30a4fc3SCraig Topper; LA64-NEXT:    srai.d $t0, $a1, 63
313*e30a4fc3SCraig Topper; LA64-NEXT:    mul.d $t0, $t0, $a2
314*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a7, $a7, $t0
3150d9f557bShev; LA64-NEXT:    add.d $a6, $a7, $a6
316*e30a4fc3SCraig Topper; LA64-NEXT:    mulh.du $a7, $a0, $a3
317*e30a4fc3SCraig Topper; LA64-NEXT:    srai.d $t0, $a3, 63
318*e30a4fc3SCraig Topper; LA64-NEXT:    mul.d $t0, $a0, $t0
319*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a7, $a7, $t0
320*e30a4fc3SCraig Topper; LA64-NEXT:    mul.d $t0, $a0, $a3
321*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a5, $t0, $a5
322*e30a4fc3SCraig Topper; LA64-NEXT:    sltu $t0, $a5, $t0
323*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a7, $a7, $t0
324*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $t0, $a6, $a7
325*e30a4fc3SCraig Topper; LA64-NEXT:    sltu $t1, $t0, $a6
326*e30a4fc3SCraig Topper; LA64-NEXT:    srai.d $a6, $a6, 63
327*e30a4fc3SCraig Topper; LA64-NEXT:    srai.d $a7, $a7, 63
328*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a6, $a6, $a7
329*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a6, $a6, $t1
330*e30a4fc3SCraig Topper; LA64-NEXT:    mulh.d $a7, $a1, $a3
331a5c90e48Swanglei; LA64-NEXT:    add.d $a6, $a7, $a6
332*e30a4fc3SCraig Topper; LA64-NEXT:    mul.d $a1, $a1, $a3
333*e30a4fc3SCraig Topper; LA64-NEXT:    add.d $a3, $a1, $t0
334*e30a4fc3SCraig Topper; LA64-NEXT:    sltu $a1, $a3, $a1
335a5c90e48Swanglei; LA64-NEXT:    add.d $a1, $a6, $a1
336*e30a4fc3SCraig Topper; LA64-NEXT:    srai.d $a6, $a5, 63
337*e30a4fc3SCraig Topper; LA64-NEXT:    xor $a1, $a1, $a6
338*e30a4fc3SCraig Topper; LA64-NEXT:    xor $a3, $a3, $a6
339a5c90e48Swanglei; LA64-NEXT:    or $a1, $a3, $a1
340a5c90e48Swanglei; LA64-NEXT:    sltu $a1, $zero, $a1
3410d9f557bShev; LA64-NEXT:    mul.d $a0, $a0, $a2
3420d9f557bShev; LA64-NEXT:    st.d $a0, $a4, 0
343a5c90e48Swanglei; LA64-NEXT:    st.d $a5, $a4, 8
344a5c90e48Swanglei; LA64-NEXT:    move $a0, $a1
3457414c0dbShev; LA64-NEXT:    ret
3467414c0dbShev  %t = call {i128, i1} @llvm.smul.with.overflow.i128(i128 %v1, i128 %v2)
3477414c0dbShev  %val = extractvalue {i128, i1} %t, 0
3487414c0dbShev  %obit = extractvalue {i128, i1} %t, 1
3497414c0dbShev  store i128 %val, ptr %res
3507414c0dbShev  ret i1 %obit
3517414c0dbShev}
3527414c0dbShev
3537414c0dbShevdeclare {i64, i1} @llvm.smul.with.overflow.i64(i64, i64) nounwind readnone
3547414c0dbShevdeclare {i128, i1} @llvm.smul.with.overflow.i128(i128, i128) nounwind readnone
355