1 ; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=16
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
13 define void @calc_z() nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" {
15 %0 = load i32, ptr @a, align 4
16 %cmp = icmp ne i32 %0, 1
17 br i1 %cmp, label %cond.true, label %cond.false
19 cond.true: ; preds = %entry
20 %1 = load i32, ptr @f, align 4
23 cond.false: ; preds = %entry
24 %2 = load i32, ptr @t, align 4
27 cond.end: ; preds = %cond.false, %cond.true
28 %cond = phi i32 [ %1, %cond.true ], [ %2, %cond.false ]
29 store i32 %cond, ptr @z1, align 4
30 %3 = load i32, ptr @a, align 4
31 %cmp1 = icmp ne i32 %3, 1000
32 br i1 %cmp1, label %cond.true2, label %cond.false3
34 cond.true2: ; preds = %cond.end
35 %4 = load i32, ptr @t, align 4
38 cond.false3: ; preds = %cond.end
39 %5 = load i32, ptr @f, align 4
42 cond.end4: ; preds = %cond.false3, %cond.true2
43 %cond5 = phi i32 [ %4, %cond.true2 ], [ %5, %cond.false3 ]
44 store i32 %cond5, ptr @z2, align 4
45 %6 = load i32, ptr @b, align 4
46 %cmp6 = icmp ne i32 %6, 3
47 br i1 %cmp6, label %cond.true7, label %cond.false8
49 cond.true7: ; preds = %cond.end4
50 %7 = load i32, ptr @t, align 4
53 cond.false8: ; preds = %cond.end4
54 %8 = load i32, ptr @f, align 4
57 cond.end9: ; preds = %cond.false8, %cond.true7
58 %cond10 = phi i32 [ %7, %cond.true7 ], [ %8, %cond.false8 ]
59 store i32 %cond10, ptr @z3, align 4
60 %9 = load i32, ptr @b, align 4
61 %cmp11 = icmp ne i32 %9, 1000
62 br i1 %cmp11, label %cond.true12, label %cond.false13
64 cond.true12: ; preds = %cond.end9
65 %10 = load i32, ptr @f, align 4
68 cond.false13: ; preds = %cond.end9
69 %11 = load i32, ptr @t, align 4
72 cond.end14: ; preds = %cond.false13, %cond.true12
73 %cond15 = phi i32 [ %10, %cond.true12 ], [ %11, %cond.false13 ]
74 store i32 %cond15, ptr @z4, align 4
78 define i32 @main() nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" {
80 call void @calc_z() "target-cpu"="mips16" "target-features"="+mips16,+o32"
81 %0 = load i32, ptr @z1, align 4
82 %call = call i32 (ptr, ...) @printf(ptr @.str, i32 %0) "target-cpu"="mips16" "target-features"="+mips16,+o32"
83 %1 = load i32, ptr @z2, align 4
84 %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %1) "target-cpu"="mips16" "target-features"="+mips16,+o32"
85 %2 = load i32, ptr @z3, align 4
86 %call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %2) "target-cpu"="mips16" "target-features"="+mips16,+o32"
87 %3 = load i32, ptr @z4, align 4
88 %call3 = call i32 (ptr, ...) @printf(ptr @.str, i32 %3) "target-cpu"="mips16" "target-features"="+mips16,+o32"
92 declare i32 @printf(ptr, ...) "target-cpu"="mips16" "target-features"="+mips16,+o32"
94 attributes #0 = { nounwind "target-cpu"="mips16" "target-features"="+mips16,+o32" }
95 attributes #1 = { "target-cpu"="mips16" "target-features"="+mips16,+o32" }
97 ; 16: cmpi ${{[0-9]+}}, 1 # 16 bit inst
98 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
100 ; 16: cmpi ${{[0-9]+}}, 1000
101 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
103 ; 16: cmpi ${{[0-9]+}}, 3 # 16 bit inst
104 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}
106 ; 16: cmpi ${{[0-9]+}}, 1000
107 ; 16: bteqz $BB{{[0-9]+}}_{{[0-9]}}