1; RUN: llc -march=mipsel -O0 -relocation-model=pic < %s | FileCheck %s
2; Check that register scavenging spill slot is close to $fp.
3target triple="mipsel--"
4
5@var = external global i32
6@ptrvar = external global i8*
7
8; CHECK-LABEL: func:
9define void @func() {
10  %space = alloca i32, align 4
11  %stackspace = alloca[16384 x i32], align 4
12
13  ; ensure stackspace is not optimized out
14  %stackspace_casted = bitcast [16384 x i32]* %stackspace to i8*
15  store volatile i8* %stackspace_casted, i8** @ptrvar
16
17  ; Load values to increase register pressure.
18  %v0 = load volatile i32, i32* @var
19  %v1 = load volatile i32, i32* @var
20  %v2 = load volatile i32, i32* @var
21  %v3 = load volatile i32, i32* @var
22  %v4 = load volatile i32, i32* @var
23  %v5 = load volatile i32, i32* @var
24  %v6 = load volatile i32, i32* @var
25  %v7 = load volatile i32, i32* @var
26  %v8 = load volatile i32, i32* @var
27  %v9 = load volatile i32, i32* @var
28  %v10 = load volatile i32, i32* @var
29  %v11 = load volatile i32, i32* @var
30  %v12 = load volatile i32, i32* @var
31  %v13 = load volatile i32, i32* @var
32  %v14 = load volatile i32, i32* @var
33  %v15 = load volatile i32, i32* @var
34  %v16 = load volatile i32, i32* @var
35
36  ; Computing a stack-relative values needs an additional register.
37  ; We should get an emergency spill/reload for this.
38  ; CHECK: sw ${{.*}}, 0($sp)
39  ; CHECK: lw ${{.*}}, 0($sp)
40  store volatile i32 %v0, i32* %space
41
42  ; store values so they are used.
43  store volatile i32 %v0, i32* @var
44  store volatile i32 %v1, i32* @var
45  store volatile i32 %v2, i32* @var
46  store volatile i32 %v3, i32* @var
47  store volatile i32 %v4, i32* @var
48  store volatile i32 %v5, i32* @var
49  store volatile i32 %v6, i32* @var
50  store volatile i32 %v7, i32* @var
51  store volatile i32 %v8, i32* @var
52  store volatile i32 %v9, i32* @var
53  store volatile i32 %v10, i32* @var
54  store volatile i32 %v11, i32* @var
55  store volatile i32 %v12, i32* @var
56  store volatile i32 %v13, i32* @var
57  store volatile i32 %v14, i32* @var
58  store volatile i32 %v15, i32* @var
59  store volatile i32 %v16, i32* @var
60
61  ret void
62}
63