blob: 13ab693adb8b12dea4b5268bdac9627247c49211 [file] [log] [blame]
Daniel Sanders8008de52015-10-15 14:34:23 +00001; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=16
Reed Kotlerd8217192013-02-19 00:20:58 +00002
3@t = global i32 10, align 4
4@f = global i32 199, align 4
5@a = global i32 1, align 4
6@b = global i32 1000, align 4
7@z1 = common global i32 0, align 4
8@z2 = common global i32 0, align 4
9@z3 = common global i32 0, align 4
10@z4 = common global i32 0, align 4
11@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
12
13define void @calc_z() nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" {
14entry:
David Blaikiea79ac142015-02-27 21:17:42 +000015 %0 = load i32, i32* @a, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000016 %cmp = icmp ne i32 %0, 1
17 br i1 %cmp, label %cond.true, label %cond.false
18
19cond.true: ; preds = %entry
David Blaikiea79ac142015-02-27 21:17:42 +000020 %1 = load i32, i32* @f, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000021 br label %cond.end
22
23cond.false: ; preds = %entry
David Blaikiea79ac142015-02-27 21:17:42 +000024 %2 = load i32, i32* @t, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000025 br label %cond.end
26
27cond.end: ; preds = %cond.false, %cond.true
28 %cond = phi i32 [ %1, %cond.true ], [ %2, %cond.false ]
29 store i32 %cond, i32* @z1, align 4
David Blaikiea79ac142015-02-27 21:17:42 +000030 %3 = load i32, i32* @a, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000031 %cmp1 = icmp ne i32 %3, 1000
32 br i1 %cmp1, label %cond.true2, label %cond.false3
33
34cond.true2: ; preds = %cond.end
David Blaikiea79ac142015-02-27 21:17:42 +000035 %4 = load i32, i32* @t, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000036 br label %cond.end4
37
38cond.false3: ; preds = %cond.end
David Blaikiea79ac142015-02-27 21:17:42 +000039 %5 = load i32, i32* @f, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000040 br label %cond.end4
41
42cond.end4: ; preds = %cond.false3, %cond.true2
43 %cond5 = phi i32 [ %4, %cond.true2 ], [ %5, %cond.false3 ]
44 store i32 %cond5, i32* @z2, align 4
David Blaikiea79ac142015-02-27 21:17:42 +000045 %6 = load i32, i32* @b, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000046 %cmp6 = icmp ne i32 %6, 3
47 br i1 %cmp6, label %cond.true7, label %cond.false8
48
49cond.true7: ; preds = %cond.end4
David Blaikiea79ac142015-02-27 21:17:42 +000050 %7 = load i32, i32* @t, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000051 br label %cond.end9
52
53cond.false8: ; preds = %cond.end4
David Blaikiea79ac142015-02-27 21:17:42 +000054 %8 = load i32, i32* @f, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000055 br label %cond.end9
56
57cond.end9: ; preds = %cond.false8, %cond.true7
58 %cond10 = phi i32 [ %7, %cond.true7 ], [ %8, %cond.false8 ]
59 store i32 %cond10, i32* @z3, align 4
David Blaikiea79ac142015-02-27 21:17:42 +000060 %9 = load i32, i32* @b, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000061 %cmp11 = icmp ne i32 %9, 1000
62 br i1 %cmp11, label %cond.true12, label %cond.false13
63
64cond.true12: ; preds = %cond.end9
David Blaikiea79ac142015-02-27 21:17:42 +000065 %10 = load i32, i32* @f, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000066 br label %cond.end14
67
68cond.false13: ; preds = %cond.end9
David Blaikiea79ac142015-02-27 21:17:42 +000069 %11 = load i32, i32* @t, align 4
Reed Kotlerd8217192013-02-19 00:20:58 +000070 br label %cond.end14
71
72cond.end14: ; preds = %cond.false13, %cond.true12
73 %cond15 = phi i32 [ %10, %cond.true12 ], [ %11, %cond.false13 ]
74 store i32 %cond15, i32* @z4, align 4
75 ret void
76}
77
78define i32 @main() nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" {
79entry:
80 call void @calc_z() "target-cpu"="mips16" "target-features"="+mips16,+o32"
David Blaikiea79ac142015-02-27 21:17:42 +000081 %0 = load i32, i32* @z1, align 4
David Blaikie23af6482015-04-16 23:24:18 +000082 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 %0) "target-cpu"="mips16" "target-features"="+mips16,+o32"
David Blaikiea79ac142015-02-27 21:17:42 +000083 %1 = load i32, i32* @z2, align 4
David Blaikie23af6482015-04-16 23:24:18 +000084 %call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 %1) "target-cpu"="mips16" "target-features"="+mips16,+o32"
David Blaikiea79ac142015-02-27 21:17:42 +000085 %2 = load i32, i32* @z3, align 4
David Blaikie23af6482015-04-16 23:24:18 +000086 %call2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 %2) "target-cpu"="mips16" "target-features"="+mips16,+o32"
David Blaikiea79ac142015-02-27 21:17:42 +000087 %3 = load i32, i32* @z4, align 4
David Blaikie23af6482015-04-16 23:24:18 +000088 %call3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 %3) "target-cpu"="mips16" "target-features"="+mips16,+o32"
Reed Kotlerd8217192013-02-19 00:20:58 +000089 ret i32 0
90}
91
92declare i32 @printf(i8*, ...) "target-cpu"="mips16" "target-features"="+mips16,+o32"
93
94attributes #0 = { nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" }
95attributes #1 = { "target-cpu"="mips16" "target-features"="+mips16,+o32" }
96
97; 16: cmpi ${{[0-9]+}}, 1 # 16 bit inst
98; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
99
100; 16: cmpi ${{[0-9]+}}, 1000
101; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
102
103; 16: cmpi ${{[0-9]+}}, 3 # 16 bit inst
104; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
105
106; 16: cmpi ${{[0-9]+}}, 1000
Stephen Linf799e3f2013-07-13 20:38:47 +0000107; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}