Model stacksave and stackrestore as both writing memory, since we
[oota-llvm.git] / test / Transforms / LoopIndexSplit / SplitValue-2007-08-24.ll
1 ; Split loop. Save last value. Split value is off by one in this example.
2 ; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
3 ; RUN: grep "loop-index-split" | count 1
4
5 @k = external global i32                ; <i32*> [#uses=2]
6
7 define void @foobar(i32 %a, i32 %b) {
8 entry:
9         br label %bb
10
11 bb:             ; preds = %cond_next16, %entry
12         %i.01.0 = phi i32 [ 0, %entry ], [ %tmp18, %cond_next16 ]               ; <i32> [#uses=5]
13         %tsum.18.0 = phi i32 [ 42, %entry ], [ %tsum.013.1, %cond_next16 ]              ; <i32> [#uses=3]
14         %tmp1 = icmp sgt i32 %i.01.0, 50                ; <i1> [#uses=1]
15         br i1 %tmp1, label %cond_true, label %cond_false
16
17 cond_true:              ; preds = %bb
18         %tmp4 = tail call i32 @foo( i32 %i.01.0 )               ; <i32> [#uses=1]
19         %tmp6 = add i32 %tmp4, %tsum.18.0               ; <i32> [#uses=2]
20         %tmp914 = load i32* @k, align 4         ; <i32> [#uses=1]
21         %tmp1015 = icmp eq i32 %tmp914, 0               ; <i1> [#uses=1]
22         br i1 %tmp1015, label %cond_next16, label %cond_true13
23
24 cond_false:             ; preds = %bb
25         %tmp8 = tail call i32 @bar( i32 %i.01.0 )               ; <i32> [#uses=0]
26         %tmp9 = load i32* @k, align 4           ; <i32> [#uses=1]
27         %tmp10 = icmp eq i32 %tmp9, 0           ; <i1> [#uses=1]
28         br i1 %tmp10, label %cond_next16, label %cond_true13
29
30 cond_true13:            ; preds = %cond_false, %cond_true
31         %tsum.013.0 = phi i32 [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ]                ; <i32> [#uses=1]
32         %tmp15 = tail call i32 @bar( i32 %i.01.0 )              ; <i32> [#uses=0]
33         br label %cond_next16
34
35 cond_next16:            ; preds = %cond_false, %cond_true, %cond_true13
36         %tsum.013.1 = phi i32 [ %tsum.013.0, %cond_true13 ], [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ]         ; <i32> [#uses=2]
37         %tmp18 = add i32 %i.01.0, 1             ; <i32> [#uses=3]
38         %tmp21 = icmp slt i32 %tmp18, 100               ; <i1> [#uses=1]
39         br i1 %tmp21, label %bb, label %bb24
40
41 bb24:           ; preds = %cond_next16
42         %tmp18.lcssa = phi i32 [ %tmp18, %cond_next16 ]         ; <i32> [#uses=1]
43         %tsum.013.1.lcssa = phi i32 [ %tsum.013.1, %cond_next16 ]               ; <i32> [#uses=1]
44         %tmp27 = tail call i32 @t( i32 %tmp18.lcssa, i32 %tsum.013.1.lcssa )            ; <i32> [#uses=0]
45         ret void
46 }
47
48 declare i32 @foo(i32)
49
50 declare i32 @bar(i32)
51
52 declare i32 @t(i32, i32)