aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-26 17:41:02 +0000
committerChris Lattner <sabre@nondot.org>2011-04-26 17:41:02 +0000
commit9750acc079409e52f6563636a112a9de50749b30 (patch)
treec4de4b907fe534490798165a404b1318159760e6
parenta61e73bda5125c28e48b52e573d115370838596b (diff)
Improve the bail-out predicate to really only kick in when phi
translation fails. We were bailing out in some cases that would cause us to miss GVN'ing some non-local cases away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130206 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/GVN.cpp3
-rw-r--r--test/Transforms/GVN/rle.ll23
-rw-r--r--test/Transforms/SimplifyCFG/2006-08-03-Crash.ll4
3 files changed, 26 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 15db9ad70a..7c11323ec8 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1103,7 +1103,8 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
// If we had a phi translation failure, we'll have a single entry which is a
// clobber in the current block. Reject this early.
- if (Deps.size() == 1 && Deps[0].getResult().isClobber()) {
+ if (Deps.size() == 1 && Deps[0].getResult().isClobber() &&
+ Deps[0].getResult().getInst()->getParent() == LI->getParent()) {
DEBUG(
dbgs() << "GVN: non-local load ";
WriteAsOperand(dbgs(), LI);
diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll
index 42363d8bb2..11e207cda0 100644
--- a/test/Transforms/GVN/rle.ll
+++ b/test/Transforms/GVN/rle.ll
@@ -570,4 +570,27 @@ entry:
}
+; Cross block partial alias case.
+define i32 @load_load_partial_alias_cross_block(i8* %P) nounwind ssp {
+entry:
+ %xx = bitcast i8* %P to i32*
+ %x1 = load i32* %xx, align 4
+ %cmp = icmp eq i32 %x1, 127
+ br i1 %cmp, label %land.lhs.true, label %if.end
+
+land.lhs.true: ; preds = %entry
+ %arrayidx4 = getelementptr inbounds i8* %P, i64 1
+ %tmp5 = load i8* %arrayidx4, align 1
+ %conv6 = zext i8 %tmp5 to i32
+ ret i32 %conv6
+
+if.end:
+ ret i32 52
+; CHECK: @load_load_partial_alias_cross_block
+; CHECK: land.lhs.true:
+; CHECK-NOT: load i8
+; CHECK: ret i32 %conv6
+}
+
+
diff --git a/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll
index 2c84c937ae..70fbddfe33 100644
--- a/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll
+++ b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll
@@ -1,7 +1,5 @@
-; RUN: opt < %s -gvn -simplifycfg \
-; RUN: -disable-output
+; RUN: opt < %s -gvn -simplifycfg -disable-output
; PR867
-; END.
target datalayout = "E-p:32:32"
target triple = "powerpc-apple-darwin8"