blob: f0a8244ecfadbbf611123e2ad839a36fa2f9e951 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; This is the test case taken from appel's book that illustrates a hard case
2; that SCCP gets right. BB3 should be completely eliminated.
3;
4; RUN: llvm-upgrade < %s | llvm-as | opt -sccp -constprop -dce -simplifycfg | \
5; RUN: llvm-dis | not grep BB3
6
7int %testfunction(int %i0, int %j0) {
8BB1:
9 br label %BB2
10BB2:
11 %j2 = phi int [%j4, %BB7], [1, %BB1]
12 %k2 = phi int [%k4, %BB7], [0, %BB1]
13 %kcond = setlt int %k2, 100
14 br bool %kcond, label %BB3, label %BB4
15
16BB3:
17 %jcond = setlt int %j2, 20
18 br bool %jcond, label %BB5, label %BB6
19
20BB4:
21 ret int %j2
22
23BB5:
24 %k3 = add int %k2, 1
25 br label %BB7
26
27BB6:
28 %k5 = add int %k2, 1
29 br label %BB7
30
31BB7:
32 %j4 = phi int [1, %BB5], [%k2, %BB6]
33 %k4 = phi int [%k3, %BB5], [%k5, %BB6]
34 br label %BB2
35}