1; RUN: opt < %s -inline -S | FileCheck %s
2; RUN: opt < %s -passes='cgscc(inline)' -S | FileCheck %s
3; Test that bar and bar2 are both inlined throughout and removed.
4@A = weak global i32 0		; <i32*> [#uses=1]
5@B = weak global i32 0		; <i32*> [#uses=1]
6@C = weak global i32 0		; <i32*> [#uses=1]
7
8define fastcc void @foo(i32 %X) {
9entry:
10; CHECK-LABEL: @foo(
11	%ALL = alloca i32, align 4		; <i32*> [#uses=1]
12	%tmp1 = and i32 %X, 1		; <i32> [#uses=1]
13	%tmp1.upgrd.1 = icmp eq i32 %tmp1, 0		; <i1> [#uses=1]
14	br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true
15
16cond_true:		; preds = %entry
17	store i32 1, i32* @A
18	br label %cond_next
19
20cond_next:		; preds = %cond_true, %entry
21	%tmp4 = and i32 %X, 2		; <i32> [#uses=1]
22	%tmp4.upgrd.2 = icmp eq i32 %tmp4, 0		; <i1> [#uses=1]
23	br i1 %tmp4.upgrd.2, label %cond_next7, label %cond_true5
24
25cond_true5:		; preds = %cond_next
26	store i32 1, i32* @B
27	br label %cond_next7
28
29cond_next7:		; preds = %cond_true5, %cond_next
30	%tmp10 = and i32 %X, 4		; <i32> [#uses=1]
31	%tmp10.upgrd.3 = icmp eq i32 %tmp10, 0		; <i1> [#uses=1]
32	br i1 %tmp10.upgrd.3, label %cond_next13, label %cond_true11
33
34cond_true11:		; preds = %cond_next7
35	store i32 1, i32* @C
36	br label %cond_next13
37
38cond_next13:		; preds = %cond_true11, %cond_next7
39	%tmp16 = and i32 %X, 8		; <i32> [#uses=1]
40	%tmp16.upgrd.4 = icmp eq i32 %tmp16, 0		; <i1> [#uses=1]
41	br i1 %tmp16.upgrd.4, label %UnifiedReturnBlock, label %cond_true17
42
43cond_true17:		; preds = %cond_next13
44	call void @ext( i32* %ALL )
45	ret void
46
47UnifiedReturnBlock:		; preds = %cond_next13
48	ret void
49}
50
51; CHECK-NOT: @bar(
52define internal fastcc void @bar(i32 %X) {
53entry:
54	%ALL = alloca i32, align 4		; <i32*> [#uses=1]
55	%tmp1 = and i32 %X, 1		; <i32> [#uses=1]
56	%tmp1.upgrd.1 = icmp eq i32 %tmp1, 0		; <i1> [#uses=1]
57	br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true
58
59cond_true:		; preds = %entry
60	store i32 1, i32* @A
61	br label %cond_next
62
63cond_next:		; preds = %cond_true, %entry
64	%tmp4 = and i32 %X, 2		; <i32> [#uses=1]
65	%tmp4.upgrd.2 = icmp eq i32 %tmp4, 0		; <i1> [#uses=1]
66	br i1 %tmp4.upgrd.2, label %cond_next7, label %cond_true5
67
68cond_true5:		; preds = %cond_next
69	store i32 1, i32* @B
70	br label %cond_next7
71
72cond_next7:		; preds = %cond_true5, %cond_next
73	%tmp10 = and i32 %X, 4		; <i32> [#uses=1]
74	%tmp10.upgrd.3 = icmp eq i32 %tmp10, 0		; <i1> [#uses=1]
75	br i1 %tmp10.upgrd.3, label %cond_next13, label %cond_true11
76
77cond_true11:		; preds = %cond_next7
78	store i32 1, i32* @C
79	br label %cond_next13
80
81cond_next13:		; preds = %cond_true11, %cond_next7
82	%tmp16 = and i32 %X, 8		; <i32> [#uses=1]
83	%tmp16.upgrd.4 = icmp eq i32 %tmp16, 0		; <i1> [#uses=1]
84	br i1 %tmp16.upgrd.4, label %UnifiedReturnBlock, label %cond_true17
85
86cond_true17:		; preds = %cond_next13
87	call void @foo( i32 %X )
88	ret void
89
90UnifiedReturnBlock:		; preds = %cond_next13
91	ret void
92}
93
94define internal fastcc void @bar2(i32 %X) {
95entry:
96	call void @foo( i32 %X )
97	ret void
98}
99
100declare void @ext(i32*)
101
102define void @test(i32 %X) {
103entry:
104; CHECK: test
105; CHECK-NOT: @bar(
106	tail call fastcc void @bar( i32 %X )
107	tail call fastcc void @bar( i32 %X )
108	tail call fastcc void @bar2( i32 %X )
109	tail call fastcc void @bar2( i32 %X )
110	ret void
111; CHECK: ret
112}
113