Chris Lattner | a1ab959 | 2002-05-02 20:41:39 +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 | ; |
Reid Spencer | 9aafdcf | 2007-04-15 09:21:47 +0000 | [diff] [blame^] | 4 | ; RUN: llvm-upgrade < %s | llvm-as | opt -sccp -constprop -dce -simplifycfg | \ |
| 5 | ; RUN: llvm-dis | not grep BB3 |
Chris Lattner | a1ab959 | 2002-05-02 20:41:39 +0000 | [diff] [blame] | 6 | |
Chris Lattner | 5fa8707 | 2005-05-13 15:51:31 +0000 | [diff] [blame] | 7 | int %testfunction(int %i0, int %j0) { |
Chris Lattner | a1ab959 | 2002-05-02 20:41:39 +0000 | [diff] [blame] | 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 |
Chris Lattner | 50e8682 | 2003-06-28 23:23:34 +0000 | [diff] [blame] | 35 | } |