2002-08-22 22:22:55 +02:00
|
|
|
; Test that LICM uses basicaa to do alias analysis, which is capable of
|
2003-02-26 17:18:00 +01: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 22:22:55 +02:00
|
|
|
|
2006-12-02 05:23:10 +01:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -licm --adce | llvm-dis | not grep Loop
|
2002-08-22 22:22:55 +02:00
|
|
|
|
|
|
|
%A = global int 7
|
|
|
|
%B = global int 8
|
2003-03-04 00:27:15 +01:00
|
|
|
%C = global [2 x int ] [ int 4, int 8 ]
|
2002-08-22 22:22:55 +02:00
|
|
|
implementation
|
|
|
|
|
|
|
|
int %test(bool %c) {
|
2002-09-08 00:48:30 +02:00
|
|
|
%Atmp = load int* %A
|
2003-02-26 17:18:00 +01:00
|
|
|
br label %Loop
|
2003-02-25 00:14:07 +01:00
|
|
|
Loop:
|
|
|
|
%ToRemove = load int* %A
|
2002-09-08 00:48:30 +02:00
|
|
|
store int %Atmp, int* %B ; Store cannot alias %A
|
2002-08-22 22:22:55 +02:00
|
|
|
|
|
|
|
br bool %c, label %Out, label %Loop
|
|
|
|
Out:
|
2003-02-24 04:52:13 +01:00
|
|
|
%X = sub int %ToRemove, %Atmp
|
|
|
|
ret int %X
|
2002-08-22 22:22:55 +02:00
|
|
|
}
|
|
|
|
|
2003-03-04 00:27:15 +01: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
|
|
|
|
}
|
|
|
|
|