blob: 2ec67ff5c44c27f6a83d41994f7b0a9c172b4428 [file] [log] [blame]
Chris Lattner73eedf02006-09-13 19:23:43 +00001; Test that the inliner doesn't leave around dead allocas, and that it folds
2; uncond branches away after it is done specializing.
3
Reid Spencer951d8dc2007-04-15 08:30:33 +00004; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | \
5; RUN: not grep {alloca.*uses=0}
6; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | \
7; RUN: not grep {br label}
Chris Lattner73eedf02006-09-13 19:23:43 +00008
9%A = weak global int 0 ; <int*> [#uses=1]
10%B = weak global int 0 ; <int*> [#uses=1]
11%C = weak global int 0 ; <int*> [#uses=1]
12
13implementation ; Functions:
14
15internal fastcc void %foo(int %X) {
16entry:
17 %ALL = alloca int, align 4 ; <int*> [#uses=1]
18 %tmp1 = and int %X, 1 ; <int> [#uses=1]
19 %tmp1 = seteq int %tmp1, 0 ; <bool> [#uses=1]
20 br bool %tmp1, label %cond_next, label %cond_true
21
22cond_true: ; preds = %entry
23 store int 1, int* %A
24 br label %cond_next
25
26cond_next: ; preds = %entry, %cond_true
27 %tmp4 = and int %X, 2 ; <int> [#uses=1]
28 %tmp4 = seteq int %tmp4, 0 ; <bool> [#uses=1]
29 br bool %tmp4, label %cond_next7, label %cond_true5
30
31cond_true5: ; preds = %cond_next
32 store int 1, int* %B
33 br label %cond_next7
34
35cond_next7: ; preds = %cond_next, %cond_true5
36 %tmp10 = and int %X, 4 ; <int> [#uses=1]
37 %tmp10 = seteq int %tmp10, 0 ; <bool> [#uses=1]
38 br bool %tmp10, label %cond_next13, label %cond_true11
39
40cond_true11: ; preds = %cond_next7
41 store int 1, int* %C
42 br label %cond_next13
43
44cond_next13: ; preds = %cond_next7, %cond_true11
45 %tmp16 = and int %X, 8 ; <int> [#uses=1]
46 %tmp16 = seteq int %tmp16, 0 ; <bool> [#uses=1]
47 br bool %tmp16, label %UnifiedReturnBlock, label %cond_true17
48
49cond_true17: ; preds = %cond_next13
50 call void %ext( int* %ALL )
51 ret void
52
53UnifiedReturnBlock: ; preds = %cond_next13
54 ret void
55}
56
57declare void %ext(int*)
58
59void %test() {
60entry:
61 tail call fastcc void %foo( int 1 )
62 tail call fastcc void %foo( int 2 )
63 tail call fastcc void %foo( int 3 )
64 tail call fastcc void %foo( int 8 )
65 ret void
66}