blob: 1e4255d4efe6d62022c38e5f53e58fba12c43acb [file] [log] [blame]
Chris Lattner8673e442002-08-22 20:22:55 +00001; 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 Lattnerbe677582003-02-24 23:14:07 +00007; RUN: if as < %s | opt -basicaa -licm -load-vn -gcse -instcombine | dis | grep ToRemove
Chris Lattner8673e442002-08-22 20:22:55 +00008; RUN: then exit 1
9; RUN: else exit 0
10; RUN: fi
11
12%A = global int 7
13%B = global int 8
14implementation
15
16int %test(bool %c) {
Chris Lattner92bab832002-09-07 22:48:30 +000017 %Atmp = load int* %A
Chris Lattnerbe677582003-02-24 23:14:07 +000018 br bool %c, label %Dummy, label %Loop
19Loop:
20 %ToRemove = load int* %A
Chris Lattner92bab832002-09-07 22:48:30 +000021 store int %Atmp, int* %B ; Store cannot alias %A
Chris Lattner8673e442002-08-22 20:22:55 +000022
23 br bool %c, label %Out, label %Loop
24Out:
Chris Lattner4e313652003-02-24 03:52:13 +000025 %X = sub int %ToRemove, %Atmp
26 ret int %X
Chris Lattner8673e442002-08-22 20:22:55 +000027
28Dummy:
29 store int 7, int* %A
30 br label %Loop
31}
32