Renamed `as' => `llvm-as', `dis' => `llvm-dis', `link' => `llvm-link'.
[oota-llvm.git] / test / Transforms / BasicAA / licmtest.ll
1 ; Test that LICM uses basicaa to do alias analysis, which is capable of 
2 ; disambiguating some obvious cases.  If LICM is able to disambiguate the
3 ; two pointers, then the load should be hoisted, and the store sunk.  Thus
4 ; the loop becomes empty and can be deleted by ADCE. 
5
6 ; RUN: llvm-as < %s | opt -basicaa -licm --adce | llvm-dis | not grep Loop
7
8 %A = global int 7
9 %B = global int 8
10 %C = global [2 x int ] [ int 4, int 8 ]
11 implementation
12
13 int %test(bool %c) {
14         %Atmp = load int* %A
15         br label %Loop
16 Loop:
17         %ToRemove = load int* %A
18         store int %Atmp, int* %B  ; Store cannot alias %A
19
20         br bool %c, label %Out, label %Loop
21 Out:
22         %X = sub int %ToRemove, %Atmp
23         ret int %X
24 }
25
26 int %test2(bool %c) {
27         br label %Loop
28 Loop:
29         %AVal = load int* %A
30         %C0 = getelementptr [2 x int ]* %C, long 0, long 0
31         store int %AVal, int* %C0  ; Store cannot alias %A
32
33         %BVal = load int* %B
34         %C1 = getelementptr [2 x int ]* %C, long 0, long 1
35         store int %BVal, int* %C1  ; Store cannot alias %A, %B, or %C0
36
37         br bool %c, label %Out, label %Loop
38 Out:
39         %X = sub int %AVal, %BVal
40         ret int %X
41 }
42