1; Test 32-bit addition in which the second operand is constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check additions of 1.
6define i32 @f1(i32 %a) {
7; CHECK-LABEL: f1:
8; CHECK: ahi %r2, 1
9; CHECK: br %r14
10  %add = add i32 %a, 1
11  ret i32 %add
12}
13
14; Check the high end of the AHI range.
15define i32 @f2(i32 %a) {
16; CHECK-LABEL: f2:
17; CHECK: ahi %r2, 32767
18; CHECK: br %r14
19  %add = add i32 %a, 32767
20  ret i32 %add
21}
22
23; Check the next value up, which must use AFI instead.
24define i32 @f3(i32 %a) {
25; CHECK-LABEL: f3:
26; CHECK: afi %r2, 32768
27; CHECK: br %r14
28  %add = add i32 %a, 32768
29  ret i32 %add
30}
31
32; Check the high end of the signed 32-bit range.
33define i32 @f4(i32 %a) {
34; CHECK-LABEL: f4:
35; CHECK: afi %r2, 2147483647
36; CHECK: br %r14
37  %add = add i32 %a, 2147483647
38  ret i32 %add
39}
40
41; Check the next value up, which is treated as a negative value.
42define i32 @f5(i32 %a) {
43; CHECK-LABEL: f5:
44; CHECK: afi %r2, -2147483648
45; CHECK: br %r14
46  %add = add i32 %a, 2147483648
47  ret i32 %add
48}
49
50; Check the high end of the negative AHI range.
51define i32 @f6(i32 %a) {
52; CHECK-LABEL: f6:
53; CHECK: ahi %r2, -1
54; CHECK: br %r14
55  %add = add i32 %a, -1
56  ret i32 %add
57}
58
59; Check the low end of the AHI range.
60define i32 @f7(i32 %a) {
61; CHECK-LABEL: f7:
62; CHECK: ahi %r2, -32768
63; CHECK: br %r14
64  %add = add i32 %a, -32768
65  ret i32 %add
66}
67
68; Check the next value down, which must use AFI instead.
69define i32 @f8(i32 %a) {
70; CHECK-LABEL: f8:
71; CHECK: afi %r2, -32769
72; CHECK: br %r14
73  %add = add i32 %a, -32769
74  ret i32 %add
75}
76
77; Check the low end of the signed 32-bit range.
78define i32 @f9(i32 %a) {
79; CHECK-LABEL: f9:
80; CHECK: afi %r2, -2147483648
81; CHECK: br %r14
82  %add = add i32 %a, -2147483648
83  ret i32 %add
84}
85
86; Check the next value down, which is treated as a positive value.
87define i32 @f10(i32 %a) {
88; CHECK-LABEL: f10:
89; CHECK: afi %r2, 2147483647
90; CHECK: br %r14
91  %add = add i32 %a, -2147483649
92  ret i32 %add
93}
94