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: slgrk %r2, %r3, %r4
11 ; CHECK: ipm [[REG1:%r[0-5]]]
12 ; CHECK: afi [[REG1]], -536870912
13 ; CHECK: risbg [[REG2:%r[0-5]]], [[REG1]], 63, 191, 33
14 ; CHECK: stg [[REG2]], 0(%r5)
16 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
17 %val = extractvalue {i64, i1} %t, 0
18 %obit = extractvalue {i64, i1} %t, 1
19 %ext = zext i1 %obit to i64
20 store i64 %ext, i64 *%flag
24 ; Check using the overflow result for a branch.
25 define i64 @f2(i64 %dummy, i64 %a, i64 %b) {
27 ; CHECK: slgrk %r2, %r3, %r4
28 ; CHECK-NEXT: bnler %r14
31 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
32 %val = extractvalue {i64, i1} %t, 0
33 %obit = extractvalue {i64, i1} %t, 1
34 br i1 %obit, label %call, label %exit
37 %res = tail call i64 @foo(i64 0, i64 %a, i64 %b)
44 ; ... and the same with the inverted direction.
45 define i64 @f3(i64 %dummy, i64 %a, i64 %b) {
47 ; CHECK: slgrk %r2, %r3, %r4
48 ; CHECK-NEXT: bler %r14
51 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
52 %val = extractvalue {i64, i1} %t, 0
53 %obit = extractvalue {i64, i1} %t, 1
54 br i1 %obit, label %exit, label %call
57 %res = tail call i64 @foo(i64 0, i64 %a, i64 %b)
64 ; Check that we can still use SLGR in obvious cases.
65 define i64 @f4(i64 %a, i64 %b, i64 *%flag) {
67 ; CHECK: slgr %r2, %r3
68 ; CHECK: ipm [[REG1:%r[0-5]]]
69 ; CHECK: afi [[REG1]], -536870912
70 ; CHECK: risbg [[REG2:%r[0-5]]], [[REG1]], 63, 191, 33
71 ; CHECK: stg [[REG2]], 0(%r4)
73 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
74 %val = extractvalue {i64, i1} %t, 0
75 %obit = extractvalue {i64, i1} %t, 1
76 %ext = zext i1 %obit to i64
77 store i64 %ext, i64 *%flag
81 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone