1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; Test 32-bit subtraction 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(i32 %dummy, i32 %a, ptr %res) {
13 ; CHECK-NEXT: alhsik %r0, %r3, -1
14 ; CHECK-NEXT: st %r0, 0(%r4)
16 ; CHECK-NEXT: afi %r1, -536870912
17 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
19 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
20 %val = extractvalue {i32, i1} %t, 0
21 %obit = extractvalue {i32, i1} %t, 1
22 store i32 %val, ptr %res
26 ; Check the high end of the ALHSIK range.
27 define zeroext i1 @f2(i32 %dummy, i32 %a, ptr %res) {
30 ; CHECK-NEXT: alhsik %r0, %r3, -32768
31 ; CHECK-NEXT: st %r0, 0(%r4)
33 ; CHECK-NEXT: afi %r1, -536870912
34 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
36 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 32768)
37 %val = extractvalue {i32, i1} %t, 0
38 %obit = extractvalue {i32, i1} %t, 1
39 store i32 %val, ptr %res
43 ; Check the next value down, which must use SLFI instead.
44 define zeroext i1 @f3(i32 %dummy, i32 %a, ptr %res) {
47 ; CHECK-NEXT: slfi %r3, 32769
48 ; CHECK-NEXT: st %r3, 0(%r4)
50 ; CHECK-NEXT: afi %r0, -536870912
51 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
53 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 32769)
54 %val = extractvalue {i32, i1} %t, 0
55 %obit = extractvalue {i32, i1} %t, 1
56 store i32 %val, ptr %res
60 ; Check the high end of the negative ALHSIK range.
61 define zeroext i1 @f4(i32 %dummy, i32 %a, ptr %res) {
64 ; CHECK-NEXT: alhsik %r0, %r3, 1
65 ; CHECK-NEXT: st %r0, 0(%r4)
67 ; CHECK-NEXT: afi %r1, -536870912
68 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
70 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 -1)
71 %val = extractvalue {i32, i1} %t, 0
72 %obit = extractvalue {i32, i1} %t, 1
73 store i32 %val, ptr %res
77 ; Check the low end of the ALHSIK range.
78 define zeroext i1 @f5(i32 %dummy, i32 %a, ptr %res) {
81 ; CHECK-NEXT: alhsik %r0, %r3, 32767
82 ; CHECK-NEXT: st %r0, 0(%r4)
84 ; CHECK-NEXT: afi %r1, -536870912
85 ; CHECK-NEXT: risbg %r2, %r1, 63, 191, 33
87 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 -32767)
88 %val = extractvalue {i32, i1} %t, 0
89 %obit = extractvalue {i32, i1} %t, 1
90 store i32 %val, ptr %res
94 ; Check the next value down, which must use SLFI instead.
95 define zeroext i1 @f6(i32 %dummy, i32 %a, ptr %res) {
98 ; CHECK-NEXT: slfi %r3, 4294934528
99 ; CHECK-NEXT: st %r3, 0(%r4)
100 ; CHECK-NEXT: ipm %r0
101 ; CHECK-NEXT: afi %r0, -536870912
102 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
103 ; CHECK-NEXT: br %r14
104 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 -32768)
105 %val = extractvalue {i32, i1} %t, 0
106 %obit = extractvalue {i32, i1} %t, 1
107 store i32 %val, ptr %res
111 ; Check using the overflow result for a branch.
112 define void @f7(i32 %dummy, i32 %a, ptr %res) {
115 ; CHECK-NEXT: alhsik %r0, %r3, -1
116 ; CHECK-NEXT: st %r0, 0(%r4)
117 ; CHECK-NEXT: jgle foo@PLT
118 ; CHECK-NEXT: .LBB6_1: # %exit
119 ; CHECK-NEXT: br %r14
120 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
121 %val = extractvalue {i32, i1} %t, 0
122 %obit = extractvalue {i32, i1} %t, 1
123 store i32 %val, ptr %res
124 br i1 %obit, label %call, label %exit
134 ; ... and the same with the inverted direction.
135 define void @f8(i32 %dummy, i32 %a, ptr %res) {
138 ; CHECK-NEXT: alhsik %r0, %r3, -1
139 ; CHECK-NEXT: st %r0, 0(%r4)
140 ; CHECK-NEXT: jgnle foo@PLT
141 ; CHECK-NEXT: .LBB7_1: # %exit
142 ; CHECK-NEXT: br %r14
143 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
144 %val = extractvalue {i32, i1} %t, 0
145 %obit = extractvalue {i32, i1} %t, 1
146 store i32 %val, ptr %res
147 br i1 %obit, label %exit, label %call
158 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone