1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 define zeroext i1 @smuloi64(i64 %v1, i64 %v2, ptr %res) {
6 ; LA32-LABEL: smuloi64:
8 ; LA32-NEXT: mulh.wu $a5, $a0, $a2
9 ; LA32-NEXT: mul.w $a6, $a1, $a2
10 ; LA32-NEXT: add.w $a5, $a6, $a5
11 ; LA32-NEXT: sltu $a6, $a5, $a6
12 ; LA32-NEXT: mulh.wu $a7, $a1, $a2
13 ; LA32-NEXT: add.w $a6, $a7, $a6
14 ; LA32-NEXT: mul.w $a7, $a0, $a3
15 ; LA32-NEXT: add.w $a5, $a7, $a5
16 ; LA32-NEXT: sltu $a7, $a5, $a7
17 ; LA32-NEXT: mulh.wu $t0, $a0, $a3
18 ; LA32-NEXT: add.w $a7, $t0, $a7
19 ; LA32-NEXT: add.w $a7, $a6, $a7
20 ; LA32-NEXT: mul.w $t0, $a1, $a3
21 ; LA32-NEXT: add.w $t1, $t0, $a7
22 ; LA32-NEXT: srai.w $t2, $a1, 31
23 ; LA32-NEXT: mul.w $t3, $a2, $t2
24 ; LA32-NEXT: srai.w $t4, $a3, 31
25 ; LA32-NEXT: mul.w $t5, $t4, $a0
26 ; LA32-NEXT: add.w $t6, $t5, $t3
27 ; LA32-NEXT: add.w $t7, $t1, $t6
28 ; LA32-NEXT: sltu $t8, $t7, $t1
29 ; LA32-NEXT: sltu $t0, $t1, $t0
30 ; LA32-NEXT: sltu $a6, $a7, $a6
31 ; LA32-NEXT: mulh.wu $a7, $a1, $a3
32 ; LA32-NEXT: add.w $a6, $a7, $a6
33 ; LA32-NEXT: add.w $a6, $a6, $t0
34 ; LA32-NEXT: mulh.wu $a7, $a2, $t2
35 ; LA32-NEXT: add.w $a7, $a7, $t3
36 ; LA32-NEXT: mul.w $a3, $a3, $t2
37 ; LA32-NEXT: add.w $a3, $a7, $a3
38 ; LA32-NEXT: mul.w $a1, $t4, $a1
39 ; LA32-NEXT: mulh.wu $a7, $t4, $a0
40 ; LA32-NEXT: add.w $a1, $a7, $a1
41 ; LA32-NEXT: add.w $a1, $a1, $t5
42 ; LA32-NEXT: add.w $a1, $a1, $a3
43 ; LA32-NEXT: sltu $a3, $t6, $t5
44 ; LA32-NEXT: add.w $a1, $a1, $a3
45 ; LA32-NEXT: add.w $a1, $a6, $a1
46 ; LA32-NEXT: add.w $a1, $a1, $t8
47 ; LA32-NEXT: srai.w $a3, $a5, 31
48 ; LA32-NEXT: xor $a1, $a1, $a3
49 ; LA32-NEXT: xor $a3, $t7, $a3
50 ; LA32-NEXT: or $a1, $a3, $a1
51 ; LA32-NEXT: sltu $a1, $zero, $a1
52 ; LA32-NEXT: mul.w $a0, $a0, $a2
53 ; LA32-NEXT: st.w $a0, $a4, 0
54 ; LA32-NEXT: st.w $a5, $a4, 4
55 ; LA32-NEXT: move $a0, $a1
58 ; LA64-LABEL: smuloi64:
60 ; LA64-NEXT: mulh.d $a3, $a0, $a1
61 ; LA64-NEXT: mul.d $a1, $a0, $a1
62 ; LA64-NEXT: srai.d $a0, $a1, 63
63 ; LA64-NEXT: xor $a0, $a3, $a0
64 ; LA64-NEXT: sltu $a0, $zero, $a0
65 ; LA64-NEXT: st.d $a1, $a2, 0
67 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
68 %val = extractvalue {i64, i1} %t, 0
69 %obit = extractvalue {i64, i1} %t, 1
70 store i64 %val, ptr %res
74 define zeroext i1 @smuloi128(i128 %v1, i128 %v2, ptr %res) {
75 ; LA32-LABEL: smuloi128:
77 ; LA32-NEXT: addi.w $sp, $sp, -96
78 ; LA32-NEXT: .cfi_def_cfa_offset 96
79 ; LA32-NEXT: st.w $ra, $sp, 92 # 4-byte Folded Spill
80 ; LA32-NEXT: st.w $fp, $sp, 88 # 4-byte Folded Spill
81 ; LA32-NEXT: st.w $s0, $sp, 84 # 4-byte Folded Spill
82 ; LA32-NEXT: st.w $s1, $sp, 80 # 4-byte Folded Spill
83 ; LA32-NEXT: st.w $s2, $sp, 76 # 4-byte Folded Spill
84 ; LA32-NEXT: st.w $s3, $sp, 72 # 4-byte Folded Spill
85 ; LA32-NEXT: st.w $s4, $sp, 68 # 4-byte Folded Spill
86 ; LA32-NEXT: st.w $s5, $sp, 64 # 4-byte Folded Spill
87 ; LA32-NEXT: st.w $s6, $sp, 60 # 4-byte Folded Spill
88 ; LA32-NEXT: st.w $s7, $sp, 56 # 4-byte Folded Spill
89 ; LA32-NEXT: st.w $s8, $sp, 52 # 4-byte Folded Spill
90 ; LA32-NEXT: .cfi_offset 1, -4
91 ; LA32-NEXT: .cfi_offset 22, -8
92 ; LA32-NEXT: .cfi_offset 23, -12
93 ; LA32-NEXT: .cfi_offset 24, -16
94 ; LA32-NEXT: .cfi_offset 25, -20
95 ; LA32-NEXT: .cfi_offset 26, -24
96 ; LA32-NEXT: .cfi_offset 27, -28
97 ; LA32-NEXT: .cfi_offset 28, -32
98 ; LA32-NEXT: .cfi_offset 29, -36
99 ; LA32-NEXT: .cfi_offset 30, -40
100 ; LA32-NEXT: .cfi_offset 31, -44
101 ; LA32-NEXT: st.w $a2, $sp, 48 # 4-byte Folded Spill
102 ; LA32-NEXT: ld.w $t0, $a1, 12
103 ; LA32-NEXT: ld.w $t1, $a1, 8
104 ; LA32-NEXT: ld.w $a5, $a0, 12
105 ; LA32-NEXT: ld.w $a7, $a1, 0
106 ; LA32-NEXT: ld.w $a3, $a0, 0
107 ; LA32-NEXT: ld.w $a6, $a0, 4
108 ; LA32-NEXT: ld.w $a4, $a0, 8
109 ; LA32-NEXT: ld.w $t3, $a1, 4
110 ; LA32-NEXT: mulh.wu $a0, $a3, $a7
111 ; LA32-NEXT: mul.w $a1, $a6, $a7
112 ; LA32-NEXT: add.w $a0, $a1, $a0
113 ; LA32-NEXT: sltu $a1, $a0, $a1
114 ; LA32-NEXT: mulh.wu $t2, $a6, $a7
115 ; LA32-NEXT: add.w $a1, $t2, $a1
116 ; LA32-NEXT: mul.w $t2, $a3, $t3
117 ; LA32-NEXT: add.w $a0, $t2, $a0
118 ; LA32-NEXT: st.w $a0, $sp, 44 # 4-byte Folded Spill
119 ; LA32-NEXT: sltu $t2, $a0, $t2
120 ; LA32-NEXT: mulh.wu $t4, $a3, $t3
121 ; LA32-NEXT: add.w $t2, $t4, $t2
122 ; LA32-NEXT: add.w $t2, $a1, $t2
123 ; LA32-NEXT: mul.w $t4, $a6, $t3
124 ; LA32-NEXT: add.w $t5, $t4, $t2
125 ; LA32-NEXT: sltu $t4, $t5, $t4
126 ; LA32-NEXT: sltu $a1, $t2, $a1
127 ; LA32-NEXT: mulh.wu $t2, $a6, $t3
128 ; LA32-NEXT: add.w $a1, $t2, $a1
129 ; LA32-NEXT: add.w $a1, $a1, $t4
130 ; LA32-NEXT: mulh.wu $t2, $a4, $a7
131 ; LA32-NEXT: mul.w $t4, $a5, $a7
132 ; LA32-NEXT: add.w $t2, $t4, $t2
133 ; LA32-NEXT: mul.w $t6, $a4, $t3
134 ; LA32-NEXT: add.w $t7, $t6, $t2
135 ; LA32-NEXT: add.w $a1, $t7, $a1
136 ; LA32-NEXT: mul.w $t8, $a4, $a7
137 ; LA32-NEXT: add.w $t5, $t8, $t5
138 ; LA32-NEXT: sltu $t8, $t5, $t8
139 ; LA32-NEXT: add.w $a1, $a1, $t8
140 ; LA32-NEXT: sltu $fp, $a1, $t7
141 ; LA32-NEXT: xor $s0, $a1, $t7
142 ; LA32-NEXT: sltui $s0, $s0, 1
143 ; LA32-NEXT: masknez $fp, $fp, $s0
144 ; LA32-NEXT: maskeqz $t8, $t8, $s0
145 ; LA32-NEXT: or $t8, $t8, $fp
146 ; LA32-NEXT: sltu $t2, $t2, $t4
147 ; LA32-NEXT: mulh.wu $t4, $a5, $a7
148 ; LA32-NEXT: add.w $t4, $t4, $t2
149 ; LA32-NEXT: sltu $t2, $t7, $t6
150 ; LA32-NEXT: mulh.wu $t6, $a4, $t3
151 ; LA32-NEXT: add.w $t2, $t6, $t2
152 ; LA32-NEXT: add.w $fp, $t4, $t2
153 ; LA32-NEXT: mul.w $t6, $a5, $t3
154 ; LA32-NEXT: add.w $s0, $t6, $fp
155 ; LA32-NEXT: add.w $s1, $s0, $t8
156 ; LA32-NEXT: mulh.wu $t2, $a3, $t1
157 ; LA32-NEXT: mul.w $t7, $a6, $t1
158 ; LA32-NEXT: add.w $t8, $t7, $t2
159 ; LA32-NEXT: mul.w $s2, $a3, $t0
160 ; LA32-NEXT: add.w $s3, $s2, $t8
161 ; LA32-NEXT: add.w $t2, $s3, $a1
162 ; LA32-NEXT: mul.w $s4, $a3, $t1
163 ; LA32-NEXT: add.w $a0, $s4, $t5
164 ; LA32-NEXT: st.w $a0, $sp, 40 # 4-byte Folded Spill
165 ; LA32-NEXT: sltu $t5, $a0, $s4
166 ; LA32-NEXT: add.w $a0, $t2, $t5
167 ; LA32-NEXT: st.w $a0, $sp, 36 # 4-byte Folded Spill
168 ; LA32-NEXT: sltu $s4, $a0, $s3
169 ; LA32-NEXT: xor $s5, $a0, $s3
170 ; LA32-NEXT: sltui $s5, $s5, 1
171 ; LA32-NEXT: masknez $s4, $s4, $s5
172 ; LA32-NEXT: maskeqz $t5, $t5, $s5
173 ; LA32-NEXT: or $t5, $t5, $s4
174 ; LA32-NEXT: sltu $t7, $t8, $t7
175 ; LA32-NEXT: mulh.wu $t8, $a6, $t1
176 ; LA32-NEXT: add.w $s4, $t8, $t7
177 ; LA32-NEXT: sltu $t7, $s3, $s2
178 ; LA32-NEXT: mulh.wu $t8, $a3, $t0
179 ; LA32-NEXT: add.w $t7, $t8, $t7
180 ; LA32-NEXT: add.w $s2, $s4, $t7
181 ; LA32-NEXT: mul.w $s3, $a6, $t0
182 ; LA32-NEXT: add.w $s6, $s3, $s2
183 ; LA32-NEXT: add.w $s7, $s6, $t5
184 ; LA32-NEXT: add.w $s5, $s1, $s7
185 ; LA32-NEXT: mul.w $s8, $a4, $t1
186 ; LA32-NEXT: add.w $ra, $s8, $s5
187 ; LA32-NEXT: srai.w $t8, $a5, 31
188 ; LA32-NEXT: mul.w $t7, $a7, $t8
189 ; LA32-NEXT: st.w $a7, $sp, 28 # 4-byte Folded Spill
190 ; LA32-NEXT: srai.w $t5, $t0, 31
191 ; LA32-NEXT: sltu $s5, $s5, $s1
192 ; LA32-NEXT: sltu $s1, $s1, $s0
193 ; LA32-NEXT: sltu $s0, $s0, $t6
194 ; LA32-NEXT: mul.w $t2, $a3, $t5
195 ; LA32-NEXT: st.w $a3, $sp, 24 # 4-byte Folded Spill
196 ; LA32-NEXT: sltu $t4, $fp, $t4
197 ; LA32-NEXT: mulh.wu $fp, $a5, $t3
198 ; LA32-NEXT: st.w $a5, $sp, 0 # 4-byte Folded Spill
199 ; LA32-NEXT: add.w $t4, $fp, $t4
200 ; LA32-NEXT: add.w $fp, $t2, $t7
201 ; LA32-NEXT: add.w $s0, $t4, $s0
202 ; LA32-NEXT: add.w $a0, $ra, $fp
203 ; LA32-NEXT: st.w $a0, $sp, 32 # 4-byte Folded Spill
204 ; LA32-NEXT: add.w $a2, $s0, $s1
205 ; LA32-NEXT: sltu $s0, $a0, $ra
206 ; LA32-NEXT: sltu $s1, $s7, $s6
207 ; LA32-NEXT: sltu $s3, $s6, $s3
208 ; LA32-NEXT: sltu $s2, $s2, $s4
209 ; LA32-NEXT: move $s6, $a6
210 ; LA32-NEXT: st.w $a6, $sp, 16 # 4-byte Folded Spill
211 ; LA32-NEXT: mulh.wu $s4, $a6, $t0
212 ; LA32-NEXT: add.w $s2, $s4, $s2
213 ; LA32-NEXT: add.w $s2, $s2, $s3
214 ; LA32-NEXT: add.w $s1, $s2, $s1
215 ; LA32-NEXT: add.w $s1, $a2, $s1
216 ; LA32-NEXT: add.w $s7, $s1, $s5
217 ; LA32-NEXT: move $a0, $a4
218 ; LA32-NEXT: st.w $a4, $sp, 4 # 4-byte Folded Spill
219 ; LA32-NEXT: mulh.wu $s1, $a4, $t1
220 ; LA32-NEXT: mul.w $a5, $a5, $t1
221 ; LA32-NEXT: add.w $a4, $a5, $s1
222 ; LA32-NEXT: mul.w $a6, $a0, $t0
223 ; LA32-NEXT: add.w $a1, $a6, $a4
224 ; LA32-NEXT: sltu $ra, $ra, $s8
225 ; LA32-NEXT: add.w $s1, $a1, $s7
226 ; LA32-NEXT: add.w $s8, $s1, $ra
227 ; LA32-NEXT: move $a0, $t2
228 ; LA32-NEXT: st.w $t2, $sp, 8 # 4-byte Folded Spill
229 ; LA32-NEXT: sltu $t6, $fp, $t2
230 ; LA32-NEXT: mulh.wu $t2, $a7, $t8
231 ; LA32-NEXT: mul.w $s4, $t3, $t8
232 ; LA32-NEXT: add.w $a7, $s4, $t2
233 ; LA32-NEXT: st.w $a7, $sp, 12 # 4-byte Folded Spill
234 ; LA32-NEXT: add.w $s3, $t7, $a7
235 ; LA32-NEXT: mulh.wu $a7, $a3, $t5
236 ; LA32-NEXT: add.w $t4, $a7, $a0
237 ; LA32-NEXT: mul.w $s2, $s6, $t5
238 ; LA32-NEXT: add.w $s1, $t4, $s2
239 ; LA32-NEXT: add.w $fp, $s1, $s3
240 ; LA32-NEXT: add.w $a0, $fp, $t6
241 ; LA32-NEXT: add.w $fp, $s8, $a0
242 ; LA32-NEXT: add.w $a3, $fp, $s0
243 ; LA32-NEXT: st.w $a3, $sp, 20 # 4-byte Folded Spill
244 ; LA32-NEXT: xor $fp, $a3, $s8
245 ; LA32-NEXT: sltui $fp, $fp, 1
246 ; LA32-NEXT: sltu $s6, $a3, $s8
247 ; LA32-NEXT: masknez $s6, $s6, $fp
248 ; LA32-NEXT: maskeqz $fp, $s0, $fp
249 ; LA32-NEXT: or $s6, $fp, $s6
250 ; LA32-NEXT: sltu $fp, $s7, $a2
251 ; LA32-NEXT: xor $a2, $s7, $a2
252 ; LA32-NEXT: sltui $a2, $a2, 1
253 ; LA32-NEXT: masknez $fp, $fp, $a2
254 ; LA32-NEXT: maskeqz $a2, $s5, $a2
255 ; LA32-NEXT: or $s0, $a2, $fp
256 ; LA32-NEXT: sltu $a2, $a4, $a5
257 ; LA32-NEXT: ld.w $a5, $sp, 0 # 4-byte Folded Reload
258 ; LA32-NEXT: mulh.wu $a3, $a5, $t1
259 ; LA32-NEXT: add.w $a2, $a3, $a2
260 ; LA32-NEXT: sltu $a3, $a1, $a6
261 ; LA32-NEXT: ld.w $fp, $sp, 4 # 4-byte Folded Reload
262 ; LA32-NEXT: mulh.wu $a4, $fp, $t0
263 ; LA32-NEXT: add.w $a3, $a4, $a3
264 ; LA32-NEXT: sltu $a4, $s8, $a1
265 ; LA32-NEXT: xor $a1, $s8, $a1
266 ; LA32-NEXT: sltui $a1, $a1, 1
267 ; LA32-NEXT: masknez $a4, $a4, $a1
268 ; LA32-NEXT: maskeqz $a1, $ra, $a1
269 ; LA32-NEXT: or $a1, $a1, $a4
270 ; LA32-NEXT: sltu $a4, $a0, $s1
271 ; LA32-NEXT: xor $a0, $a0, $s1
272 ; LA32-NEXT: sltui $a0, $a0, 1
273 ; LA32-NEXT: masknez $a4, $a4, $a0
274 ; LA32-NEXT: maskeqz $a0, $t6, $a0
275 ; LA32-NEXT: or $s5, $a0, $a4
276 ; LA32-NEXT: sltu $a0, $s3, $t7
277 ; LA32-NEXT: add.w $a0, $t2, $a0
278 ; LA32-NEXT: ld.w $t2, $sp, 8 # 4-byte Folded Reload
279 ; LA32-NEXT: sltu $a4, $t4, $t2
280 ; LA32-NEXT: add.w $s7, $a7, $a4
281 ; LA32-NEXT: add.w $a3, $a2, $a3
282 ; LA32-NEXT: sltu $a2, $a3, $a2
283 ; LA32-NEXT: mulh.wu $a4, $a5, $t0
284 ; LA32-NEXT: add.w $a2, $a4, $a2
285 ; LA32-NEXT: mul.w $a4, $a5, $t0
286 ; LA32-NEXT: move $a6, $a5
287 ; LA32-NEXT: add.w $a3, $a4, $a3
288 ; LA32-NEXT: sltu $a4, $a3, $a4
289 ; LA32-NEXT: add.w $a2, $a2, $a4
290 ; LA32-NEXT: add.w $a4, $a3, $s0
291 ; LA32-NEXT: sltu $a3, $a4, $a3
292 ; LA32-NEXT: add.w $a2, $a2, $a3
293 ; LA32-NEXT: add.w $s8, $a4, $a1
294 ; LA32-NEXT: sltu $a1, $s8, $a4
295 ; LA32-NEXT: add.w $ra, $a2, $a1
296 ; LA32-NEXT: ld.w $a1, $sp, 12 # 4-byte Folded Reload
297 ; LA32-NEXT: sltu $a1, $a1, $s4
298 ; LA32-NEXT: mulh.wu $a2, $t3, $t8
299 ; LA32-NEXT: add.w $a1, $a2, $a1
300 ; LA32-NEXT: add.w $a0, $a1, $a0
301 ; LA32-NEXT: sltu $a1, $a0, $a1
302 ; LA32-NEXT: add.w $a1, $a2, $a1
303 ; LA32-NEXT: add.w $a0, $s4, $a0
304 ; LA32-NEXT: sltu $a2, $a0, $s4
305 ; LA32-NEXT: add.w $a1, $a1, $a2
306 ; LA32-NEXT: mul.w $a2, $t8, $t1
307 ; LA32-NEXT: mul.w $a3, $t8, $t0
308 ; LA32-NEXT: mulh.wu $a4, $t8, $t1
309 ; LA32-NEXT: add.w $a3, $a4, $a3
310 ; LA32-NEXT: add.w $a3, $a3, $a2
311 ; LA32-NEXT: add.w $a3, $s3, $a3
312 ; LA32-NEXT: add.w $a2, $t7, $a2
313 ; LA32-NEXT: sltu $a4, $a2, $t7
314 ; LA32-NEXT: add.w $a3, $a3, $a4
315 ; LA32-NEXT: add.w $a1, $a1, $a3
316 ; LA32-NEXT: add.w $a2, $a0, $a2
317 ; LA32-NEXT: sltu $a0, $a2, $a0
318 ; LA32-NEXT: add.w $a0, $a1, $a0
319 ; LA32-NEXT: sltu $a1, $s1, $s2
320 ; LA32-NEXT: ld.w $a3, $sp, 16 # 4-byte Folded Reload
321 ; LA32-NEXT: mulh.wu $a3, $t5, $a3
322 ; LA32-NEXT: add.w $a1, $a3, $a1
323 ; LA32-NEXT: add.w $a1, $s7, $a1
324 ; LA32-NEXT: sltu $a4, $a1, $s7
325 ; LA32-NEXT: add.w $a3, $a3, $a4
326 ; LA32-NEXT: add.w $a1, $s2, $a1
327 ; LA32-NEXT: sltu $a4, $a1, $s2
328 ; LA32-NEXT: add.w $a3, $a3, $a4
329 ; LA32-NEXT: mul.w $a4, $fp, $t5
330 ; LA32-NEXT: mulh.wu $a5, $fp, $t5
331 ; LA32-NEXT: mul.w $a6, $a6, $t5
332 ; LA32-NEXT: add.w $a5, $a5, $a4
333 ; LA32-NEXT: add.w $a5, $a5, $a6
334 ; LA32-NEXT: add.w $a5, $a5, $s1
335 ; LA32-NEXT: add.w $a6, $a4, $t2
336 ; LA32-NEXT: sltu $a4, $a6, $a4
337 ; LA32-NEXT: add.w $a4, $a5, $a4
338 ; LA32-NEXT: add.w $a3, $a3, $a4
339 ; LA32-NEXT: add.w $a4, $a1, $a6
340 ; LA32-NEXT: sltu $a1, $a4, $a1
341 ; LA32-NEXT: add.w $a1, $a3, $a1
342 ; LA32-NEXT: add.w $a0, $a1, $a0
343 ; LA32-NEXT: add.w $a1, $a4, $a2
344 ; LA32-NEXT: sltu $a2, $a1, $a4
345 ; LA32-NEXT: add.w $a0, $a0, $a2
346 ; LA32-NEXT: add.w $a2, $a1, $s5
347 ; LA32-NEXT: sltu $a1, $a2, $a1
348 ; LA32-NEXT: add.w $a0, $a0, $a1
349 ; LA32-NEXT: add.w $a0, $ra, $a0
350 ; LA32-NEXT: add.w $a1, $s8, $a2
351 ; LA32-NEXT: sltu $a2, $a1, $s8
352 ; LA32-NEXT: add.w $a0, $a0, $a2
353 ; LA32-NEXT: add.w $a2, $a1, $s6
354 ; LA32-NEXT: sltu $a1, $a2, $a1
355 ; LA32-NEXT: add.w $a0, $a0, $a1
356 ; LA32-NEXT: ld.w $a4, $sp, 36 # 4-byte Folded Reload
357 ; LA32-NEXT: srai.w $a1, $a4, 31
358 ; LA32-NEXT: xor $a0, $a0, $a1
359 ; LA32-NEXT: ld.w $a3, $sp, 20 # 4-byte Folded Reload
360 ; LA32-NEXT: xor $a3, $a3, $a1
361 ; LA32-NEXT: or $a0, $a3, $a0
362 ; LA32-NEXT: xor $a2, $a2, $a1
363 ; LA32-NEXT: ld.w $a3, $sp, 32 # 4-byte Folded Reload
364 ; LA32-NEXT: xor $a1, $a3, $a1
365 ; LA32-NEXT: or $a1, $a1, $a2
366 ; LA32-NEXT: or $a0, $a1, $a0
367 ; LA32-NEXT: ld.w $a1, $sp, 28 # 4-byte Folded Reload
368 ; LA32-NEXT: ld.w $a2, $sp, 24 # 4-byte Folded Reload
369 ; LA32-NEXT: mul.w $a1, $a2, $a1
370 ; LA32-NEXT: ld.w $a2, $sp, 48 # 4-byte Folded Reload
371 ; LA32-NEXT: st.w $a1, $a2, 0
372 ; LA32-NEXT: ld.w $a1, $sp, 44 # 4-byte Folded Reload
373 ; LA32-NEXT: st.w $a1, $a2, 4
374 ; LA32-NEXT: ld.w $a1, $sp, 40 # 4-byte Folded Reload
375 ; LA32-NEXT: st.w $a1, $a2, 8
376 ; LA32-NEXT: sltu $a0, $zero, $a0
377 ; LA32-NEXT: st.w $a4, $a2, 12
378 ; LA32-NEXT: ld.w $s8, $sp, 52 # 4-byte Folded Reload
379 ; LA32-NEXT: ld.w $s7, $sp, 56 # 4-byte Folded Reload
380 ; LA32-NEXT: ld.w $s6, $sp, 60 # 4-byte Folded Reload
381 ; LA32-NEXT: ld.w $s5, $sp, 64 # 4-byte Folded Reload
382 ; LA32-NEXT: ld.w $s4, $sp, 68 # 4-byte Folded Reload
383 ; LA32-NEXT: ld.w $s3, $sp, 72 # 4-byte Folded Reload
384 ; LA32-NEXT: ld.w $s2, $sp, 76 # 4-byte Folded Reload
385 ; LA32-NEXT: ld.w $s1, $sp, 80 # 4-byte Folded Reload
386 ; LA32-NEXT: ld.w $s0, $sp, 84 # 4-byte Folded Reload
387 ; LA32-NEXT: ld.w $fp, $sp, 88 # 4-byte Folded Reload
388 ; LA32-NEXT: ld.w $ra, $sp, 92 # 4-byte Folded Reload
389 ; LA32-NEXT: addi.w $sp, $sp, 96
392 ; LA64-LABEL: smuloi128:
394 ; LA64-NEXT: mulh.du $a5, $a0, $a2
395 ; LA64-NEXT: mul.d $a6, $a1, $a2
396 ; LA64-NEXT: add.d $a5, $a6, $a5
397 ; LA64-NEXT: sltu $a6, $a5, $a6
398 ; LA64-NEXT: mulh.du $a7, $a1, $a2
399 ; LA64-NEXT: add.d $a6, $a7, $a6
400 ; LA64-NEXT: mul.d $a7, $a0, $a3
401 ; LA64-NEXT: add.d $a5, $a7, $a5
402 ; LA64-NEXT: sltu $a7, $a5, $a7
403 ; LA64-NEXT: mulh.du $t0, $a0, $a3
404 ; LA64-NEXT: add.d $a7, $t0, $a7
405 ; LA64-NEXT: add.d $a7, $a6, $a7
406 ; LA64-NEXT: mul.d $t0, $a1, $a3
407 ; LA64-NEXT: add.d $t1, $t0, $a7
408 ; LA64-NEXT: srai.d $t2, $a1, 63
409 ; LA64-NEXT: mul.d $t3, $a2, $t2
410 ; LA64-NEXT: srai.d $t4, $a3, 63
411 ; LA64-NEXT: mul.d $t5, $t4, $a0
412 ; LA64-NEXT: add.d $t6, $t5, $t3
413 ; LA64-NEXT: add.d $t7, $t1, $t6
414 ; LA64-NEXT: sltu $t8, $t7, $t1
415 ; LA64-NEXT: sltu $t0, $t1, $t0
416 ; LA64-NEXT: sltu $a6, $a7, $a6
417 ; LA64-NEXT: mulh.du $a7, $a1, $a3
418 ; LA64-NEXT: add.d $a6, $a7, $a6
419 ; LA64-NEXT: add.d $a6, $a6, $t0
420 ; LA64-NEXT: mulh.du $a7, $a2, $t2
421 ; LA64-NEXT: add.d $a7, $a7, $t3
422 ; LA64-NEXT: mul.d $a3, $a3, $t2
423 ; LA64-NEXT: add.d $a3, $a7, $a3
424 ; LA64-NEXT: mul.d $a1, $t4, $a1
425 ; LA64-NEXT: mulh.du $a7, $t4, $a0
426 ; LA64-NEXT: add.d $a1, $a7, $a1
427 ; LA64-NEXT: add.d $a1, $a1, $t5
428 ; LA64-NEXT: add.d $a1, $a1, $a3
429 ; LA64-NEXT: sltu $a3, $t6, $t5
430 ; LA64-NEXT: add.d $a1, $a1, $a3
431 ; LA64-NEXT: add.d $a1, $a6, $a1
432 ; LA64-NEXT: add.d $a1, $a1, $t8
433 ; LA64-NEXT: srai.d $a3, $a5, 63
434 ; LA64-NEXT: xor $a1, $a1, $a3
435 ; LA64-NEXT: xor $a3, $t7, $a3
436 ; LA64-NEXT: or $a1, $a3, $a1
437 ; LA64-NEXT: sltu $a1, $zero, $a1
438 ; LA64-NEXT: mul.d $a0, $a0, $a2
439 ; LA64-NEXT: st.d $a0, $a4, 0
440 ; LA64-NEXT: st.d $a5, $a4, 8
441 ; LA64-NEXT: move $a0, $a1
443 %t = call {i128, i1} @llvm.smul.with.overflow.i128(i128 %v1, i128 %v2)
444 %val = extractvalue {i128, i1} %t, 0
445 %obit = extractvalue {i128, i1} %t, 1
446 store i128 %val, ptr %res
450 declare {i64, i1} @llvm.smul.with.overflow.i64(i64, i64) nounwind readnone
451 declare {i128, i1} @llvm.smul.with.overflow.i128(i128, i128) nounwind readnone