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