blob: d838e6cb6062c517238543c27917e3bd9d793f34 [file] [log] [blame]
Chris Lattner8673e442002-08-22 20:22:55 +00001; Test that LICM uses basicaa to do alias analysis, which is capable of
Chris Lattner24a0bee2003-02-26 16:18:00 +00002; 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.
Chris Lattner8673e442002-08-22 20:22:55 +00005
Chris Lattner24a0bee2003-02-26 16:18:00 +00006; RUN: if as < %s | opt -basicaa -licm --adce | dis | grep Loop
Chris Lattner8673e442002-08-22 20:22:55 +00007; RUN: then exit 1
8; RUN: else exit 0
9; RUN: fi
10
11%A = global int 7
12%B = global int 8
13implementation
14
15int %test(bool %c) {
Chris Lattner92bab832002-09-07 22:48:30 +000016 %Atmp = load int* %A
Chris Lattner24a0bee2003-02-26 16:18:00 +000017 br label %Loop
Chris Lattnerbe677582003-02-24 23:14:07 +000018Loop:
19 %ToRemove = load int* %A
Chris Lattner92bab832002-09-07 22:48:30 +000020 store int %Atmp, int* %B ; Store cannot alias %A
Chris Lattner8673e442002-08-22 20:22:55 +000021
22 br bool %c, label %Out, label %Loop
23Out:
Chris Lattner4e313652003-02-24 03:52:13 +000024 %X = sub int %ToRemove, %Atmp
25 ret int %X
Chris Lattner8673e442002-08-22 20:22:55 +000026}
27