1 ; Test subtractions of a sign-extended i32 from an i64.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 define i64 @f1(i64 %a, i32 %b) {
10 ; CHECK: sgfr %r2, %r3
12 %bext = sext i32 %b to i64
13 %sub = sub i64 %a, %bext
17 ; Check SGF with no displacement.
18 define i64 @f2(i64 %a, ptr %src) {
20 ; CHECK: sgf %r2, 0(%r3)
22 %b = load i32, ptr %src
23 %bext = sext i32 %b to i64
24 %sub = sub i64 %a, %bext
28 ; Check the high end of the aligned SGF range.
29 define i64 @f3(i64 %a, ptr %src) {
31 ; CHECK: sgf %r2, 524284(%r3)
33 %ptr = getelementptr i32, ptr %src, i64 131071
34 %b = load i32, ptr %ptr
35 %bext = sext i32 %b to i64
36 %sub = sub i64 %a, %bext
40 ; Check the next word up, which needs separate address logic.
41 ; Other sequences besides this one would be OK.
42 define i64 @f4(i64 %a, ptr %src) {
44 ; CHECK: agfi %r3, 524288
45 ; CHECK: sgf %r2, 0(%r3)
47 %ptr = getelementptr i32, ptr %src, i64 131072
48 %b = load i32, ptr %ptr
49 %bext = sext i32 %b to i64
50 %sub = sub i64 %a, %bext
54 ; Check the high end of the negative aligned SGF range.
55 define i64 @f5(i64 %a, ptr %src) {
57 ; CHECK: sgf %r2, -4(%r3)
59 %ptr = getelementptr i32, ptr %src, i64 -1
60 %b = load i32, ptr %ptr
61 %bext = sext i32 %b to i64
62 %sub = sub i64 %a, %bext
66 ; Check the low end of the SGF range.
67 define i64 @f6(i64 %a, ptr %src) {
69 ; CHECK: sgf %r2, -524288(%r3)
71 %ptr = getelementptr i32, ptr %src, i64 -131072
72 %b = load i32, ptr %ptr
73 %bext = sext i32 %b to i64
74 %sub = sub i64 %a, %bext
78 ; Check the next word down, which needs separate address logic.
79 ; Other sequences besides this one would be OK.
80 define i64 @f7(i64 %a, ptr %src) {
82 ; CHECK: agfi %r3, -524292
83 ; CHECK: sgf %r2, 0(%r3)
85 %ptr = getelementptr i32, ptr %src, i64 -131073
86 %b = load i32, ptr %ptr
87 %bext = sext i32 %b to i64
88 %sub = sub i64 %a, %bext
92 ; Check that SGF allows an index.
93 define i64 @f8(i64 %a, i64 %src, i64 %index) {
95 ; CHECK: sgf %r2, 524284({{%r4,%r3|%r3,%r4}})
97 %add1 = add i64 %src, %index
98 %add2 = add i64 %add1, 524284
99 %ptr = inttoptr i64 %add2 to ptr
100 %b = load i32, ptr %ptr
101 %bext = sext i32 %b to i64
102 %sub = sub i64 %a, %bext
106 ; Check that subtractions of spilled values can use SGF rather than SGFR.
107 define i64 @f9(ptr %ptr0) {
109 ; CHECK: brasl %r14, foo@PLT
110 ; CHECK: sgf %r2, 160(%r15)
112 %ptr1 = getelementptr i32, ptr %ptr0, i64 2
113 %ptr2 = getelementptr i32, ptr %ptr0, i64 4
114 %ptr3 = getelementptr i32, ptr %ptr0, i64 6
115 %ptr4 = getelementptr i32, ptr %ptr0, i64 8
116 %ptr5 = getelementptr i32, ptr %ptr0, i64 10
117 %ptr6 = getelementptr i32, ptr %ptr0, i64 12
118 %ptr7 = getelementptr i32, ptr %ptr0, i64 14
119 %ptr8 = getelementptr i32, ptr %ptr0, i64 16
120 %ptr9 = getelementptr i32, ptr %ptr0, i64 18
122 %val0 = load i32, ptr %ptr0
123 %val1 = load i32, ptr %ptr1
124 %val2 = load i32, ptr %ptr2
125 %val3 = load i32, ptr %ptr3
126 %val4 = load i32, ptr %ptr4
127 %val5 = load i32, ptr %ptr5
128 %val6 = load i32, ptr %ptr6
129 %val7 = load i32, ptr %ptr7
130 %val8 = load i32, ptr %ptr8
131 %val9 = load i32, ptr %ptr9
133 %frob0 = add i32 %val0, 100
134 %frob1 = add i32 %val1, 100
135 %frob2 = add i32 %val2, 100
136 %frob3 = add i32 %val3, 100
137 %frob4 = add i32 %val4, 100
138 %frob5 = add i32 %val5, 100
139 %frob6 = add i32 %val6, 100
140 %frob7 = add i32 %val7, 100
141 %frob8 = add i32 %val8, 100
142 %frob9 = add i32 %val9, 100
144 store i32 %frob0, ptr %ptr0
145 store i32 %frob1, ptr %ptr1
146 store i32 %frob2, ptr %ptr2
147 store i32 %frob3, ptr %ptr3
148 store i32 %frob4, ptr %ptr4
149 store i32 %frob5, ptr %ptr5
150 store i32 %frob6, ptr %ptr6
151 store i32 %frob7, ptr %ptr7
152 store i32 %frob8, ptr %ptr8
153 store i32 %frob9, ptr %ptr9
155 %ret = call i64 @foo()
157 %ext0 = sext i32 %frob0 to i64
158 %ext1 = sext i32 %frob1 to i64
159 %ext2 = sext i32 %frob2 to i64
160 %ext3 = sext i32 %frob3 to i64
161 %ext4 = sext i32 %frob4 to i64
162 %ext5 = sext i32 %frob5 to i64
163 %ext6 = sext i32 %frob6 to i64
164 %ext7 = sext i32 %frob7 to i64
165 %ext8 = sext i32 %frob8 to i64
166 %ext9 = sext i32 %frob9 to i64
168 %sub0 = sub i64 %ret, %ext0
169 %sub1 = sub i64 %sub0, %ext1
170 %sub2 = sub i64 %sub1, %ext2
171 %sub3 = sub i64 %sub2, %ext3
172 %sub4 = sub i64 %sub3, %ext4
173 %sub5 = sub i64 %sub4, %ext5
174 %sub6 = sub i64 %sub5, %ext6
175 %sub7 = sub i64 %sub6, %ext7
176 %sub8 = sub i64 %sub7, %ext8
177 %sub9 = sub i64 %sub8, %ext9