blob: 2136ca644c8116d594a39f10f5bf6acd63628810 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +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: llvm-upgrade < %s | llvm-as | opt -sccp | llvm-dis | not grep loop
9
10int* %test() {
11bb1:
12 %A = malloc int
13 br label %bb2
14bb2:
15 %i = phi int [ %i2, %bb2 ], [ 0, %bb1 ] ;; Always 0
16 %i2 = add int %i, 1 ;; Always 1
17 store int %i, int *%A
18 %loop = setle int %i2, 0 ;; Always false
19 br bool %loop, label %bb2, label %bb3
20
21bb3:
22 ret int * %A
23}