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.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 ; Check subtraction of 1.
9 define zeroext i1 @f1(i32 %dummy, i32 %a, ptr %res) {
12 ; CHECK-NEXT: slfi %r3, 1
14 ; CHECK-NEXT: afi %r0, -536870912
15 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
16 ; CHECK-NEXT: st %r3, 0(%r4)
18 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
19 %val = extractvalue {i32, i1} %t, 0
20 %obit = extractvalue {i32, i1} %t, 1
21 store i32 %val, ptr %res
25 ; Check the high end of the SLFI range.
26 define zeroext i1 @f2(i32 %dummy, i32 %a, ptr %res) {
29 ; CHECK-NEXT: slfi %r3, 4294967295
31 ; CHECK-NEXT: afi %r0, -536870912
32 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
33 ; CHECK-NEXT: st %r3, 0(%r4)
35 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 4294967295)
36 %val = extractvalue {i32, i1} %t, 0
37 %obit = extractvalue {i32, i1} %t, 1
38 store i32 %val, ptr %res
42 ; Check that negative values are treated as unsigned
43 define zeroext i1 @f3(i32 %dummy, i32 %a, ptr %res) {
46 ; CHECK-NEXT: slfi %r3, 4294967295
48 ; CHECK-NEXT: afi %r0, -536870912
49 ; CHECK-NEXT: risbg %r2, %r0, 63, 191, 33
50 ; CHECK-NEXT: st %r3, 0(%r4)
52 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 -1)
53 %val = extractvalue {i32, i1} %t, 0
54 %obit = extractvalue {i32, i1} %t, 1
55 store i32 %val, ptr %res
59 ; Check using the overflow result for a branch.
60 define void @f4(i32 %dummy, i32 %a, ptr %res) {
63 ; CHECK-NEXT: slfi %r3, 1
64 ; CHECK-NEXT: st %r3, 0(%r4)
65 ; CHECK-NEXT: jgle foo@PLT
66 ; CHECK-NEXT: .LBB3_1: # %exit
68 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
69 %val = extractvalue {i32, i1} %t, 0
70 %obit = extractvalue {i32, i1} %t, 1
71 store i32 %val, ptr %res
72 br i1 %obit, label %call, label %exit
82 ; ... and the same with the inverted direction.
83 define void @f5(i32 %dummy, i32 %a, ptr %res) {
86 ; CHECK-NEXT: slfi %r3, 1
87 ; CHECK-NEXT: st %r3, 0(%r4)
88 ; CHECK-NEXT: jgnle foo@PLT
89 ; CHECK-NEXT: .LBB4_1: # %exit
91 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 1)
92 %val = extractvalue {i32, i1} %t, 0
93 %obit = extractvalue {i32, i1} %t, 1
94 store i32 %val, ptr %res
95 br i1 %obit, label %exit, label %call
105 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone