blob: 341847bc13ae6d5a674c0b39d1faf3adc47b8938 [file] [log] [blame]
Chris Lattner830b5292002-05-02 20:41:39 +00001; edgefailure - This function illustrates how SCCP is not doing it's job. This
2; function should be optimized almost completely away: the loop should be
3; analyzed to detect that the body executes exactly once, and thus the branch
4; can be eliminated and code becomes trivially dead. This is distilled from a
5; real benchmark (mst from Olden benchmark, MakeGraph function). When SCCP is
6; fixed, this should be eliminated by a single SCCP application.
7;
8; RUN: if as < %s | opt -sccp | dis | grep loop
9; RUN: then exit 1
10; RUN: else exit 0
11; RUN: fi
12
13int *"test"()
14begin
15bb1:
16 %A = malloc int
17 br label %bb2
18bb2:
19 %i = phi int [ %i2, %bb2 ], [ 0, %bb1 ] ;; Always 0
20 %i2 = add int %i, 1 ;; Always 1
21 store int %i, int *%A
22 %loop = setle int %i2, 0 ;; Always false
23 br bool %loop, label %bb2, label %bb3
24
25bb3:
26 ret int * %A
27end
28