blob: 58dee1da58b5e1102f7a0513c43e3f8399cc9397 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test the handling of base + 12-bit displacement addresses for large frames,
Richard Sandifordf834ea12013-10-31 12:14:17 +00002; in cases where no 20-bit form exists. The tests here assume z10 register
3; pressure, without the high words being available.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00004;
Richard Sandifordf834ea12013-10-31 12:14:17 +00005; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | \
6; RUN: FileCheck -check-prefix=CHECK-NOFP %s
7; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 -disable-fp-elim | \
8; RUN: FileCheck -check-prefix=CHECK-FP %s
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009
10; This file tests what happens when a displacement is converted from
11; being relative to the start of a frame object to being relative to
12; the frame itself. In some cases the test is only possible if two
13; objects are allocated.
14;
15; Rather than rely on a particular order for those objects, the tests
16; instead allocate two objects of the same size and apply the test to
17; both of them. For consistency, all tests follow this model, even if
18; one object would actually be enough.
19
20; First check the highest in-range offset after conversion, which is 4092
21; for word-addressing instructions like MVHI.
22;
Richard Sandiford23943222013-07-05 13:11:52 +000023; The last in-range doubleword offset is 4088. Since the frame has two
24; emergency spill slots at 160(%r15), the amount that we need to allocate
25; in order to put another object at offset 4088 is (4088 - 176) / 4 = 978
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026; words.
27define void @f1() {
Stephen Lind24ab202013-07-14 06:24:09 +000028; CHECK-NOFP-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000029; CHECK-NOFP: mvhi 4092(%r15), 42
30; CHECK-NOFP: br %r14
31;
Stephen Lind24ab202013-07-14 06:24:09 +000032; CHECK-FP-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000033; CHECK-FP: mvhi 4092(%r11), 42
34; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +000035 %region1 = alloca [978 x i32], align 8
36 %region2 = alloca [978 x i32], align 8
37 %ptr1 = getelementptr inbounds [978 x i32]* %region1, i64 0, i64 1
38 %ptr2 = getelementptr inbounds [978 x i32]* %region2, i64 0, i64 1
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000039 store volatile i32 42, i32 *%ptr1
40 store volatile i32 42, i32 *%ptr2
41 ret void
42}
43
44; Test the first out-of-range offset. We cannot use an index register here.
45define void @f2() {
Stephen Lind24ab202013-07-14 06:24:09 +000046; CHECK-NOFP-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000047; CHECK-NOFP: lay %r1, 4096(%r15)
48; CHECK-NOFP: mvhi 0(%r1), 42
49; CHECK-NOFP: br %r14
50;
Stephen Lind24ab202013-07-14 06:24:09 +000051; CHECK-FP-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000052; CHECK-FP: lay %r1, 4096(%r11)
53; CHECK-FP: mvhi 0(%r1), 42
54; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +000055 %region1 = alloca [978 x i32], align 8
56 %region2 = alloca [978 x i32], align 8
57 %ptr1 = getelementptr inbounds [978 x i32]* %region1, i64 0, i64 2
58 %ptr2 = getelementptr inbounds [978 x i32]* %region2, i64 0, i64 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000059 store volatile i32 42, i32 *%ptr1
60 store volatile i32 42, i32 *%ptr2
61 ret void
62}
63
64; Test the next offset after that.
65define void @f3() {
Stephen Lind24ab202013-07-14 06:24:09 +000066; CHECK-NOFP-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000067; CHECK-NOFP: lay %r1, 4096(%r15)
68; CHECK-NOFP: mvhi 4(%r1), 42
69; CHECK-NOFP: br %r14
70;
Stephen Lind24ab202013-07-14 06:24:09 +000071; CHECK-FP-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000072; CHECK-FP: lay %r1, 4096(%r11)
73; CHECK-FP: mvhi 4(%r1), 42
74; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +000075 %region1 = alloca [978 x i32], align 8
76 %region2 = alloca [978 x i32], align 8
77 %ptr1 = getelementptr inbounds [978 x i32]* %region1, i64 0, i64 3
78 %ptr2 = getelementptr inbounds [978 x i32]* %region2, i64 0, i64 3
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000079 store volatile i32 42, i32 *%ptr1
80 store volatile i32 42, i32 *%ptr2
81 ret void
82}
83
84; Add 4096 bytes (1024 words) to the size of each object and repeat.
85define void @f4() {
Stephen Lind24ab202013-07-14 06:24:09 +000086; CHECK-NOFP-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000087; CHECK-NOFP: lay %r1, 4096(%r15)
88; CHECK-NOFP: mvhi 4092(%r1), 42
89; CHECK-NOFP: br %r14
90;
Stephen Lind24ab202013-07-14 06:24:09 +000091; CHECK-FP-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000092; CHECK-FP: lay %r1, 4096(%r11)
93; CHECK-FP: mvhi 4092(%r1), 42
94; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +000095 %region1 = alloca [2002 x i32], align 8
96 %region2 = alloca [2002 x i32], align 8
97 %ptr1 = getelementptr inbounds [2002 x i32]* %region1, i64 0, i64 1
98 %ptr2 = getelementptr inbounds [2002 x i32]* %region2, i64 0, i64 1
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000099 store volatile i32 42, i32 *%ptr1
100 store volatile i32 42, i32 *%ptr2
101 ret void
102}
103
104; ...as above.
105define void @f5() {
Stephen Lind24ab202013-07-14 06:24:09 +0000106; CHECK-NOFP-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000107; CHECK-NOFP: lay %r1, 8192(%r15)
108; CHECK-NOFP: mvhi 0(%r1), 42
109; CHECK-NOFP: br %r14
110;
Stephen Lind24ab202013-07-14 06:24:09 +0000111; CHECK-FP-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000112; CHECK-FP: lay %r1, 8192(%r11)
113; CHECK-FP: mvhi 0(%r1), 42
114; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +0000115 %region1 = alloca [2002 x i32], align 8
116 %region2 = alloca [2002 x i32], align 8
117 %ptr1 = getelementptr inbounds [2002 x i32]* %region1, i64 0, i64 2
118 %ptr2 = getelementptr inbounds [2002 x i32]* %region2, i64 0, i64 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000119 store volatile i32 42, i32 *%ptr1
120 store volatile i32 42, i32 *%ptr2
121 ret void
122}
123
124; ...as above.
125define void @f6() {
Stephen Lind24ab202013-07-14 06:24:09 +0000126; CHECK-NOFP-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000127; CHECK-NOFP: lay %r1, 8192(%r15)
128; CHECK-NOFP: mvhi 4(%r1), 42
129; CHECK-NOFP: br %r14
130;
Stephen Lind24ab202013-07-14 06:24:09 +0000131; CHECK-FP-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000132; CHECK-FP: lay %r1, 8192(%r11)
133; CHECK-FP: mvhi 4(%r1), 42
134; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +0000135 %region1 = alloca [2002 x i32], align 8
136 %region2 = alloca [2002 x i32], align 8
137 %ptr1 = getelementptr inbounds [2002 x i32]* %region1, i64 0, i64 3
138 %ptr2 = getelementptr inbounds [2002 x i32]* %region2, i64 0, i64 3
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000139 store volatile i32 42, i32 *%ptr1
140 store volatile i32 42, i32 *%ptr2
141 ret void
142}
143
144; Now try an offset of 4092 from the start of the object, with the object
Richard Sandiford23943222013-07-05 13:11:52 +0000145; being at offset 8192. This time we need objects of (8192 - 176) / 4 = 2004
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000146; words.
147define void @f7() {
Stephen Lind24ab202013-07-14 06:24:09 +0000148; CHECK-NOFP-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000149; CHECK-NOFP: lay %r1, 8192(%r15)
150; CHECK-NOFP: mvhi 4092(%r1), 42
151; CHECK-NOFP: br %r14
152;
Stephen Lind24ab202013-07-14 06:24:09 +0000153; CHECK-FP-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000154; CHECK-FP: lay %r1, 8192(%r11)
155; CHECK-FP: mvhi 4092(%r1), 42
156; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +0000157 %region1 = alloca [2004 x i32], align 8
158 %region2 = alloca [2004 x i32], align 8
159 %ptr1 = getelementptr inbounds [2004 x i32]* %region1, i64 0, i64 1023
160 %ptr2 = getelementptr inbounds [2004 x i32]* %region2, i64 0, i64 1023
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000161 store volatile i32 42, i32 *%ptr1
162 store volatile i32 42, i32 *%ptr2
163 ret void
164}
165
166; Keep the object-relative offset the same but bump the size of the
167; objects by one doubleword.
168define void @f8() {
Stephen Lind24ab202013-07-14 06:24:09 +0000169; CHECK-NOFP-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000170; CHECK-NOFP: lay %r1, 12288(%r15)
171; CHECK-NOFP: mvhi 4(%r1), 42
172; CHECK-NOFP: br %r14
173;
Stephen Lind24ab202013-07-14 06:24:09 +0000174; CHECK-FP-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000175; CHECK-FP: lay %r1, 12288(%r11)
176; CHECK-FP: mvhi 4(%r1), 42
177; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +0000178 %region1 = alloca [2006 x i32], align 8
179 %region2 = alloca [2006 x i32], align 8
180 %ptr1 = getelementptr inbounds [2006 x i32]* %region1, i64 0, i64 1023
181 %ptr2 = getelementptr inbounds [2006 x i32]* %region2, i64 0, i64 1023
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000182 store volatile i32 42, i32 *%ptr1
183 store volatile i32 42, i32 *%ptr2
184 ret void
185}
186
187; Check a case where the original displacement is out of range. The backend
Richard Sandiforda481f582013-08-23 11:18:53 +0000188; should force STY to be used instead.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000189define void @f9() {
Stephen Lind24ab202013-07-14 06:24:09 +0000190; CHECK-NOFP-LABEL: f9:
Richard Sandiforda481f582013-08-23 11:18:53 +0000191; CHECK-NOFP: lhi [[TMP:%r[0-5]]], 42
192; CHECK-NOFP: sty [[TMP]], 12296(%r15)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000193; CHECK-NOFP: br %r14
194;
Stephen Lind24ab202013-07-14 06:24:09 +0000195; CHECK-FP-LABEL: f9:
Richard Sandiforda481f582013-08-23 11:18:53 +0000196; CHECK-FP: lhi [[TMP:%r[0-5]]], 42
197; CHECK-FP: sty [[TMP]], 12296(%r11)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000198; CHECK-FP: br %r14
Richard Sandiford23943222013-07-05 13:11:52 +0000199 %region1 = alloca [2006 x i32], align 8
200 %region2 = alloca [2006 x i32], align 8
201 %ptr1 = getelementptr inbounds [2006 x i32]* %region1, i64 0, i64 1024
202 %ptr2 = getelementptr inbounds [2006 x i32]* %region2, i64 0, i64 1024
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000203 store volatile i32 42, i32 *%ptr1
204 store volatile i32 42, i32 *%ptr2
205 ret void
206}
207
Richard Sandiford23943222013-07-05 13:11:52 +0000208; Repeat f2 in a case that needs the emergency spill slots (because all
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000209; call-clobbered registers are live and no call-saved ones have been
210; allocated).
211define void @f10(i32 *%vptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000212; CHECK-NOFP-LABEL: f10:
Richard Sandiford23943222013-07-05 13:11:52 +0000213; CHECK-NOFP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r15)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000214; CHECK-NOFP: lay [[REGISTER]], 4096(%r15)
215; CHECK-NOFP: mvhi 0([[REGISTER]]), 42
Richard Sandiford23943222013-07-05 13:11:52 +0000216; CHECK-NOFP: lg [[REGISTER]], [[OFFSET]](%r15)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000217; CHECK-NOFP: br %r14
218;
Stephen Lind24ab202013-07-14 06:24:09 +0000219; CHECK-FP-LABEL: f10:
Richard Sandiford23943222013-07-05 13:11:52 +0000220; CHECK-FP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r11)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000221; CHECK-FP: lay [[REGISTER]], 4096(%r11)
222; CHECK-FP: mvhi 0([[REGISTER]]), 42
Richard Sandiford23943222013-07-05 13:11:52 +0000223; CHECK-FP: lg [[REGISTER]], [[OFFSET]](%r11)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000224; CHECK-FP: br %r14
225 %i0 = load volatile i32 *%vptr
226 %i1 = load volatile i32 *%vptr
227 %i3 = load volatile i32 *%vptr
228 %i4 = load volatile i32 *%vptr
229 %i5 = load volatile i32 *%vptr
Richard Sandiford23943222013-07-05 13:11:52 +0000230 %region1 = alloca [978 x i32], align 8
231 %region2 = alloca [978 x i32], align 8
232 %ptr1 = getelementptr inbounds [978 x i32]* %region1, i64 0, i64 2
233 %ptr2 = getelementptr inbounds [978 x i32]* %region2, i64 0, i64 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000234 store volatile i32 42, i32 *%ptr1
235 store volatile i32 42, i32 *%ptr2
236 store volatile i32 %i0, i32 *%vptr
237 store volatile i32 %i1, i32 *%vptr
238 store volatile i32 %i3, i32 *%vptr
239 store volatile i32 %i4, i32 *%vptr
240 store volatile i32 %i5, i32 *%vptr
241 ret void
242}
243
Richard Sandiford23943222013-07-05 13:11:52 +0000244; And again with maximum register pressure. The only spill slots that the
245; NOFP case needs are the emergency ones, so the offsets are the same as for f2.
Richard Sandiford9afe6132013-12-10 10:36:34 +0000246; The FP case needs to spill an extra register and is too dependent on
247; register allocation heuristics for a stable test.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000248define void @f11(i32 *%vptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000249; CHECK-NOFP-LABEL: f11:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000250; CHECK-NOFP: stmg %r6, %r15,
Richard Sandiford23943222013-07-05 13:11:52 +0000251; CHECK-NOFP: stg [[REGISTER:%r[1-9][0-4]?]], [[OFFSET:160|168]](%r15)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000252; CHECK-NOFP: lay [[REGISTER]], 4096(%r15)
253; CHECK-NOFP: mvhi 0([[REGISTER]]), 42
Richard Sandiford23943222013-07-05 13:11:52 +0000254; CHECK-NOFP: lg [[REGISTER]], [[OFFSET]](%r15)
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000255; CHECK-NOFP: lmg %r6, %r15,
256; CHECK-NOFP: br %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000257 %i0 = load volatile i32 *%vptr
258 %i1 = load volatile i32 *%vptr
259 %i3 = load volatile i32 *%vptr
260 %i4 = load volatile i32 *%vptr
261 %i5 = load volatile i32 *%vptr
262 %i6 = load volatile i32 *%vptr
263 %i7 = load volatile i32 *%vptr
264 %i8 = load volatile i32 *%vptr
265 %i9 = load volatile i32 *%vptr
266 %i10 = load volatile i32 *%vptr
267 %i11 = load volatile i32 *%vptr
268 %i12 = load volatile i32 *%vptr
269 %i13 = load volatile i32 *%vptr
270 %i14 = load volatile i32 *%vptr
Richard Sandiford23943222013-07-05 13:11:52 +0000271 %region1 = alloca [978 x i32], align 8
272 %region2 = alloca [978 x i32], align 8
273 %ptr1 = getelementptr inbounds [978 x i32]* %region1, i64 0, i64 2
274 %ptr2 = getelementptr inbounds [978 x i32]* %region2, i64 0, i64 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000275 store volatile i32 42, i32 *%ptr1
276 store volatile i32 42, i32 *%ptr2
277 store volatile i32 %i0, i32 *%vptr
278 store volatile i32 %i1, i32 *%vptr
279 store volatile i32 %i3, i32 *%vptr
280 store volatile i32 %i4, i32 *%vptr
281 store volatile i32 %i5, i32 *%vptr
282 store volatile i32 %i6, i32 *%vptr
283 store volatile i32 %i7, i32 *%vptr
284 store volatile i32 %i8, i32 *%vptr
285 store volatile i32 %i9, i32 *%vptr
286 store volatile i32 %i10, i32 *%vptr
287 store volatile i32 %i11, i32 *%vptr
288 store volatile i32 %i12, i32 *%vptr
289 store volatile i32 %i13, i32 *%vptr
290 store volatile i32 %i14, i32 *%vptr
291 ret void
292}