aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/GVN/rle.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-09 01:59:31 +0000
committerChris Lattner <sabre@nondot.org>2009-12-09 01:59:31 +0000
commit05e15f8897bd949f9d4bce073d53ed3256c71e2b (patch)
treee9f03085680ca3f56f93dd7899cda45e972b090b /test/Transforms/GVN/rle.ll
parent7bd6478cd6a1264f884b46f3694af3a68a6fab0a (diff)
downloadexternal_llvm-05e15f8897bd949f9d4bce073d53ed3256c71e2b.zip
external_llvm-05e15f8897bd949f9d4bce073d53ed3256c71e2b.tar.gz
external_llvm-05e15f8897bd949f9d4bce073d53ed3256c71e2b.tar.bz2
Switch GVN and memdep to use PHITransAddr, which correctly handles
phi translation of complex expressions like &A[i+1]. This has the following benefits: 1. The phi translation logic is all contained in its own class with a strong interface and verification that it is self consistent. 2. The logic is more correct than before. Previously, if intermediate expressions got PHI translated, we'd miss the update and scan for the wrong pointers in predecessor blocks. @phi_trans2 is a testcase for this. 3. We have a lot less code in memdep. We can handle phi translation across blocks of things like @phi_trans3, which is pretty insane :). This patch should fix the miscompiles of 255.vortex, and I tested it with a bootstrap of llvm-gcc, llvm-test and dejagnu of course. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN/rle.ll')
-rw-r--r--test/Transforms/GVN/rle.ll51
1 files changed, 50 insertions, 1 deletions
diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll
index e667eec..0a2b953 100644
--- a/test/Transforms/GVN/rle.ll
+++ b/test/Transforms/GVN/rle.ll
@@ -388,6 +388,7 @@ declare i1 @cond() readonly
declare i1 @cond2() readonly
define i32 @phi_trans2() {
+; CHECK: @phi_trans2
entry:
%P = alloca i32, i32 400
br label %F1
@@ -411,9 +412,57 @@ F:
br label %F1
TX:
- ret i32 %x ;; SHOULD NOT BE COMPILED TO 'ret i32 42'.
+ ; This load should not be compiled to 'ret i32 42'. An overly clever
+ ; implementation of GVN would see that we're returning 17 if the loop
+ ; executes once or 42 if it executes more than that, but we'd have to do
+ ; loop restructuring to expose this, and GVN shouldn't do this sort of CFG
+ ; transformation.
+
+; CHECK: TX:
+; CHECK: ret i32 %x
+ ret i32 %x
TY:
ret i32 0
}
+define i32 @phi_trans3(i32* %p) {
+; CHECK: @phi_trans3
+block1:
+ br i1 true, label %block2, label %block3
+
+block2:
+ store i32 87, i32* %p
+ br label %block4
+
+block3:
+ %p2 = getelementptr i32* %p, i32 43
+ store i32 97, i32* %p2
+ br label %block4
+
+block4:
+ %A = phi i32 [-1, %block2], [42, %block3]
+ br i1 true, label %block5, label %exit
+
+; CHECK: block4:
+; CHECK-NEXT: %D = phi i32 [ 87, %block2 ], [ 97, %block3 ]
+; CHECK-NOT: load
+
+block5:
+ %B = add i32 %A, 1
+ br i1 true, label %block6, label %exit
+
+block6:
+ %C = getelementptr i32* %p, i32 %B
+ br i1 true, label %block7, label %exit
+
+block7:
+ %D = load i32* %C
+ ret i32 %D
+
+; CHECK: block7:
+; CHECK-NEXT: ret i32 %D
+
+exit:
+ ret i32 -1
+}