1; RUN: llc  -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
2
3@iiii = global i32 25, align 4
4@jjjj = global i32 35, align 4
5@kkkk = global i32 100, align 4
6@t = global i32 25, align 4
7@riii = common global i32 0, align 4
8@rjjj = common global i32 0, align 4
9@rkkk = common global i32 0, align 4
10
11define void @temp(i32 %foo) nounwind {
12entry:
13  %foo.addr = alloca i32, align 4
14  store i32 %foo, i32* %foo.addr, align 4
15  %0 = load i32, i32* %foo.addr, align 4
16  store i32 %0, i32* @t, align 4
17  ret void
18}
19
20define void @test() nounwind {
21entry:
22; 16: 	.frame	$sp,8,$ra
23; 16: 	save 	8 # 16 bit inst
24; 16: 	move	$16, $sp
25; 16:	move	${{[0-9]+}}, $sp
26; 16:	subu	$[[REGISTER:[0-9]+]], ${{[0-9]+}}, ${{[0-9]+}}
27; 16:	move	$sp, $[[REGISTER]]
28  %sssi = alloca i32, align 4
29  %ip = alloca i32*, align 4
30  %sssj = alloca i32, align 4
31  %0 = load i32, i32* @iiii, align 4
32  store i32 %0, i32* %sssi, align 4
33  %1 = load i32, i32* @kkkk, align 4
34  %mul = mul nsw i32 %1, 100
35  %2 = alloca i8, i32 %mul
36  %3 = bitcast i8* %2 to i32*
37  store i32* %3, i32** %ip, align 4
38  %4 = load i32, i32* @jjjj, align 4
39  store i32 %4, i32* %sssj, align 4
40  %5 = load i32, i32* @jjjj, align 4
41  %6 = load i32, i32* @iiii, align 4
42  %7 = load i32*, i32** %ip, align 4
43  %arrayidx = getelementptr inbounds i32, i32* %7, i32 %6
44  store i32 %5, i32* %arrayidx, align 4
45  %8 = load i32, i32* @kkkk, align 4
46  %9 = load i32, i32* @jjjj, align 4
47  %10 = load i32*, i32** %ip, align 4
48  %arrayidx1 = getelementptr inbounds i32, i32* %10, i32 %9
49  store i32 %8, i32* %arrayidx1, align 4
50  %11 = load i32, i32* @iiii, align 4
51  %12 = load i32, i32* @kkkk, align 4
52  %13 = load i32*, i32** %ip, align 4
53  %arrayidx2 = getelementptr inbounds i32, i32* %13, i32 %12
54  store i32 %11, i32* %arrayidx2, align 4
55  %14 = load i32*, i32** %ip, align 4
56  %arrayidx3 = getelementptr inbounds i32, i32* %14, i32 25
57  %15 = load i32, i32* %arrayidx3, align 4
58  store i32 %15, i32* @riii, align 4
59  %16 = load i32*, i32** %ip, align 4
60  %arrayidx4 = getelementptr inbounds i32, i32* %16, i32 35
61  %17 = load i32, i32* %arrayidx4, align 4
62  store i32 %17, i32* @rjjj, align 4
63  %18 = load i32*, i32** %ip, align 4
64  %arrayidx5 = getelementptr inbounds i32, i32* %18, i32 100
65  %19 = load i32, i32* %arrayidx5, align 4
66  store i32 %19, i32* @rkkk, align 4
67  %20 = load i32, i32* @t, align 4
68  %21 = load i32*, i32** %ip, align 4
69  %arrayidx6 = getelementptr inbounds i32, i32* %21, i32 %20
70  %22 = load i32, i32* %arrayidx6, align 4
71; 16: 	addiu $sp, -16
72  call void @temp(i32 %22)
73; 16: 	addiu $sp, 16
74  ret void
75}
76