• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test that the inliner doesn't leave around dead allocas, and that it folds
2; uncond branches away after it is done specializing.
3
4; RUN: opt < %s -inline -S | \
5; RUN:    not grep {alloca.*uses=0}
6; RUN: opt < %s -inline -S | \
7; RUN:    not grep {br label}
8@A = weak global i32 0		; <i32*> [#uses=1]
9@B = weak global i32 0		; <i32*> [#uses=1]
10@C = weak global i32 0		; <i32*> [#uses=1]
11
12define internal fastcc void @foo(i32 %X) {
13entry:
14	%ALL = alloca i32, align 4		; <i32*> [#uses=1]
15	%tmp1 = and i32 %X, 1		; <i32> [#uses=1]
16	%tmp1.upgrd.1 = icmp eq i32 %tmp1, 0		; <i1> [#uses=1]
17	br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true
18
19cond_true:		; preds = %entry
20	store i32 1, i32* @A
21	br label %cond_next
22
23cond_next:		; preds = %cond_true, %entry
24	%tmp4 = and i32 %X, 2		; <i32> [#uses=1]
25	%tmp4.upgrd.2 = icmp eq i32 %tmp4, 0		; <i1> [#uses=1]
26	br i1 %tmp4.upgrd.2, label %cond_next7, label %cond_true5
27
28cond_true5:		; preds = %cond_next
29	store i32 1, i32* @B
30	br label %cond_next7
31
32cond_next7:		; preds = %cond_true5, %cond_next
33	%tmp10 = and i32 %X, 4		; <i32> [#uses=1]
34	%tmp10.upgrd.3 = icmp eq i32 %tmp10, 0		; <i1> [#uses=1]
35	br i1 %tmp10.upgrd.3, label %cond_next13, label %cond_true11
36
37cond_true11:		; preds = %cond_next7
38	store i32 1, i32* @C
39	br label %cond_next13
40
41cond_next13:		; preds = %cond_true11, %cond_next7
42	%tmp16 = and i32 %X, 8		; <i32> [#uses=1]
43	%tmp16.upgrd.4 = icmp eq i32 %tmp16, 0		; <i1> [#uses=1]
44	br i1 %tmp16.upgrd.4, label %UnifiedReturnBlock, label %cond_true17
45
46cond_true17:		; preds = %cond_next13
47	call void @ext( i32* %ALL )
48	ret void
49
50UnifiedReturnBlock:		; preds = %cond_next13
51	ret void
52}
53
54declare void @ext(i32*)
55
56define void @test() {
57entry:
58	tail call fastcc void @foo( i32 1 )
59	tail call fastcc void @foo( i32 2 )
60	tail call fastcc void @foo( i32 3 )
61	tail call fastcc void @foo( i32 8 )
62	ret void
63}
64