aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-26 02:17:34 +0000
committerChris Lattner <sabre@nondot.org>2009-11-26 02:17:34 +0000
commitd84eb911a9f9c5b16fb6a737289a98651b94ce7f (patch)
tree7edf0cb4d4bdebdf3344746df69fa97f826f3362 /test/Analysis
parent4b7d0d97279c3144bd36160721fc4a8b4ff198f5 (diff)
downloadexternal_llvm-d84eb911a9f9c5b16fb6a737289a98651b94ce7f.zip
external_llvm-d84eb911a9f9c5b16fb6a737289a98651b94ce7f.tar.gz
external_llvm-d84eb911a9f9c5b16fb6a737289a98651b94ce7f.tar.bz2
Change the other half of aliasGEP (which handles GEP differencing) to use DecomposeGEPExpression. This dramatically simplifies and shrinks the code by eliminating the horrible CheckGEPInstructions method, fixes a miscompilation (@test3) and makes the code more aggressive. In particular, we now handle the @test4 case, which is reduced from the SmallPtrSet constructor. Missing this caused us to emit a variable length memset instead of a fixed size one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll61
1 files changed, 59 insertions, 2 deletions
diff --git a/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll b/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll
index aaf9061..e8f8a8e 100644
--- a/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll
+++ b/test/Analysis/BasicAA/2008-12-09-GEP-IndicesAlias.ll
@@ -1,7 +1,9 @@
-; RUN: opt < %s -aa-eval -print-all-alias-modref-info -disable-output |& grep {MustAlias:.*%R,.*%r}
+; RUN: opt < %s -gvn -instcombine -S |& FileCheck %s
; Make sure that basicaa thinks R and r are must aliases.
-define i32 @test(i8 * %P) {
+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"
+
+define i32 @test1(i8 * %P) {
entry:
%Q = bitcast i8* %P to {i32, i32}*
%R = getelementptr {i32, i32}* %Q, i32 0, i32 1
@@ -13,4 +15,59 @@ entry:
%t = sub i32 %S, %s
ret i32 %t
+; CHECK: @test1
+; CHECK: ret i32 0
+}
+
+define i32 @test2(i8 * %P) {
+entry:
+ %Q = bitcast i8* %P to {i32, i32, i32}*
+ %R = getelementptr {i32, i32, i32}* %Q, i32 0, i32 1
+ %S = load i32* %R
+
+ %r = getelementptr {i32, i32, i32}* %Q, i32 0, i32 2
+ store i32 42, i32* %r
+
+ %s = load i32* %R
+
+ %t = sub i32 %S, %s
+ ret i32 %t
+; CHECK: @test2
+; CHECK: ret i32 0
+}
+
+
+; This was a miscompilation.
+define i32 @test3({float, {i32, i32, i32}}* %P) {
+entry:
+ %P2 = getelementptr {float, {i32, i32, i32}}* %P, i32 0, i32 1
+ %R = getelementptr {i32, i32, i32}* %P2, i32 0, i32 1
+ %S = load i32* %R
+
+ %r = getelementptr {i32, i32, i32}* %P2, i32 0, i32 2
+ store i32 42, i32* %r
+
+ %s = load i32* %R
+
+ %t = sub i32 %S, %s
+ ret i32 %t
+; CHECK: @test3
+; CHECK: ret i32 0
+}
+
+
+;; This is reduced from the SmallPtrSet constructor.
+%SmallPtrSetImpl = type { i8**, i32, i32, i32, [1 x i8*] }
+%SmallPtrSet64 = type { %SmallPtrSetImpl, [64 x i8*] }
+
+define i32 @test4(%SmallPtrSet64* %P) {
+entry:
+ %tmp2 = getelementptr inbounds %SmallPtrSet64* %P, i64 0, i32 0, i32 1
+ store i32 64, i32* %tmp2, align 8
+ %tmp3 = getelementptr inbounds %SmallPtrSet64* %P, i64 0, i32 0, i32 4, i64 64
+ store i8* null, i8** %tmp3, align 8
+ %tmp4 = load i32* %tmp2, align 8
+ ret i32 %tmp4
+; CHECK: @test4
+; CHECK: ret i32 64
}