2002-08-22 19:31:36 +02:00
|
|
|
; Test that GCSE uses basicaa to do alias analysis, which is capable of
|
|
|
|
; disambiguating some obvious cases. All loads should be removable in
|
|
|
|
; this testcase.
|
|
|
|
|
2009-09-11 20:01:28 +02:00
|
|
|
; RUN: opt < %s -basicaa -gvn -instcombine -dce -S \
|
2009-09-09 00:41:33 +02:00
|
|
|
; RUN: | not grep load
|
2002-08-22 19:31:36 +02:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
@A = global i32 7
|
|
|
|
@B = global i32 8
|
2002-08-22 19:31:36 +02:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
define i32 @test() {
|
|
|
|
%A1 = load i32* @A
|
2002-08-22 19:31:36 +02:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
store i32 123, i32* @B ; Store cannot alias @A
|
2002-08-22 19:31:36 +02:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
%A2 = load i32* @A
|
|
|
|
%X = sub i32 %A1, %A2
|
|
|
|
ret i32 %X
|
2002-08-22 19:31:36 +02:00
|
|
|
}
|
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
define i32 @test2() {
|
|
|
|
%A1 = load i32* @A
|
2002-08-22 22:22:55 +02:00
|
|
|
br label %Loop
|
|
|
|
Loop:
|
2008-02-14 07:56:27 +01:00
|
|
|
%AP = phi i32 [0, %0], [%X, %Loop]
|
|
|
|
store i32 %AP, i32* @B ; Store cannot alias @A
|
2002-08-22 22:22:55 +02:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
%A2 = load i32* @A
|
|
|
|
%X = sub i32 %A1, %A2
|
|
|
|
%c = icmp eq i32 %X, 0
|
|
|
|
br i1 %c, label %out, label %Loop
|
2002-08-22 22:22:55 +02:00
|
|
|
|
|
|
|
out:
|
2008-02-14 07:56:27 +01:00
|
|
|
ret i32 %X
|
2002-08-22 22:22:55 +02:00
|
|
|
}
|
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
declare void @external()
|
2004-03-12 23:38:31 +01:00
|
|
|
|
2008-02-14 07:56:27 +01:00
|
|
|
define i32 @test3() {
|
|
|
|
%X = alloca i32
|
|
|
|
store i32 7, i32* %X
|
|
|
|
call void @external()
|
|
|
|
%V = load i32* %X
|
|
|
|
ret i32 %V
|
2004-03-12 23:38:31 +01:00
|
|
|
}
|
|
|
|
|