Chris Lattner | 8673e44 | 2002-08-22 20:22:55 +0000 | [diff] [blame] | 1 | ; Test that LICM uses basicaa to do alias analysis, which is capable of |
| 2 | ; disambiguating some obvious cases. The ToRemove load should be eliminated |
| 3 | ; in this testcase. This testcase was carefully contrived so that GCSE would |
| 4 | ; not be able to eliminate the load itself, without licm's help. This is |
| 5 | ; because, for GCSE, the load is killed by the dummy basic block. |
| 6 | |
Chris Lattner | be67758 | 2003-02-24 23:14:07 +0000 | [diff] [blame] | 7 | ; RUN: if as < %s | opt -basicaa -licm -load-vn -gcse -instcombine | dis | grep ToRemove |
Chris Lattner | 8673e44 | 2002-08-22 20:22:55 +0000 | [diff] [blame] | 8 | ; RUN: then exit 1 |
| 9 | ; RUN: else exit 0 |
| 10 | ; RUN: fi |
| 11 | |
| 12 | %A = global int 7 |
| 13 | %B = global int 8 |
| 14 | implementation |
| 15 | |
| 16 | int %test(bool %c) { |
Chris Lattner | 92bab83 | 2002-09-07 22:48:30 +0000 | [diff] [blame] | 17 | %Atmp = load int* %A |
Chris Lattner | be67758 | 2003-02-24 23:14:07 +0000 | [diff] [blame] | 18 | br bool %c, label %Dummy, label %Loop |
| 19 | Loop: |
| 20 | %ToRemove = load int* %A |
Chris Lattner | 92bab83 | 2002-09-07 22:48:30 +0000 | [diff] [blame] | 21 | store int %Atmp, int* %B ; Store cannot alias %A |
Chris Lattner | 8673e44 | 2002-08-22 20:22:55 +0000 | [diff] [blame] | 22 | |
| 23 | br bool %c, label %Out, label %Loop |
| 24 | Out: |
Chris Lattner | 4e31365 | 2003-02-24 03:52:13 +0000 | [diff] [blame] | 25 | %X = sub int %ToRemove, %Atmp |
| 26 | ret int %X |
Chris Lattner | 8673e44 | 2002-08-22 20:22:55 +0000 | [diff] [blame] | 27 | |
| 28 | Dummy: |
| 29 | store int 7, int* %A |
| 30 | br label %Loop |
| 31 | } |
| 32 | |