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 | d0e30dc | 2006-12-02 04:23:10 +0000 | [diff] [blame] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline -disable-output && |
| 5 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | not grep 'alloca.*uses=0' && |
| 6 | ; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | not grep 'br label' |
Chris Lattner | 73eedf0 | 2006-09-13 19:23:43 +0000 | [diff] [blame] | 7 | |
| 8 | %A = weak global int 0 ; <int*> [#uses=1] |
| 9 | %B = weak global int 0 ; <int*> [#uses=1] |
| 10 | %C = weak global int 0 ; <int*> [#uses=1] |
| 11 | |
| 12 | implementation ; Functions: |
| 13 | |
| 14 | internal fastcc void %foo(int %X) { |
| 15 | entry: |
| 16 | %ALL = alloca int, align 4 ; <int*> [#uses=1] |
| 17 | %tmp1 = and int %X, 1 ; <int> [#uses=1] |
| 18 | %tmp1 = seteq int %tmp1, 0 ; <bool> [#uses=1] |
| 19 | br bool %tmp1, label %cond_next, label %cond_true |
| 20 | |
| 21 | cond_true: ; preds = %entry |
| 22 | store int 1, int* %A |
| 23 | br label %cond_next |
| 24 | |
| 25 | cond_next: ; preds = %entry, %cond_true |
| 26 | %tmp4 = and int %X, 2 ; <int> [#uses=1] |
| 27 | %tmp4 = seteq int %tmp4, 0 ; <bool> [#uses=1] |
| 28 | br bool %tmp4, label %cond_next7, label %cond_true5 |
| 29 | |
| 30 | cond_true5: ; preds = %cond_next |
| 31 | store int 1, int* %B |
| 32 | br label %cond_next7 |
| 33 | |
| 34 | cond_next7: ; preds = %cond_next, %cond_true5 |
| 35 | %tmp10 = and int %X, 4 ; <int> [#uses=1] |
| 36 | %tmp10 = seteq int %tmp10, 0 ; <bool> [#uses=1] |
| 37 | br bool %tmp10, label %cond_next13, label %cond_true11 |
| 38 | |
| 39 | cond_true11: ; preds = %cond_next7 |
| 40 | store int 1, int* %C |
| 41 | br label %cond_next13 |
| 42 | |
| 43 | cond_next13: ; preds = %cond_next7, %cond_true11 |
| 44 | %tmp16 = and int %X, 8 ; <int> [#uses=1] |
| 45 | %tmp16 = seteq int %tmp16, 0 ; <bool> [#uses=1] |
| 46 | br bool %tmp16, label %UnifiedReturnBlock, label %cond_true17 |
| 47 | |
| 48 | cond_true17: ; preds = %cond_next13 |
| 49 | call void %ext( int* %ALL ) |
| 50 | ret void |
| 51 | |
| 52 | UnifiedReturnBlock: ; preds = %cond_next13 |
| 53 | ret void |
| 54 | } |
| 55 | |
| 56 | declare void %ext(int*) |
| 57 | |
| 58 | void %test() { |
| 59 | entry: |
| 60 | tail call fastcc void %foo( int 1 ) |
| 61 | tail call fastcc void %foo( int 2 ) |
| 62 | tail call fastcc void %foo( int 3 ) |
| 63 | tail call fastcc void %foo( int 8 ) |
| 64 | ret void |
| 65 | } |