1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; Test the three-operand form of 32-bit addition.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
6 declare i32 @foo(i32, i32, i32)
9 define i32 @f1(i32 %dummy, i32 %a, i32 %b, ptr %flag) {
12 ; CHECK-NEXT: alrk %r2, %r3, %r4
14 ; CHECK-NEXT: risblg %r0, %r0, 31, 159, 35
15 ; CHECK-NEXT: st %r0, 0(%r5)
17 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
18 %val = extractvalue {i32, i1} %t, 0
19 %obit = extractvalue {i32, i1} %t, 1
20 %ext = zext i1 %obit to i32
21 store i32 %ext, ptr %flag
25 ; Check using the overflow result for a branch.
26 define i32 @f2(i32 %dummy, i32 %a, i32 %b) {
29 ; CHECK-NEXT: alrk %r2, %r3, %r4
30 ; CHECK-NEXT: bler %r14
31 ; CHECK-NEXT: .LBB1_1: # %call
32 ; CHECK-NEXT: lhi %r2, 0
33 ; CHECK-NEXT: jg foo@PLT
34 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
35 %val = extractvalue {i32, i1} %t, 0
36 %obit = extractvalue {i32, i1} %t, 1
37 br i1 %obit, label %call, label %exit
40 %res = tail call i32 @foo(i32 0, i32 %a, i32 %b)
47 ; ... and the same with the inverted direction.
48 define i32 @f3(i32 %dummy, i32 %a, i32 %b) {
51 ; CHECK-NEXT: alrk %r2, %r3, %r4
52 ; CHECK-NEXT: bnler %r14
53 ; CHECK-NEXT: .LBB2_1: # %call
54 ; CHECK-NEXT: lhi %r2, 0
55 ; CHECK-NEXT: jg foo@PLT
56 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
57 %val = extractvalue {i32, i1} %t, 0
58 %obit = extractvalue {i32, i1} %t, 1
59 br i1 %obit, label %exit, label %call
62 %res = tail call i32 @foo(i32 0, i32 %a, i32 %b)
69 ; Check that we can still use ALR in obvious cases.
70 define i32 @f4(i32 %a, i32 %b, ptr %flag) {
73 ; CHECK-NEXT: alr %r2, %r3
75 ; CHECK-NEXT: risblg %r0, %r0, 31, 159, 35
76 ; CHECK-NEXT: st %r0, 0(%r4)
78 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
79 %val = extractvalue {i32, i1} %t, 0
80 %obit = extractvalue {i32, i1} %t, 1
81 %ext = zext i1 %obit to i32
82 store i32 %ext, ptr %flag
86 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone