1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; Test 64-bit addition in which the second operand is constant and in which
3 ; three-operand forms are available.
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
9 ; Check additions of 1.
10 define zeroext i1 @f1(i64 %dummy, i64 %a, ptr %res) {
13 ; CHECK-NEXT: alghsik %r0, %r3, 1
14 ; CHECK-NEXT: stg %r0, 0(%r4)
16 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 35
18 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 1)
19 %val = extractvalue {i64, i1} %t, 0
20 %obit = extractvalue {i64, i1} %t, 1
21 store i64 %val, ptr %res
25 ; Check the high end of the ALGHSIK range.
26 define zeroext i1 @f2(i64 %dummy, i64 %a, ptr %res) {
29 ; CHECK-NEXT: alghsik %r0, %r3, 32767
30 ; CHECK-NEXT: stg %r0, 0(%r4)
32 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 35
34 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 32767)
35 %val = extractvalue {i64, i1} %t, 0
36 %obit = extractvalue {i64, i1} %t, 1
37 store i64 %val, ptr %res
41 ; Check the next value up, which must use ALGFI instead.
42 define zeroext i1 @f3(i64 %dummy, i64 %a, ptr %res) {
45 ; CHECK-NEXT: algfi %r3, 32768
46 ; CHECK-NEXT: stg %r3, 0(%r4)
48 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 35
50 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 32768)
51 %val = extractvalue {i64, i1} %t, 0
52 %obit = extractvalue {i64, i1} %t, 1
53 store i64 %val, ptr %res
57 ; Check the high end of the negative ALGHSIK range.
58 define zeroext i1 @f4(i64 %dummy, i64 %a, ptr %res) {
61 ; CHECK-NEXT: alghsik %r0, %r3, -1
62 ; CHECK-NEXT: stg %r0, 0(%r4)
64 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 35
66 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 -1)
67 %val = extractvalue {i64, i1} %t, 0
68 %obit = extractvalue {i64, i1} %t, 1
69 store i64 %val, ptr %res
73 ; Check the low end of the ALGHSIK range.
74 define zeroext i1 @f5(i64 %dummy, i64 %a, ptr %res) {
77 ; CHECK-NEXT: alghsik %r0, %r3, -32768
78 ; CHECK-NEXT: stg %r0, 0(%r4)
80 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 35
82 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 -32768)
83 %val = extractvalue {i64, i1} %t, 0
84 %obit = extractvalue {i64, i1} %t, 1
85 store i64 %val, ptr %res
89 ; Test the next value down, which cannot use either ALGHSIK or ALGFI.
90 define zeroext i1 @f6(i64 %dummy, i64 %a, ptr %res) {
93 ; CHECK-NEXT: lgfi %r0, -32769
94 ; CHECK-NEXT: algr %r0, %r3
96 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 35
97 ; CHECK-NEXT: stg %r0, 0(%r4)
99 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 -32769)
100 %val = extractvalue {i64, i1} %t, 0
101 %obit = extractvalue {i64, i1} %t, 1
102 store i64 %val, ptr %res
106 ; Check using the overflow result for a branch.
107 define void @f7(i64 %dummy, i64 %a, ptr %res) {
110 ; CHECK-NEXT: alghsik %r0, %r3, 1
111 ; CHECK-NEXT: stg %r0, 0(%r4)
112 ; CHECK-NEXT: jgnle foo@PLT
113 ; CHECK-NEXT: .LBB6_1: # %exit
114 ; CHECK-NEXT: br %r14
115 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 1)
116 %val = extractvalue {i64, i1} %t, 0
117 %obit = extractvalue {i64, i1} %t, 1
118 store i64 %val, ptr %res
119 br i1 %obit, label %call, label %exit
129 ; ... and the same with the inverted direction.
130 define void @f8(i64 %dummy, i64 %a, ptr %res) {
133 ; CHECK-NEXT: alghsik %r0, %r3, 1
134 ; CHECK-NEXT: stg %r0, 0(%r4)
135 ; CHECK-NEXT: jgle foo@PLT
136 ; CHECK-NEXT: .LBB7_1: # %exit
137 ; CHECK-NEXT: br %r14
138 %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 1)
139 %val = extractvalue {i64, i1} %t, 0
140 %obit = extractvalue {i64, i1} %t, 1
141 store i64 %val, ptr %res
142 br i1 %obit, label %exit, label %call
153 declare {i64, i1} @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone