Added more comments
[oota-llvm.git] / test / sccptest.ll
1 implementation
2
3 ; edgefailure - This function illustrates how SCCP is not doing it's job.  This
4 ; function should be optimized almost completely away: the loop should be
5 ; analyzed to detect that the body executes exactly once, and thus the branch
6 ; can be eliminated and code becomes trivially dead.  This is distilled from a
7 ; real benchmark (mst from Olden benchmark, MakeGraph function).  When SCCP is
8 ; fixed, this should be eliminated by a single SCCP application.  TODO
9 ;
10 int *"edgefailure"()
11 begin
12 bb1:
13         %A = malloc int
14         br label %bb2
15 bb2:
16         %i = phi int [ %i2, %bb2 ], [ 0, %bb1 ]   ;; Always 0
17         %i2 = add int %i, 1                       ;; Always 1
18         store int %i, int *%A
19         %loop = setle int %i2, 0                  ;; Always false
20         br bool %loop, label %bb2, label %bb3
21
22 bb3:
23         ret int * %A
24 end
25
26
27
28 int "test function"(int %i0, int %j0)
29         %i1 = const int 1
30         %j1 = const int 1
31         %k1 = const int 0
32 begin
33 BB1:
34         br label %BB2
35 BB2:
36         %j2 = phi int [%j4, %BB7], [%j1, %BB1]
37         %k2 = phi int [%k4, %BB7], [%k1, %BB1]
38         %kcond = setlt int %k2, 100
39         br bool %kcond, label %BB3, label %BB4
40
41 BB3:
42         %jcond = setlt int %j2, 20
43         br bool %jcond, label %BB5, label %BB6
44
45 BB4:
46         ret int %j2
47
48 BB5:
49         %k3 = add int %k2, 1
50         br label %BB7
51
52 BB6:
53         %k5 = add int %k2, 1
54         br label %BB7
55
56 BB7:
57         %j4 = phi int [%i1, %BB5], [%k2, %BB6]
58         %k4 = phi int [%k3, %BB5], [%k5, %BB6]
59         br label %BB2
60 end
61