1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; Test 64-bit subtraction in which the second operand is constant.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
9 define zeroext i1 @f1(i64 %dummy, i64 %a, ptr %res) {
12 ; CHECK-NEXT: slgfi %r3, 1
14 ; CHECK-NEXT: afi %r0, -536870912
15 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
16 ; CHECK-NEXT: stg %r3, 0(%r4)
18 %t = call {i64, i1} @llvm.usub.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 SLGFI range.
26 define zeroext i1 @f2(i64 %dummy, i64 %a, ptr %res) {
29 ; CHECK-NEXT: slgfi %r3, 4294967295
31 ; CHECK-NEXT: afi %r0, -536870912
32 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
33 ; CHECK-NEXT: stg %r3, 0(%r4)
35 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 4294967295)
36 %val = extractvalue {i64, i1} %t, 0
37 %obit = extractvalue {i64, i1} %t, 1
38 store i64 %val, ptr %res
42 ; Check the next value up, which must be loaded into a register first.
43 define zeroext i1 @f3(i64 %dummy, i64 %a, ptr %res) {
46 ; CHECK-NEXT: llihl %r0, 1
47 ; CHECK-NEXT: slgr %r3, %r0
49 ; CHECK-NEXT: afi %r0, -536870912
50 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
51 ; CHECK-NEXT: stg %r3, 0(%r4)
53 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 4294967296)
54 %val = extractvalue {i64, i1} %t, 0
55 %obit = extractvalue {i64, i1} %t, 1
56 store i64 %val, ptr %res
60 ; Likewise for negative values.
61 define zeroext i1 @f4(i64 %dummy, i64 %a, ptr %res) {
64 ; CHECK-NEXT: lghi %r0, -1
65 ; CHECK-NEXT: slgr %r3, %r0
67 ; CHECK-NEXT: afi %r0, -536870912
68 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
69 ; CHECK-NEXT: stg %r3, 0(%r4)
71 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 -1)
72 %val = extractvalue {i64, i1} %t, 0
73 %obit = extractvalue {i64, i1} %t, 1
74 store i64 %val, ptr %res
78 ; Check using the overflow result for a branch.
79 define void @f5(i64 %dummy, i64 %a, ptr %res) {
82 ; CHECK-NEXT: slgfi %r3, 1
83 ; CHECK-NEXT: stg %r3, 0(%r4)
84 ; CHECK-NEXT: jgle foo@PLT
85 ; CHECK-NEXT: .LBB4_1: # %exit
87 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 1)
88 %val = extractvalue {i64, i1} %t, 0
89 %obit = extractvalue {i64, i1} %t, 1
90 store i64 %val, ptr %res
91 br i1 %obit, label %call, label %exit
101 ; ... and the same with the inverted direction.
102 define void @f6(i64 %dummy, i64 %a, ptr %res) {
105 ; CHECK-NEXT: slgfi %r3, 1
106 ; CHECK-NEXT: stg %r3, 0(%r4)
107 ; CHECK-NEXT: jgnle foo@PLT
108 ; CHECK-NEXT: .LBB5_1: # %exit
109 ; CHECK-NEXT: br %r14
110 %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 1)
111 %val = extractvalue {i64, i1} %t, 0
112 %obit = extractvalue {i64, i1} %t, 1
113 store i64 %val, ptr %res
114 br i1 %obit, label %exit, label %call
124 declare {i64, i1} @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone