aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-12 01:41:34 +0000
committerChris Lattner <sabre@nondot.org>2009-11-12 01:41:34 +0000
commit9a90e1559353cc51cd1acfa8ba7e34e263ae4cd3 (patch)
treee83afecfd662d89dd8a570f1954de4aab4b6a6b5
parent45404958d705d78cc6068356f8ee293b27b15219 (diff)
downloadexternal_llvm-9a90e1559353cc51cd1acfa8ba7e34e263ae4cd3.zip
external_llvm-9a90e1559353cc51cd1acfa8ba7e34e263ae4cd3.tar.gz
external_llvm-9a90e1559353cc51cd1acfa8ba7e34e263ae4cd3.tar.bz2
with the new code we can thread non-instruction values. This
allows us to handle the test10 testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86924 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp7
-rw-r--r--test/Transforms/JumpThreading/basic.ll42
2 files changed, 46 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index e7ca0f4..47bebf9 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -518,8 +518,13 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
}
// All the rest of our checks depend on the condition being an instruction.
- if (CondInst == 0)
+ if (CondInst == 0) {
+ // FIXME: Unify this with code below.
+ if (LVI && ProcessThreadableEdges(Condition, BB))
+ return true;
return false;
+ }
+
// See if this is a phi node in the current block.
if (PHINode *PN = dyn_cast<PHINode>(CondInst))
diff --git a/test/Transforms/JumpThreading/basic.ll b/test/Transforms/JumpThreading/basic.ll
index 514c865..4a1a286 100644
--- a/test/Transforms/JumpThreading/basic.ll
+++ b/test/Transforms/JumpThreading/basic.ll
@@ -285,12 +285,50 @@ F2:
+; CHECK: @test10
+declare i32 @test10f1()
+declare i32 @test10f2()
+declare void @test10f3()
+
+;; Non-local condition threading.
+define i32 @test10(i1 %cond) {
+; CHECK: @test10
+; CHECK-NEXT: br i1 %cond, label %T2, label %F2
+ br i1 %cond, label %T1, label %F1
+
+T1:
+ %v1 = call i32 @test10f1()
+ br label %Merge
+
+; CHECK: %v1 = call i32 @test10f1()
+; CHECK-NEXT: call void @f3()
+; CHeCK-NEXT: ret i32 %v1
+
+F1:
+ %v2 = call i32 @test10f2()
+ br label %Merge
+
+Merge:
+ %B = phi i32 [%v1, %T1], [%v2, %F1]
+ br i1 %cond, label %T2, label %F2
+
+T2:
+ call void @f3()
+ ret i32 %B
+
+F2:
+ ret i32 %B
+}
+
+
+
+
;;; Duplicate condition to avoid xor of cond.
;;; TODO: Make this happen.
-define i32 @test10(i1 %cond, i1 %cond2) {
+define i32 @test11(i1 %cond, i1 %cond2) {
Entry:
-; CHECK: @test10
+; CHECK: @test11
%v1 = call i32 @f1()
br i1 %cond, label %Merge, label %F1