aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/GVN
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-27 08:25:10 +0000
committerChris Lattner <sabre@nondot.org>2009-11-27 08:25:10 +0000
commit616613d7a4ddc7cefce53b2bfe3fdcdec6b032c2 (patch)
treea21c2231efa530622c802a2907533ef4beb023c4 /test/Transforms/GVN
parentd280d85791c1fad9e625a5e2f472092b0c81c14e (diff)
teach GVN's load PRE to insert computations of the address in predecessors
where it is not available. It's unclear how to get this inserted computation into GVN's scalar availability sets, Owen, help? :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r--test/Transforms/GVN/pre-load.ll34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/Transforms/GVN/pre-load.ll b/test/Transforms/GVN/pre-load.ll
index 637a6d26c8..3cb67135ac 100644
--- a/test/Transforms/GVN/pre-load.ll
+++ b/test/Transforms/GVN/pre-load.ll
@@ -22,6 +22,7 @@ block4:
; CHECK-NEXT: ret i32
}
+; This is a simple phi translation case.
define i32 @test2(i32* %p, i32* %q, i1 %C) {
; CHECK: @test2
block1:
@@ -46,6 +47,7 @@ block4:
; CHECK: ret i32
}
+; This is a PRE case that requires phi translation through a GEP.
define i32 @test3(i32* %p, i32* %q, i32** %Hack, i1 %C) {
; CHECK: @test3
block1:
@@ -73,3 +75,35 @@ block4:
; CHECK-NOT: load
; CHECK: ret i32
}
+
+;; Here the loaded address is available, but the computation is in 'block3'
+;; which does not dominate 'block2'.
+define i32 @test4(i32* %p, i32* %q, i32** %Hack, i1 %C) {
+; CHECK: @test4
+block1:
+ br i1 %C, label %block2, label %block3
+
+block2:
+ br label %block4
+; CHECK: block2:
+; CHECK: load i32*
+; CHECK: br label %block4
+
+block3:
+ %B = getelementptr i32* %q, i32 1
+ store i32* %B, i32** %Hack
+
+ %A = getelementptr i32* %p, i32 1
+ store i32 0, i32* %A
+ br label %block4
+
+block4:
+ %P2 = phi i32* [%p, %block3], [%q, %block2]
+ %P3 = getelementptr i32* %P2, i32 1
+ %PRE = load i32* %P3
+ ret i32 %PRE
+; CHECK: block4:
+; CHECK-NEXT: phi i32 [
+; CHECK-NOT: load
+; CHECK: ret i32
+}