Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | ; 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 | |
| 7 | int %testfunction(int %i0, int %j0) { |
| 8 | BB1: |
| 9 | br label %BB2 |
| 10 | BB2: |
| 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 | |
| 16 | BB3: |
| 17 | %jcond = setlt int %j2, 20 |
| 18 | br bool %jcond, label %BB5, label %BB6 |
| 19 | |
| 20 | BB4: |
| 21 | ret int %j2 |
| 22 | |
| 23 | BB5: |
| 24 | %k3 = add int %k2, 1 |
| 25 | br label %BB7 |
| 26 | |
| 27 | BB6: |
| 28 | %k5 = add int %k2, 1 |
| 29 | br label %BB7 |
| 30 | |
| 31 | BB7: |
| 32 | %j4 = phi int [1, %BB5], [%k2, %BB6] |
| 33 | %k4 = phi int [%k3, %BB5], [%k5, %BB6] |
| 34 | br label %BB2 |
| 35 | } |