Prepare for PR411
[oota-llvm.git] / test / Transforms / InstCombine / 2007-02-01-LoadSinkAlloca.ll
1 ; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | grep '%A = alloca' &&
2 ; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | not grep '%B = alloca'
3
4 ; Ensure that instcombine doesn't sink the loads in entry/cond_true into 
5 ; cond_next.  Doing so prevents mem2reg from promoting the B alloca.
6
7 define i32 @test2(i32 %C) {
8 entry:
9         %A = alloca i32
10         %B = alloca i32
11         %tmp = call i32 (...)* @bar( i32* %A )          ; <i32> [#uses=0]
12         %T = load i32* %A               ; <i32> [#uses=1]
13         %tmp2 = icmp eq i32 %C, 0               ; <i1> [#uses=1]
14         br i1 %tmp2, label %cond_next, label %cond_true
15
16 cond_true:              ; preds = %entry
17         store i32 123, i32* %B
18         call i32 @test2( i32 123 )              ; <i32>:0 [#uses=0]
19         %T1 = load i32* %B              ; <i32> [#uses=1]
20         br label %cond_next
21
22 cond_next:              ; preds = %cond_true, %entry
23         %tmp1.0 = phi i32 [ %T1, %cond_true ], [ %T, %entry ]           ; <i32> [#uses=1]
24         %tmp7 = call i32 (...)* @baq( )         ; <i32> [#uses=0]
25         %tmp8 = call i32 (...)* @baq( )         ; <i32> [#uses=0]
26         %tmp9 = call i32 (...)* @baq( )         ; <i32> [#uses=0]
27         %tmp10 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
28         %tmp11 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
29         %tmp12 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
30         %tmp13 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
31         %tmp14 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
32         %tmp15 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
33         %tmp16 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
34         %tmp17 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
35         %tmp18 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
36         %tmp19 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
37         %tmp20 = call i32 (...)* @baq( )                ; <i32> [#uses=0]
38         ret i32 %tmp1.0
39 }
40
41 declare i32 @bar(...)
42
43 declare i32 @baq(...)