From 3c47f2de906ce5c83d090f05a16edc06c3ee87ab Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Nov 2009 19:25:46 +0000 Subject: [PATCH] @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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89960 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Analysis/BasicAA/gep-alias.ll | 40 +++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/Analysis/BasicAA/gep-alias.ll b/test/Analysis/BasicAA/gep-alias.ll index 0eb8bb00b40..1ed03122471 100644 --- a/test/Analysis/BasicAA/gep-alias.ll +++ b/test/Analysis/BasicAA/gep-alias.ll @@ -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 +}