1# Test cases where MVC is used for spill slots that end up being out of range.
2# RUN: python %s | llc -mtriple=s390x-linux-gnu | FileCheck %s
3
4# There are 8 usable call-saved GPRs, two of which are needed for the base
5# registers.  The first 160 bytes of the frame are needed for the ABI
6# call frame, and a further 8 bytes are needed for the emergency spill slot.
7# That means we will have at least one out-of-range slot if:
8#
9#    count == (4096 - 168) / 8 + 6 + 1 == 498
10#
11# Add in some extra room and check both %r15+4096 (the first out-of-range slot)
12# and %r15+4104.
13#
14# CHECK: f1:
15# CHECK: lay [[REG:%r[0-5]]], 4096(%r15)
16# CHECK: mvc 0(8,[[REG]]), {{[0-9]+}}({{%r[0-9]+}})
17# CHECK: brasl %r14, foo@PLT
18# CHECK: lay [[REG:%r[0-5]]], 4096(%r15)
19# CHECK: mvc {{[0-9]+}}(8,{{%r[0-9]+}}), 8([[REG]])
20# CHECK: br %r14
21
22from __future__ import print_function
23
24count = 500
25
26print('declare void @foo()')
27print('')
28print('define void @f1(i64 *%base0, i64 *%base1) {')
29
30for i in range(count):
31    print('  %%ptr%d = getelementptr i64, i64 *%%base%d, i64 %d' % (i, i % 2, i / 2))
32    print('  %%val%d = load i64 , i64 *%%ptr%d' % (i, i))
33    print('')
34
35print('  call void @foo()')
36print('')
37
38for i in range(count):
39    print('  store i64 %%val%d, i64 *%%ptr%d' % (i, i))
40
41print('')
42print('  ret void')
43print('}')
44