| Chris Lattner | df8fcca | 2002-04-28 01:46:36 +0000 | [diff] [blame] | 1 | ; Various test cases to ensure basic functionality is working for GCSE |
| 2 | |
| Misha Brukman | edf4bab | 2003-09-16 15:29:54 +0000 | [diff] [blame] | 3 | ; RUN: llvm-as < %s | opt -gcse |
| Chris Lattner | df8fcca | 2002-04-28 01:46:36 +0000 | [diff] [blame] | 4 | |
| 5 | implementation |
| 6 | |
| 7 | void "testinsts"(int %i, int %j, int* %p) |
| 8 | begin |
| 9 | %A = cast int %i to uint |
| 10 | %B = cast int %i to uint |
| 11 | |
| 12 | %C = shl int %i, ubyte 1 |
| 13 | %D = shl int %i, ubyte 1 |
| 14 | |
| Chris Lattner | 3c050b5 | 2003-09-08 16:29:02 +0000 | [diff] [blame] | 15 | %E = getelementptr int* %p, long 12 |
| 16 | %F = getelementptr int* %p, long 12 |
| 17 | %G = getelementptr int* %p, long 13 |
| Chris Lattner | df8fcca | 2002-04-28 01:46:36 +0000 | [diff] [blame] | 18 | ret void |
| 19 | end |
| 20 | |
| 21 | |
| 22 | ; Test different combinations of domination properties... |
| 23 | void "sameBBtest"(int %i, int %j) |
| 24 | begin |
| 25 | %A = add int %i, %j |
| 26 | %B = add int %i, %j |
| 27 | |
| Chris Lattner | 1115d58 | 2002-08-14 19:28:22 +0000 | [diff] [blame] | 28 | %C = xor int %A, -1 |
| 29 | %D = xor int %B, -1 |
| 30 | %E = xor int %j, -1 |
| Chris Lattner | df8fcca | 2002-04-28 01:46:36 +0000 | [diff] [blame] | 31 | |
| 32 | ret void |
| 33 | end |
| 34 | |
| 35 | int "dominates"(int %i, int %j) |
| 36 | begin |
| 37 | %A = add int %i, %j |
| 38 | br label %BB2 |
| 39 | |
| 40 | BB2: |
| 41 | %B = add int %i, %j |
| 42 | ret int %B |
| 43 | end |
| 44 | |
| 45 | int "hascommondominator"(int %i, int %j) |
| 46 | begin |
| 47 | br bool true, label %BB1, label %BB2 |
| 48 | |
| 49 | BB1: |
| 50 | %A = add int %i, %j |
| 51 | ret int %A |
| 52 | |
| 53 | BB2: |
| 54 | %B = add int %i, %j |
| 55 | ret int %B |
| 56 | end |
| 57 | |