summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-12 05:24:05 +0000
committerChris Lattner <sabre@nondot.org>2009-11-12 05:24:05 +0000
commit66c04c48debfd4357beaf9310346b2b24046b685 (patch)
tree21ae6fe818b545a074550b4d53b7bc1e221bf3ac /lib/Transforms/Scalar/JumpThreading.cpp
parentf496e79f44f13ac80564f5f8e69aa648033e7889 (diff)
downloadllvm-66c04c48debfd4357beaf9310346b2b24046b685.tar.gz
llvm-66c04c48debfd4357beaf9310346b2b24046b685.tar.bz2
llvm-66c04c48debfd4357beaf9310346b2b24046b685.tar.xz
use getPredicateOnEdge to fold comparisons through PHI nodes,
which implements GCC PR18046. This also gets us 360 more jump threads on 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86953 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 1bfad2d5d7..d5ce86aca0 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -368,7 +368,17 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB);
Value *Res = SimplifyCmpInst(Cmp->getPredicate(), LHS, RHS, TD);
- if (Res == 0) continue;
+ if (Res == 0) {
+ if (!LVI || !isa<Constant>(RHS))
+ continue;
+
+ LazyValueInfo::Tristate
+ ResT = LVI->getPredicateOnEdge(Cmp->getPredicate(), LHS,
+ cast<Constant>(RHS), PredBB, BB);
+ if (ResT == LazyValueInfo::Unknown)
+ continue;
+ Res = ConstantInt::get(Type::getInt1Ty(LHS->getContext()), ResT);
+ }
if (isa<UndefValue>(Res))
Result.push_back(std::make_pair((ConstantInt*)0, PredBB));