@test9 is a testcase for r89958. Before 89958, we misanalyzed the

first expression as P+4+4*i which we considered to possibly alias
P+4*j.  Now we correctly analyze the former one as P+1+4*i.

@test10 is a sanity test that verfies that we know that P+4+4*i != P+4*i.

llvm-svn: 89960
This commit is contained in:
Chris Lattner 2009-11-26 19:25:46 +00:00
parent ce573daf09
commit 911e5047d0

View File

@ -1,8 +1,8 @@
; RUN: opt < %s -gvn -instcombine -S |& FileCheck %s
; Make sure that basicaa thinks R and r are must aliases.
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
; Make sure that basicaa thinks R and r are must aliases.
define i32 @test1(i8 * %P) {
entry:
%Q = bitcast i8* %P to {i32, i32}*
@ -131,3 +131,41 @@ define i32 @test8(i32* %p, i32 %i) {
; CHECK: @test8
; CHECK: ret i32 0
}
define i8 @test9([4 x i8] *%P, i32 %i, i32 %j) {
%i2 = shl i32 %i, 2
%i3 = add i32 %i2, 1
; P2 = P + 1 + 4*i
%P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3
%j2 = shl i32 %j, 2
; P4 = P + 4*j
%P4 = getelementptr [4 x i8]* %P, i32 0, i32 %j2
%x = load i8* %P2
store i8 42, i8* %P4
%y = load i8* %P2
%z = sub i8 %x, %y
ret i8 %z
; CHECK: @test9
; CHECK: ret i8 0
}
define i8 @test10([4 x i8] *%P, i32 %i) {
%i2 = shl i32 %i, 2
%i3 = add i32 %i2, 4
; P2 = P + 4 + 4*i
%P2 = getelementptr [4 x i8] *%P, i32 0, i32 %i3
; P4 = P + 4*i
%P4 = getelementptr [4 x i8]* %P, i32 0, i32 %i2
%x = load i8* %P2
store i8 42, i8* %P4
%y = load i8* %P2
%z = sub i8 %x, %y
ret i8 %z
; CHECK: @test10
; CHECK: ret i8 0
}