1 ; Test the three-operand form of 64-bit addition.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
5 declare i64 @foo(i64, i64, i64)
8 define i64 @f1(i64 %dummy, i64 %a, i64 %b, i64 *%flag) {
10 ; CHECK: algrk %r2, %r3, %r4
11 ; CHECK: ipm [[REG1:%r[0-5]]]
12 ; CHECK: risbg [[REG2:%r[0-5]]], [[REG1]], 63, 191, 35
13 ; CHECK: stg [[REG2]], 0(%r5)
15 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
16 %val = extractvalue {i64, i1} %t, 0
17 %obit = extractvalue {i64, i1} %t, 1
18 %ext = zext i1 %obit to i64
19 store i64 %ext, i64 *%flag
23 ; Check using the overflow result for a branch.
24 define i64 @f2(i64 %dummy, i64 %a, i64 %b) {
26 ; CHECK: algrk %r2, %r3, %r4
27 ; CHECK-NEXT: bler %r14
30 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
31 %val = extractvalue {i64, i1} %t, 0
32 %obit = extractvalue {i64, i1} %t, 1
33 br i1 %obit, label %call, label %exit
36 %res = tail call i64 @foo(i64 0, i64 %a, i64 %b)
43 ; ... and the same with the inverted direction.
44 define i64 @f3(i64 %dummy, i64 %a, i64 %b) {
46 ; CHECK: algrk %r2, %r3, %r4
47 ; CHECK-NEXT: bnler %r14
50 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
51 %val = extractvalue {i64, i1} %t, 0
52 %obit = extractvalue {i64, i1} %t, 1
53 br i1 %obit, label %exit, label %call
56 %res = tail call i64 @foo(i64 0, i64 %a, i64 %b)
63 ; Check that we can still use ALGR in obvious cases.
64 define i64 @f4(i64 %a, i64 %b, i64 *%flag) {
66 ; CHECK: algr %r2, %r3
67 ; CHECK: ipm [[REG1:%r[0-5]]]
68 ; CHECK: risbg [[REG2:%r[0-5]]], [[REG1]], 63, 191, 35
69 ; CHECK: stg [[REG2]], 0(%r4)
71 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
72 %val = extractvalue {i64, i1} %t, 0
73 %obit = extractvalue {i64, i1} %t, 1
74 %ext = zext i1 %obit to i64
75 store i64 %ext, i64 *%flag
79 declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone