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 subtraction 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: afi %r1, -536870912
17 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
19 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 1)
20 %val = extractvalue {i64, i1} %t, 0
21 %obit = extractvalue {i64, i1} %t, 1
22 store i64 %val, ptr %res
26 ; Check the high end of the ALGHSIK range.
27 define zeroext i1 @f2(i64 %dummy, i64 %a, ptr %res) {
30 ; CHECK-NEXT: alghsik %r0, %r3, -32768
31 ; CHECK-NEXT: stg %r0, 0(%r4)
33 ; CHECK-NEXT: afi %r1, -536870912
34 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
36 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 32768)
37 %val = extractvalue {i64, i1} %t, 0
38 %obit = extractvalue {i64, i1} %t, 1
39 store i64 %val, ptr %res
43 ; Check the next value up, which must use SLGFI instead.
44 define zeroext i1 @f3(i64 %dummy, i64 %a, ptr %res) {
47 ; CHECK-NEXT: slgfi %r3, 32769
48 ; CHECK-NEXT: stg %r3, 0(%r4)
50 ; CHECK-NEXT: afi %r0, -536870912
51 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
53 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 32769)
54 %val = extractvalue {i64, i1} %t, 0
55 %obit = extractvalue {i64, i1} %t, 1
56 store i64 %val, ptr %res
60 ; Check the high end of the negative ALGHSIK range.
61 define zeroext i1 @f4(i64 %dummy, i64 %a, ptr %res) {
64 ; CHECK-NEXT: alghsik %r0, %r3, 1
65 ; CHECK-NEXT: stg %r0, 0(%r4)
67 ; CHECK-NEXT: afi %r1, -536870912
68 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
70 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 -1)
71 %val = extractvalue {i64, i1} %t, 0
72 %obit = extractvalue {i64, i1} %t, 1
73 store i64 %val, ptr %res
77 ; Check the low end of the ALGHSIK range.
78 define zeroext i1 @f5(i64 %dummy, i64 %a, ptr %res) {
81 ; CHECK-NEXT: alghsik %r0, %r3, 32767
82 ; CHECK-NEXT: stg %r0, 0(%r4)
84 ; CHECK-NEXT: afi %r1, -536870912
85 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
87 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 -32767)
88 %val = extractvalue {i64, i1} %t, 0
89 %obit = extractvalue {i64, i1} %t, 1
90 store i64 %val, ptr %res
94 ; Test the next value down, which cannot use either ALGHSIK or SLGFI.
95 define zeroext i1 @f6(i64 %dummy, i64 %a, ptr %res) {
98 ; CHECK-NEXT: lghi %r0, -32768
99 ; CHECK-NEXT: slgr %r3, %r0
100 ; CHECK-NEXT: ipm %r0
101 ; CHECK-NEXT: afi %r0, -536870912
102 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
103 ; CHECK-NEXT: stg %r3, 0(%r4)
104 ; CHECK-NEXT: br %r14
105 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 -32768)
106 %val = extractvalue {i64, i1} %t, 0
107 %obit = extractvalue {i64, i1} %t, 1
108 store i64 %val, ptr %res
112 ; Check using the overflow result for a branch.
113 define void @f7(i64 %dummy, i64 %a, ptr %res) {
116 ; CHECK-NEXT: alghsik %r0, %r3, -1
117 ; CHECK-NEXT: stg %r0, 0(%r4)
118 ; CHECK-NEXT: jgle foo@PLT
119 ; CHECK-NEXT: .LBB6_1: # %exit
120 ; CHECK-NEXT: br %r14
121 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 1)
122 %val = extractvalue {i64, i1} %t, 0
123 %obit = extractvalue {i64, i1} %t, 1
124 store i64 %val, ptr %res
125 br i1 %obit, label %call, label %exit
135 ; ... and the same with the inverted direction.
136 define void @f8(i64 %dummy, i64 %a, ptr %res) {
139 ; CHECK-NEXT: alghsik %r0, %r3, -1
140 ; CHECK-NEXT: stg %r0, 0(%r4)
141 ; CHECK-NEXT: jgnle foo@PLT
142 ; CHECK-NEXT: .LBB7_1: # %exit
143 ; CHECK-NEXT: br %r14
144 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 1)
145 %val = extractvalue {i64, i1} %t, 0
146 %obit = extractvalue {i64, i1} %t, 1
147 store i64 %val, ptr %res
148 br i1 %obit, label %exit, label %call
159 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone