blob: 14288deb435c6050b3d36e8ab1931bfed69e7951 [file] [log] [blame]
Akira Hatanaka33ff5ae2011-09-09 23:14:58 +00001; RUN: llc -march=mipsel < %s | FileCheck %s
Akira Hatanaka053546c2011-05-25 02:20:00 +00002
3define i32 @twoalloca(i32 %size) nounwind {
4entry:
5; CHECK: subu $[[T0:[0-9]+]], $sp, $[[SZ:[0-9]+]]
6; CHECK: addu $sp, $zero, $[[T0]]
Akira Hatanaka21afc632011-06-21 00:40:49 +00007; CHECK: addiu $[[T1:[0-9]+]], $sp, [[OFF:[0-9]+]]
8; CHECK: subu $[[T2:[0-9]+]], $sp, $[[SZ]]
9; CHECK: addu $sp, $zero, $[[T2]]
10; CHECK: addiu $[[T3:[0-9]+]], $sp, [[OFF]]
Akira Hatanaka1da1cdf2012-05-12 03:25:16 +000011; CHECK: lw $[[T4:[0-9]+]], %call16(foo)
Akira Hatanaka25eba392011-06-24 19:01:25 +000012; CHECK: addu $25, $zero, $[[T4]]
13; CHECK: addu $4, $zero, $[[T1]]
Akira Hatanaka053546c2011-05-25 02:20:00 +000014; CHECK: jalr $25
15 %tmp1 = alloca i8, i32 %size, align 4
16 %add.ptr = getelementptr inbounds i8* %tmp1, i32 5
17 store i8 97, i8* %add.ptr, align 1
18 %tmp4 = alloca i8, i32 %size, align 4
19 call void @foo2(double 1.000000e+00, double 2.000000e+00, i32 3) nounwind
20 %call = call i32 @foo(i8* %tmp1) nounwind
21 %call7 = call i32 @foo(i8* %tmp4) nounwind
22 %add = add nsw i32 %call7, %call
23 ret i32 %add
24}
25
26declare void @foo2(double, double, i32)
27
28declare i32 @foo(i8*)
29
Akira Hatanaka21afc632011-06-21 00:40:49 +000030@.str = private unnamed_addr constant [22 x i8] c"%d %d %d %d %d %d %d\0A\00", align 1
31
32define i32 @alloca2(i32 %size) nounwind {
33entry:
Akira Hatanaka21afc632011-06-21 00:40:49 +000034; CHECK: alloca2
Akira Hatanaka1da1cdf2012-05-12 03:25:16 +000035; CHECK: subu $[[T0:[0-9]+]], $sp
Akira Hatanaka21afc632011-06-21 00:40:49 +000036; CHECK: addu $sp, $zero, $[[T0]]
Akira Hatanaka1da1cdf2012-05-12 03:25:16 +000037; CHECK: addiu $[[T1:[0-9]+]], $sp
Akira Hatanaka21afc632011-06-21 00:40:49 +000038
39 %tmp1 = alloca i8, i32 %size, align 4
40 %0 = bitcast i8* %tmp1 to i32*
41 %cmp = icmp sgt i32 %size, 10
42 br i1 %cmp, label %if.then, label %if.else
43
44if.then: ; preds = %entry
45; CHECK: addiu $4, $[[T1]], 40
46
47 %add.ptr = getelementptr inbounds i8* %tmp1, i32 40
48 %1 = bitcast i8* %add.ptr to i32*
49 call void @foo3(i32* %1) nounwind
50 %arrayidx15.pre = getelementptr inbounds i8* %tmp1, i32 12
51 %.pre = bitcast i8* %arrayidx15.pre to i32*
52 br label %if.end
53
54if.else: ; preds = %entry
55; CHECK: addiu $4, $[[T1]], 12
56
57 %add.ptr5 = getelementptr inbounds i8* %tmp1, i32 12
58 %2 = bitcast i8* %add.ptr5 to i32*
59 call void @foo3(i32* %2) nounwind
60 br label %if.end
61
62if.end: ; preds = %if.else, %if.then
63; CHECK: lw $5, 0($[[T1]])
64; CHECK: lw $25, %call16(printf)
65
66 %.pre-phi = phi i32* [ %2, %if.else ], [ %.pre, %if.then ]
67 %tmp7 = load i32* %0, align 4, !tbaa !0
68 %arrayidx9 = getelementptr inbounds i8* %tmp1, i32 4
69 %3 = bitcast i8* %arrayidx9 to i32*
70 %tmp10 = load i32* %3, align 4, !tbaa !0
71 %arrayidx12 = getelementptr inbounds i8* %tmp1, i32 8
72 %4 = bitcast i8* %arrayidx12 to i32*
73 %tmp13 = load i32* %4, align 4, !tbaa !0
74 %tmp16 = load i32* %.pre-phi, align 4, !tbaa !0
75 %arrayidx18 = getelementptr inbounds i8* %tmp1, i32 16
76 %5 = bitcast i8* %arrayidx18 to i32*
77 %tmp19 = load i32* %5, align 4, !tbaa !0
78 %arrayidx21 = getelementptr inbounds i8* %tmp1, i32 20
79 %6 = bitcast i8* %arrayidx21 to i32*
80 %tmp22 = load i32* %6, align 4, !tbaa !0
81 %arrayidx24 = getelementptr inbounds i8* %tmp1, i32 24
82 %7 = bitcast i8* %arrayidx24 to i32*
83 %tmp25 = load i32* %7, align 4, !tbaa !0
84 %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([22 x i8]* @.str, i32 0, i32 0), i32 %tmp7, i32 %tmp10, i32 %tmp13, i32 %tmp16, i32 %tmp19, i32 %tmp22, i32 %tmp25) nounwind
85 ret i32 0
86}
87
88declare void @foo3(i32*)
89
90declare i32 @printf(i8* nocapture, ...) nounwind
91
92!0 = metadata !{metadata !"int", metadata !1}
93!1 = metadata !{metadata !"omnipotent char", metadata !2}
94!2 = metadata !{metadata !"Simple C/C++ TBAA", null}