2002-08-22 20:22:55 +00:00
|
|
|
; Test that LICM uses basicaa to do alias analysis, which is capable of
|
2003-02-26 16:18:00 +00:00
|
|
|
; disambiguating some obvious cases. If LICM is able to disambiguate the
|
|
|
|
; two pointers, then the load should be hoisted, and the store sunk. Thus
|
|
|
|
; the loop becomes empty and can be deleted by ADCE.
|
2002-08-22 20:22:55 +00:00
|
|
|
|
2006-12-02 04:23:10 +00:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -licm --adce | llvm-dis | not grep Loop
|
2002-08-22 20:22:55 +00:00
|
|
|
|
|
|
|
%A = global int 7
|
|
|
|
%B = global int 8
|
2003-03-03 23:27:15 +00:00
|
|
|
%C = global [2 x int ] [ int 4, int 8 ]
|
2002-08-22 20:22:55 +00:00
|
|
|
implementation
|
|
|
|
|
|
|
|
int %test(bool %c) {
|
2002-09-07 22:48:30 +00:00
|
|
|
%Atmp = load int* %A
|
2003-02-26 16:18:00 +00:00
|
|
|
br label %Loop
|
2003-02-24 23:14:07 +00:00
|
|
|
Loop:
|
|
|
|
%ToRemove = load int* %A
|
2002-09-07 22:48:30 +00:00
|
|
|
store int %Atmp, int* %B ; Store cannot alias %A
|
2002-08-22 20:22:55 +00:00
|
|
|
|
|
|
|
br bool %c, label %Out, label %Loop
|
|
|
|
Out:
|
2003-02-24 03:52:13 +00:00
|
|
|
%X = sub int %ToRemove, %Atmp
|
|
|
|
ret int %X
|
2002-08-22 20:22:55 +00:00
|
|
|
}
|
|
|
|
|
2003-03-03 23:27:15 +00:00
|
|
|
int %test2(bool %c) {
|
|
|
|
br label %Loop
|
|
|
|
Loop:
|
|
|
|
%AVal = load int* %A
|
|
|
|
%C0 = getelementptr [2 x int ]* %C, long 0, long 0
|
|
|
|
store int %AVal, int* %C0 ; Store cannot alias %A
|
|
|
|
|
|
|
|
%BVal = load int* %B
|
|
|
|
%C1 = getelementptr [2 x int ]* %C, long 0, long 1
|
|
|
|
store int %BVal, int* %C1 ; Store cannot alias %A, %B, or %C0
|
|
|
|
|
|
|
|
br bool %c, label %Out, label %Loop
|
|
|
|
Out:
|
|
|
|
%X = sub int %AVal, %BVal
|
|
|
|
ret int %X
|
|
|
|
}
|
|
|
|
|