Chris Lattner | 73eedf0 | 2006-09-13 19:23:43 +0000 | [diff] [blame] | 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 | |
Reid Spencer | 951d8dc | 2007-04-15 08:30:33 +0000 | [diff] [blame] | 4 | ; 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 Lattner | 73eedf0 | 2006-09-13 19:23:43 +0000 | [diff] [blame] | 8 | |
| 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 | |
| 13 | implementation ; Functions: |
| 14 | |
| 15 | internal fastcc void %foo(int %X) { |
| 16 | entry: |
| 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 | |
| 22 | cond_true: ; preds = %entry |
| 23 | store int 1, int* %A |
| 24 | br label %cond_next |
| 25 | |
| 26 | cond_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 | |
| 31 | cond_true5: ; preds = %cond_next |
| 32 | store int 1, int* %B |
| 33 | br label %cond_next7 |
| 34 | |
| 35 | cond_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 | |
| 40 | cond_true11: ; preds = %cond_next7 |
| 41 | store int 1, int* %C |
| 42 | br label %cond_next13 |
| 43 | |
| 44 | cond_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 | |
| 49 | cond_true17: ; preds = %cond_next13 |
| 50 | call void %ext( int* %ALL ) |
| 51 | ret void |
| 52 | |
| 53 | UnifiedReturnBlock: ; preds = %cond_next13 |
| 54 | ret void |
| 55 | } |
| 56 | |
| 57 | declare void %ext(int*) |
| 58 | |
| 59 | void %test() { |
| 60 | entry: |
| 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 | } |