1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-enable-atomic-cfg-tidy=0 -disable-post-ra -verify-machineinstrs | FileCheck %s
2 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-enable-atomic-cfg-tidy=0 -fast-isel -fast-isel-abort=1 -disable-post-ra -verify-machineinstrs | FileCheck %s
5 ; Get the actual value of the overflow bit.
7 define zeroext i1 @saddo1.i32(i32 %v1, i32 %v2, i32* %res) {
9 ; CHECK-LABEL: saddo1.i32
10 ; CHECK: adds {{w[0-9]+}}, w0, w1
11 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
12 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
13 %val = extractvalue {i32, i1} %t, 0
14 %obit = extractvalue {i32, i1} %t, 1
15 store i32 %val, i32* %res
19 ; Test the immediate version.
20 define zeroext i1 @saddo2.i32(i32 %v1, i32* %res) {
22 ; CHECK-LABEL: saddo2.i32
23 ; CHECK: adds {{w[0-9]+}}, w0, #4
24 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
25 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 4)
26 %val = extractvalue {i32, i1} %t, 0
27 %obit = extractvalue {i32, i1} %t, 1
28 store i32 %val, i32* %res
32 ; Test negative immediates.
33 define zeroext i1 @saddo3.i32(i32 %v1, i32* %res) {
35 ; CHECK-LABEL: saddo3.i32
36 ; CHECK: subs {{w[0-9]+}}, w0, #4
37 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
38 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 -4)
39 %val = extractvalue {i32, i1} %t, 0
40 %obit = extractvalue {i32, i1} %t, 1
41 store i32 %val, i32* %res
45 ; Test immediates that are too large to be encoded.
46 define zeroext i1 @saddo4.i32(i32 %v1, i32* %res) {
48 ; CHECK-LABEL: saddo4.i32
49 ; CHECK: adds {{w[0-9]+}}, w0, {{w[0-9]+}}
50 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
51 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 16777215)
52 %val = extractvalue {i32, i1} %t, 0
53 %obit = extractvalue {i32, i1} %t, 1
54 store i32 %val, i32* %res
59 define zeroext i1 @saddo5.i32(i32 %v1, i32 %v2, i32* %res) {
61 ; CHECK-LABEL: saddo5.i32
62 ; CHECK: adds {{w[0-9]+}}, w0, w1
63 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
64 %lsl = shl i32 %v2, 16
65 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %lsl)
66 %val = extractvalue {i32, i1} %t, 0
67 %obit = extractvalue {i32, i1} %t, 1
68 store i32 %val, i32* %res
72 define zeroext i1 @saddo1.i64(i64 %v1, i64 %v2, i64* %res) {
74 ; CHECK-LABEL: saddo1.i64
75 ; CHECK: adds {{x[0-9]+}}, x0, x1
76 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
77 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
78 %val = extractvalue {i64, i1} %t, 0
79 %obit = extractvalue {i64, i1} %t, 1
80 store i64 %val, i64* %res
84 define zeroext i1 @saddo2.i64(i64 %v1, i64* %res) {
86 ; CHECK-LABEL: saddo2.i64
87 ; CHECK: adds {{x[0-9]+}}, x0, #4
88 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
89 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 4)
90 %val = extractvalue {i64, i1} %t, 0
91 %obit = extractvalue {i64, i1} %t, 1
92 store i64 %val, i64* %res
96 define zeroext i1 @saddo3.i64(i64 %v1, i64* %res) {
98 ; CHECK-LABEL: saddo3.i64
99 ; CHECK: subs {{x[0-9]+}}, x0, #4
100 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
101 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 -4)
102 %val = extractvalue {i64, i1} %t, 0
103 %obit = extractvalue {i64, i1} %t, 1
104 store i64 %val, i64* %res
108 define zeroext i1 @uaddo.i32(i32 %v1, i32 %v2, i32* %res) {
110 ; CHECK-LABEL: uaddo.i32
111 ; CHECK: adds {{w[0-9]+}}, w0, w1
112 ; CHECK-NEXT: cset {{w[0-9]+}}, hs
113 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
114 %val = extractvalue {i32, i1} %t, 0
115 %obit = extractvalue {i32, i1} %t, 1
116 store i32 %val, i32* %res
120 define zeroext i1 @uaddo.i64(i64 %v1, i64 %v2, i64* %res) {
122 ; CHECK-LABEL: uaddo.i64
123 ; CHECK: adds {{x[0-9]+}}, x0, x1
124 ; CHECK-NEXT: cset {{w[0-9]+}}, hs
125 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
126 %val = extractvalue {i64, i1} %t, 0
127 %obit = extractvalue {i64, i1} %t, 1
128 store i64 %val, i64* %res
132 define zeroext i1 @ssubo1.i32(i32 %v1, i32 %v2, i32* %res) {
134 ; CHECK-LABEL: ssubo1.i32
135 ; CHECK: subs {{w[0-9]+}}, w0, w1
136 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
137 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
138 %val = extractvalue {i32, i1} %t, 0
139 %obit = extractvalue {i32, i1} %t, 1
140 store i32 %val, i32* %res
144 define zeroext i1 @ssubo2.i32(i32 %v1, i32* %res) {
146 ; CHECK-LABEL: ssubo2.i32
147 ; CHECK: adds {{w[0-9]+}}, w0, #4
148 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
149 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 -4)
150 %val = extractvalue {i32, i1} %t, 0
151 %obit = extractvalue {i32, i1} %t, 1
152 store i32 %val, i32* %res
156 define zeroext i1 @ssubo.i64(i64 %v1, i64 %v2, i64* %res) {
158 ; CHECK-LABEL: ssubo.i64
159 ; CHECK: subs {{x[0-9]+}}, x0, x1
160 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
161 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
162 %val = extractvalue {i64, i1} %t, 0
163 %obit = extractvalue {i64, i1} %t, 1
164 store i64 %val, i64* %res
168 define zeroext i1 @usubo.i32(i32 %v1, i32 %v2, i32* %res) {
170 ; CHECK-LABEL: usubo.i32
171 ; CHECK: subs {{w[0-9]+}}, w0, w1
172 ; CHECK-NEXT: cset {{w[0-9]+}}, lo
173 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
174 %val = extractvalue {i32, i1} %t, 0
175 %obit = extractvalue {i32, i1} %t, 1
176 store i32 %val, i32* %res
180 define zeroext i1 @usubo.i64(i64 %v1, i64 %v2, i64* %res) {
182 ; CHECK-LABEL: usubo.i64
183 ; CHECK: subs {{x[0-9]+}}, x0, x1
184 ; CHECK-NEXT: cset {{w[0-9]+}}, lo
185 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
186 %val = extractvalue {i64, i1} %t, 0
187 %obit = extractvalue {i64, i1} %t, 1
188 store i64 %val, i64* %res
192 define zeroext i1 @smulo.i32(i32 %v1, i32 %v2, i32* %res) {
194 ; CHECK-LABEL: smulo.i32
195 ; CHECK: smull x[[MREG:[0-9]+]], w0, w1
196 ; CHECK-NEXT: lsr x[[SREG:[0-9]+]], x[[MREG]], #32
197 ; CHECK-NEXT: cmp w[[SREG]], w[[MREG]], asr #31
198 ; CHECK-NEXT: cset {{w[0-9]+}}, ne
199 %t = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %v1, i32 %v2)
200 %val = extractvalue {i32, i1} %t, 0
201 %obit = extractvalue {i32, i1} %t, 1
202 store i32 %val, i32* %res
206 define zeroext i1 @smulo.i64(i64 %v1, i64 %v2, i64* %res) {
208 ; CHECK-LABEL: smulo.i64
209 ; CHECK: mul [[MREG:x[0-9]+]], x0, x1
210 ; CHECK-NEXT: smulh [[HREG:x[0-9]+]], x0, x1
211 ; CHECK-NEXT: cmp [[HREG]], [[MREG]], asr #63
212 ; CHECK-NEXT: cset {{w[0-9]+}}, ne
213 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
214 %val = extractvalue {i64, i1} %t, 0
215 %obit = extractvalue {i64, i1} %t, 1
216 store i64 %val, i64* %res
220 define zeroext i1 @smulo2.i64(i64 %v1, i64* %res) {
222 ; CHECK-LABEL: smulo2.i64
223 ; CHECK: adds [[MREG:x[0-9]+]], x0, x0
224 ; CHECK-NEXT: cset {{w[0-9]+}}, vs
225 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 2)
226 %val = extractvalue {i64, i1} %t, 0
227 %obit = extractvalue {i64, i1} %t, 1
228 store i64 %val, i64* %res
232 define zeroext i1 @umulo.i32(i32 %v1, i32 %v2, i32* %res) {
234 ; CHECK-LABEL: umulo.i32
235 ; CHECK: umull [[MREG:x[0-9]+]], w0, w1
236 ; CHECK-NEXT: cmp xzr, [[MREG]], lsr #32
237 ; CHECK-NEXT: cset {{w[0-9]+}}, ne
238 %t = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %v1, i32 %v2)
239 %val = extractvalue {i32, i1} %t, 0
240 %obit = extractvalue {i32, i1} %t, 1
241 store i32 %val, i32* %res
245 define zeroext i1 @umulo.i64(i64 %v1, i64 %v2, i64* %res) {
247 ; CHECK-LABEL: umulo.i64
248 ; CHECK: umulh [[MREG:x[0-9]+]], x0, x1
249 ; CHECK-NEXT: cmp xzr, [[MREG]]
250 ; CHECK-NEXT: cset {{w[0-9]+}}, ne
251 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 %v2)
252 %val = extractvalue {i64, i1} %t, 0
253 %obit = extractvalue {i64, i1} %t, 1
254 store i64 %val, i64* %res
258 define zeroext i1 @umulo2.i64(i64 %v1, i64* %res) {
260 ; CHECK-LABEL: umulo2.i64
261 ; CHECK: adds [[MREG:x[0-9]+]], x0, x0
262 ; CHECK-NEXT: cset {{w[0-9]+}}, hs
263 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 2)
264 %val = extractvalue {i64, i1} %t, 0
265 %obit = extractvalue {i64, i1} %t, 1
266 store i64 %val, i64* %res
272 ; Check the use of the overflow bit in combination with a select instruction.
274 define i32 @saddo.select.i32(i32 %v1, i32 %v2) {
276 ; CHECK-LABEL: saddo.select.i32
278 ; CHECK-NEXT: csel w0, w0, w1, vs
279 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
280 %obit = extractvalue {i32, i1} %t, 1
281 %ret = select i1 %obit, i32 %v1, i32 %v2
285 define i1 @saddo.not.i32(i32 %v1, i32 %v2) {
287 ; CHECK-LABEL: saddo.not.i32
289 ; CHECK-NEXT: cset w0, vc
290 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
291 %obit = extractvalue {i32, i1} %t, 1
292 %ret = xor i1 %obit, true
296 define i64 @saddo.select.i64(i64 %v1, i64 %v2) {
298 ; CHECK-LABEL: saddo.select.i64
300 ; CHECK-NEXT: csel x0, x0, x1, vs
301 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
302 %obit = extractvalue {i64, i1} %t, 1
303 %ret = select i1 %obit, i64 %v1, i64 %v2
307 define i1 @saddo.not.i64(i64 %v1, i64 %v2) {
309 ; CHECK-LABEL: saddo.not.i64
311 ; CHECK-NEXT: cset w0, vc
312 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
313 %obit = extractvalue {i64, i1} %t, 1
314 %ret = xor i1 %obit, true
318 define i32 @uaddo.select.i32(i32 %v1, i32 %v2) {
320 ; CHECK-LABEL: uaddo.select.i32
322 ; CHECK-NEXT: csel w0, w0, w1, hs
323 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
324 %obit = extractvalue {i32, i1} %t, 1
325 %ret = select i1 %obit, i32 %v1, i32 %v2
329 define i1 @uaddo.not.i32(i32 %v1, i32 %v2) {
331 ; CHECK-LABEL: uaddo.not.i32
333 ; CHECK-NEXT: cset w0, lo
334 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
335 %obit = extractvalue {i32, i1} %t, 1
336 %ret = xor i1 %obit, true
340 define i64 @uaddo.select.i64(i64 %v1, i64 %v2) {
342 ; CHECK-LABEL: uaddo.select.i64
344 ; CHECK-NEXT: csel x0, x0, x1, hs
345 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
346 %obit = extractvalue {i64, i1} %t, 1
347 %ret = select i1 %obit, i64 %v1, i64 %v2
351 define i1 @uaddo.not.i64(i64 %v1, i64 %v2) {
353 ; CHECK-LABEL: uaddo.not.i64
355 ; CHECK-NEXT: cset w0, lo
356 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
357 %obit = extractvalue {i64, i1} %t, 1
358 %ret = xor i1 %obit, true
362 define i32 @ssubo.select.i32(i32 %v1, i32 %v2) {
364 ; CHECK-LABEL: ssubo.select.i32
366 ; CHECK-NEXT: csel w0, w0, w1, vs
367 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
368 %obit = extractvalue {i32, i1} %t, 1
369 %ret = select i1 %obit, i32 %v1, i32 %v2
373 define i1 @ssubo.not.i32(i32 %v1, i32 %v2) {
375 ; CHECK-LABEL: ssubo.not.i32
377 ; CHECK-NEXT: cset w0, vc
378 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
379 %obit = extractvalue {i32, i1} %t, 1
380 %ret = xor i1 %obit, true
384 define i64 @ssubo.select.i64(i64 %v1, i64 %v2) {
386 ; CHECK-LABEL: ssubo.select.i64
388 ; CHECK-NEXT: csel x0, x0, x1, vs
389 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
390 %obit = extractvalue {i64, i1} %t, 1
391 %ret = select i1 %obit, i64 %v1, i64 %v2
395 define i1 @ssub.not.i64(i64 %v1, i64 %v2) {
397 ; CHECK-LABEL: ssub.not.i64
399 ; CHECK-NEXT: cset w0, vc
400 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
401 %obit = extractvalue {i64, i1} %t, 1
402 %ret = xor i1 %obit, true
406 define i32 @usubo.select.i32(i32 %v1, i32 %v2) {
408 ; CHECK-LABEL: usubo.select.i32
410 ; CHECK-NEXT: csel w0, w0, w1, lo
411 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
412 %obit = extractvalue {i32, i1} %t, 1
413 %ret = select i1 %obit, i32 %v1, i32 %v2
417 define i1 @usubo.not.i32(i32 %v1, i32 %v2) {
419 ; CHECK-LABEL: usubo.not.i32
421 ; CHECK-NEXT: cset w0, hs
422 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
423 %obit = extractvalue {i32, i1} %t, 1
424 %ret = xor i1 %obit, true
428 define i64 @usubo.select.i64(i64 %v1, i64 %v2) {
430 ; CHECK-LABEL: usubo.select.i64
432 ; CHECK-NEXT: csel x0, x0, x1, lo
433 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
434 %obit = extractvalue {i64, i1} %t, 1
435 %ret = select i1 %obit, i64 %v1, i64 %v2
439 define i1 @usubo.not.i64(i64 %v1, i64 %v2) {
441 ; CHECK-LABEL: usubo.not.i64
443 ; CHECK-NEXT: cset w0, hs
444 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
445 %obit = extractvalue {i64, i1} %t, 1
446 %ret = xor i1 %obit, true
450 define i32 @smulo.select.i32(i32 %v1, i32 %v2) {
452 ; CHECK-LABEL: smulo.select.i32
453 ; CHECK: smull x[[MREG:[0-9]+]], w0, w1
454 ; CHECK-NEXT: lsr x[[SREG:[0-9]+]], x[[MREG]], #32
455 ; CHECK-NEXT: cmp w[[SREG]], w[[MREG]], asr #31
456 ; CHECK-NEXT: csel w0, w0, w1, ne
457 %t = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %v1, i32 %v2)
458 %obit = extractvalue {i32, i1} %t, 1
459 %ret = select i1 %obit, i32 %v1, i32 %v2
463 define i1 @smulo.not.i32(i32 %v1, i32 %v2) {
465 ; CHECK-LABEL: smulo.not.i32
466 ; CHECK: smull x[[MREG:[0-9]+]], w0, w1
467 ; CHECK-NEXT: lsr x[[SREG:[0-9]+]], x[[MREG]], #32
468 ; CHECK-NEXT: cmp w[[SREG]], w[[MREG]], asr #31
469 ; CHECK-NEXT: cset w0, eq
470 %t = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %v1, i32 %v2)
471 %obit = extractvalue {i32, i1} %t, 1
472 %ret = xor i1 %obit, true
476 define i64 @smulo.select.i64(i64 %v1, i64 %v2) {
478 ; CHECK-LABEL: smulo.select.i64
479 ; CHECK: mul [[MREG:x[0-9]+]], x0, x1
480 ; CHECK-NEXT: smulh [[HREG:x[0-9]+]], x0, x1
481 ; CHECK-NEXT: cmp [[HREG]], [[MREG]], asr #63
482 ; CHECK-NEXT: csel x0, x0, x1, ne
483 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
484 %obit = extractvalue {i64, i1} %t, 1
485 %ret = select i1 %obit, i64 %v1, i64 %v2
489 define i1 @smulo.not.i64(i64 %v1, i64 %v2) {
491 ; CHECK-LABEL: smulo.not.i64
492 ; CHECK: mul [[MREG:x[0-9]+]], x0, x1
493 ; CHECK-NEXT: smulh [[HREG:x[0-9]+]], x0, x1
494 ; CHECK-NEXT: cmp [[HREG]], [[MREG]], asr #63
495 ; CHECK-NEXT: cset w0, eq
496 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
497 %obit = extractvalue {i64, i1} %t, 1
498 %ret = xor i1 %obit, true
502 define i32 @umulo.select.i32(i32 %v1, i32 %v2) {
504 ; CHECK-LABEL: umulo.select.i32
505 ; CHECK: umull [[MREG:x[0-9]+]], w0, w1
506 ; CHECK-NEXT: cmp xzr, [[MREG]], lsr #32
507 ; CHECK-NEXT: csel w0, w0, w1, ne
508 %t = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %v1, i32 %v2)
509 %obit = extractvalue {i32, i1} %t, 1
510 %ret = select i1 %obit, i32 %v1, i32 %v2
514 define i1 @umulo.not.i32(i32 %v1, i32 %v2) {
516 ; CHECK-LABEL: umulo.not.i32
517 ; CHECK: umull [[MREG:x[0-9]+]], w0, w1
518 ; CHECK-NEXT: cmp xzr, [[MREG]], lsr #32
519 ; CHECK-NEXT: cset w0, eq
520 %t = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %v1, i32 %v2)
521 %obit = extractvalue {i32, i1} %t, 1
522 %ret = xor i1 %obit, true
526 define i64 @umulo.select.i64(i64 %v1, i64 %v2) {
528 ; CHECK-LABEL: umulo.select.i64
529 ; CHECK: umulh [[MREG:x[0-9]+]], x0, x1
530 ; CHECK-NEXT: cmp xzr, [[MREG]]
531 ; CHECK-NEXT: csel x0, x0, x1, ne
532 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 %v2)
533 %obit = extractvalue {i64, i1} %t, 1
534 %ret = select i1 %obit, i64 %v1, i64 %v2
538 define i1 @umulo.not.i64(i64 %v1, i64 %v2) {
540 ; CHECK-LABEL: umulo.not.i64
541 ; CHECK: umulh [[MREG:x[0-9]+]], x0, x1
542 ; CHECK-NEXT: cmp xzr, [[MREG]]
543 ; CHECK-NEXT: cset w0, eq
544 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 %v2)
545 %obit = extractvalue {i64, i1} %t, 1
546 %ret = xor i1 %obit, true
552 ; Check the use of the overflow bit in combination with a branch instruction.
554 define zeroext i1 @saddo.br.i32(i32 %v1, i32 %v2) {
556 ; CHECK-LABEL: saddo.br.i32
559 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2)
560 %val = extractvalue {i32, i1} %t, 0
561 %obit = extractvalue {i32, i1} %t, 1
562 br i1 %obit, label %overflow, label %continue
571 define zeroext i1 @saddo.br.i64(i64 %v1, i64 %v2) {
573 ; CHECK-LABEL: saddo.br.i64
576 %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2)
577 %val = extractvalue {i64, i1} %t, 0
578 %obit = extractvalue {i64, i1} %t, 1
579 br i1 %obit, label %overflow, label %continue
588 define zeroext i1 @uaddo.br.i32(i32 %v1, i32 %v2) {
590 ; CHECK-LABEL: uaddo.br.i32
593 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
594 %val = extractvalue {i32, i1} %t, 0
595 %obit = extractvalue {i32, i1} %t, 1
596 br i1 %obit, label %overflow, label %continue
605 define zeroext i1 @uaddo.br.i64(i64 %v1, i64 %v2) {
607 ; CHECK-LABEL: uaddo.br.i64
610 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2)
611 %val = extractvalue {i64, i1} %t, 0
612 %obit = extractvalue {i64, i1} %t, 1
613 br i1 %obit, label %overflow, label %continue
622 define zeroext i1 @ssubo.br.i32(i32 %v1, i32 %v2) {
624 ; CHECK-LABEL: ssubo.br.i32
627 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
628 %val = extractvalue {i32, i1} %t, 0
629 %obit = extractvalue {i32, i1} %t, 1
630 br i1 %obit, label %overflow, label %continue
639 define zeroext i1 @ssubo.br.i64(i64 %v1, i64 %v2) {
641 ; CHECK-LABEL: ssubo.br.i64
644 %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2)
645 %val = extractvalue {i64, i1} %t, 0
646 %obit = extractvalue {i64, i1} %t, 1
647 br i1 %obit, label %overflow, label %continue
656 define zeroext i1 @usubo.br.i32(i32 %v1, i32 %v2) {
658 ; CHECK-LABEL: usubo.br.i32
661 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2)
662 %val = extractvalue {i32, i1} %t, 0
663 %obit = extractvalue {i32, i1} %t, 1
664 br i1 %obit, label %overflow, label %continue
673 define zeroext i1 @usubo.br.i64(i64 %v1, i64 %v2) {
675 ; CHECK-LABEL: usubo.br.i64
678 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2)
679 %val = extractvalue {i64, i1} %t, 0
680 %obit = extractvalue {i64, i1} %t, 1
681 br i1 %obit, label %overflow, label %continue
690 define zeroext i1 @smulo.br.i32(i32 %v1, i32 %v2) {
692 ; CHECK-LABEL: smulo.br.i32
693 ; CHECK: smull x[[MREG:[0-9]+]], w0, w1
694 ; CHECK-NEXT: lsr x[[SREG:[0-9]+]], x8, #32
695 ; CHECK-NEXT: cmp w[[SREG]], w[[MREG]], asr #31
697 %t = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %v1, i32 %v2)
698 %val = extractvalue {i32, i1} %t, 0
699 %obit = extractvalue {i32, i1} %t, 1
700 br i1 %obit, label %overflow, label %continue
709 define zeroext i1 @smulo.br.i64(i64 %v1, i64 %v2) {
711 ; CHECK-LABEL: smulo.br.i64
712 ; CHECK: mul [[MREG:x[0-9]+]], x0, x1
713 ; CHECK-NEXT: smulh [[HREG:x[0-9]+]], x0, x1
714 ; CHECK-NEXT: cmp [[HREG]], [[MREG]], asr #63
716 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 %v2)
717 %val = extractvalue {i64, i1} %t, 0
718 %obit = extractvalue {i64, i1} %t, 1
719 br i1 %obit, label %overflow, label %continue
728 define zeroext i1 @smulo2.br.i64(i64 %v1) {
730 ; CHECK-LABEL: smulo2.br.i64
733 %t = call {i64, i1} @llvm.smul.with.overflow.i64(i64 %v1, i64 2)
734 %val = extractvalue {i64, i1} %t, 0
735 %obit = extractvalue {i64, i1} %t, 1
736 br i1 %obit, label %overflow, label %continue
745 define zeroext i1 @umulo.br.i32(i32 %v1, i32 %v2) {
747 ; CHECK-LABEL: umulo.br.i32
748 ; CHECK: umull [[MREG:x[0-9]+]], w0, w1
749 ; CHECK-NEXT: cmp xzr, [[MREG]], lsr #32
751 %t = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %v1, i32 %v2)
752 %val = extractvalue {i32, i1} %t, 0
753 %obit = extractvalue {i32, i1} %t, 1
754 br i1 %obit, label %overflow, label %continue
763 define zeroext i1 @umulo.br.i64(i64 %v1, i64 %v2) {
765 ; CHECK-LABEL: umulo.br.i64
766 ; CHECK: umulh [[REG:x[0-9]+]], x0, x1
767 ; CHECK-NEXT: {{cbz|cmp}}
768 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 %v2)
769 %val = extractvalue {i64, i1} %t, 0
770 %obit = extractvalue {i64, i1} %t, 1
771 br i1 %obit, label %overflow, label %continue
780 define zeroext i1 @umulo2.br.i64(i64 %v1) {
782 ; CHECK-LABEL: umulo2.br.i64
785 %t = call {i64, i1} @llvm.umul.with.overflow.i64(i64 %v1, i64 2)
786 %val = extractvalue {i64, i1} %t, 0
787 %obit = extractvalue {i64, i1} %t, 1
788 br i1 %obit, label %overflow, label %continue
797 declare {i32, i1} @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
798 declare {i64, i1} @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
799 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
800 declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
801 declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone
802 declare {i64, i1} @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone
803 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
804 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
805 declare {i32, i1} @llvm.smul.with.overflow.i32(i32, i32) nounwind readnone
806 declare {i64, i1} @llvm.smul.with.overflow.i64(i64, i64) nounwind readnone
807 declare {i32, i1} @llvm.umul.with.overflow.i32(i32, i32) nounwind readnone
808 declare {i64, i1} @llvm.umul.with.overflow.i64(i64, i64) nounwind readnone