summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-12 04:37:50 +0000
committerChris Lattner <sabre@nondot.org>2009-11-12 04:37:50 +0000
commitc893c4ed101307b08cda4cbbdc10b36ce59a4608 (patch)
tree1f886c3dc6179f5c7dae0b46a7f830775c855ab6 /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parent565ee2f1bde6a333726df7dd3be78a5b4ed8d074 (diff)
downloadbcm5719-llvm-c893c4ed101307b08cda4cbbdc10b36ce59a4608.tar.gz
bcm5719-llvm-c893c4ed101307b08cda4cbbdc10b36ce59a4608.zip
switch jump threading to use getPredicateOnEdge in one place
making the new LVI stuff smart enough to subsume some special cases in the old code. Disable them when LVI is around, the testcase still passes. llvm-svn: 86951
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 47bebf90d3c..e7a87e098d0 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -377,6 +377,7 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
// If comparing a live-in value against a constant, see if we know the
// live-in value on any predecessors.
if (LVI && isa<Constant>(Cmp->getOperand(1)) &&
+ Cmp->getType()->isInteger() && // Not vector compare.
(!isa<Instruction>(Cmp->getOperand(0)) ||
cast<Instruction>(Cmp->getOperand(0))->getParent() != BB)) {
Constant *RHSCst = cast<Constant>(Cmp->getOperand(1));
@@ -384,14 +385,14 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
// If the value is known by LazyValueInfo to be a constant in a
// predecessor, use that information to try to thread this block.
- Constant *PredCst = LVI->getConstantOnEdge(Cmp->getOperand(0), *PI, BB);
- if (PredCst == 0)
+ LazyValueInfo::Tristate
+ Res = LVI->getPredicateOnEdge(Cmp->getPredicate(), Cmp->getOperand(0),
+ RHSCst, *PI, BB);
+ if (Res == LazyValueInfo::Unknown)
continue;
-
- // Constant fold the compare.
- Value *Res = SimplifyCmpInst(Cmp->getPredicate(), PredCst, RHSCst, TD);
- if (isa<ConstantInt>(Res) || isa<UndefValue>(Res))
- Result.push_back(std::make_pair(dyn_cast<ConstantInt>(Res), *PI));
+
+ Constant *ResC = ConstantInt::get(Cmp->getType(), Res);
+ Result.push_back(std::make_pair(cast<ConstantInt>(ResC), *PI));
}
return !Result.empty();
@@ -498,7 +499,8 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
// br COND, BBX, BBY
// BBX:
// br COND, BBZ, BBW
- if (!Condition->hasOneUse() && // Multiple uses.
+ if (!LVI &&
+ !Condition->hasOneUse() && // Multiple uses.
(CondInst == 0 || CondInst->getParent() != BB)) { // Non-local definition.
pred_iterator PI = pred_begin(BB), E = pred_end(BB);
if (isa<BranchInst>(BB->getTerminator())) {
@@ -532,8 +534,9 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) {
return ProcessJumpOnPHI(PN);
if (CmpInst *CondCmp = dyn_cast<CmpInst>(CondInst)) {
- if (!isa<PHINode>(CondCmp->getOperand(0)) ||
- cast<PHINode>(CondCmp->getOperand(0))->getParent() != BB) {
+ if (!LVI &&
+ (!isa<PHINode>(CondCmp->getOperand(0)) ||
+ cast<PHINode>(CondCmp->getOperand(0))->getParent() != BB)) {
// If we have a comparison, loop over the predecessors to see if there is
// a condition with a lexically identical value.
pred_iterator PI = pred_begin(BB), E = pred_end(BB);
OpenPOWER on IntegriCloud