diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-12 00:47:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-12 00:47:34 +0000 |
commit | bbc25ff5ccc551cc3b78bc9a57a64d6ef4472d8a (patch) | |
tree | c6df05a39427a027b94a234cde1a4f3e5d767088 | |
parent | fd4a09fc0a55f4e42c699fd3e25c31ad403f8cc6 (diff) | |
download | bcm5719-llvm-bbc25ff5ccc551cc3b78bc9a57a64d6ef4472d8a.tar.gz bcm5719-llvm-bbc25ff5ccc551cc3b78bc9a57a64d6ef4472d8a.zip |
if jump threading is able to infer interesting values on both
the LHS and RHS of an and/or instruction, don't multiply add
known predecessor values. This fixes the crash on testcase
from PR7498
llvm-svn: 108114
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 15 | ||||
-rw-r--r-- | llvm/test/Transforms/JumpThreading/crash.ll | 24 |
2 files changed, 37 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 1a64b2cbad7..f68011a08ad 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -346,8 +346,19 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ } for (unsigned i = 0, e = RHSVals.size(); i != e; ++i) if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) { - Result.push_back(RHSVals[i]); - Result.back().first = InterestingVal; + // If we already inferred a value for this block on the LHS, don't + // re-add it. + bool HasValue = false; + for (unsigned r = 0, e = Result.size(); r != e; ++r) + if (Result[r].second == RHSVals[i].second) { + HasValue = true; + break; + } + + if (!HasValue) { + Result.push_back(RHSVals[i]); + Result.back().first = InterestingVal; + } } return !Result.empty(); } diff --git a/llvm/test/Transforms/JumpThreading/crash.ll b/llvm/test/Transforms/JumpThreading/crash.ll index 378c51a44a7..480b4a04ee9 100644 --- a/llvm/test/Transforms/JumpThreading/crash.ll +++ b/llvm/test/Transforms/JumpThreading/crash.ll @@ -363,3 +363,27 @@ F: ret i32 1422 } + +; PR7498 +define void @test14() nounwind { +entry: + %cmp33 = icmp slt i8 undef, 0 ; <i1> [#uses=1] + %tobool = icmp eq i8 undef, 0 ; <i1> [#uses=1] + br i1 %tobool, label %land.end69, label %land.rhs + +land.rhs: ; preds = %entry + br label %land.end69 + +land.end69: ; preds = %land.rhs, %entry + %0 = phi i1 [ undef, %land.rhs ], [ true, %entry ] ; <i1> [#uses=1] + %cmp71 = or i1 true, %0 ; <i1> [#uses=1] + %cmp73 = xor i1 %cmp33, %cmp71 ; <i1> [#uses=1] + br i1 %cmp73, label %if.then, label %if.end + +if.then: ; preds = %land.end69 + ret void + +if.end: ; preds = %land.end69 + ret void +} + |