diff options
author | Frits van Bommel <fvbommel@gmail.com> | 2010-12-07 13:08:07 +0000 |
---|---|---|
committer | Frits van Bommel <fvbommel@gmail.com> | 2010-12-07 13:08:07 +0000 |
commit | 8e8cdc8fe03db3eb4bed463281d30a053b8770cc (patch) | |
tree | e92e79cfc6fd2f4c1e2036eb61701cb3191ac55c /lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 729b2949d7655803968cb1f94a77cc8e83cb1c7b (diff) | |
download | external_llvm-8e8cdc8fe03db3eb4bed463281d30a053b8770cc.zip external_llvm-8e8cdc8fe03db3eb4bed463281d30a053b8770cc.tar.gz external_llvm-8e8cdc8fe03db3eb4bed463281d30a053b8770cc.tar.bz2 |
Remove some dead code from the jump threading pass.
The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 27bd668..84dbb1a 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -121,10 +121,6 @@ namespace { bool ProcessThreadableEdges(Value *Cond, BasicBlock *BB, ConstantPreference Preference); - - bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); - bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); - bool ProcessBranchOnPHI(PHINode *PN); bool ProcessBranchOnXOR(BinaryOperator *BO); @@ -753,143 +749,6 @@ bool JumpThreading::ProcessBlock(BasicBlock *BB) { return false; } -/// ProcessBranchOnDuplicateCond - We found a block and a predecessor of that -/// block that jump on exactly the same condition. This means that we almost -/// always know the direction of the edge in the DESTBB: -/// PREDBB: -/// br COND, DESTBB, BBY -/// DESTBB: -/// br COND, BBZ, BBW -/// -/// If DESTBB has multiple predecessors, we can't just constant fold the branch -/// in DESTBB, we have to thread over it. -bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB, - BasicBlock *BB) { - BranchInst *PredBI = cast<BranchInst>(PredBB->getTerminator()); - - // If both successors of PredBB go to DESTBB, we don't know anything. We can - // fold the branch to an unconditional one, which allows other recursive - // simplifications. - bool BranchDir; - if (PredBI->getSuccessor(1) != BB) - BranchDir = true; - else if (PredBI->getSuccessor(0) != BB) - BranchDir = false; - else { - DEBUG(dbgs() << " In block '" << PredBB->getName() - << "' folding terminator: " << *PredBB->getTerminator() << '\n'); - ++NumFolds; - ConstantFoldTerminator(PredBB); - return true; - } - - BranchInst *DestBI = cast<BranchInst>(BB->getTerminator()); - - // If the dest block has one predecessor, just fix the branch condition to a - // constant and fold it. - if (BB->getSinglePredecessor()) { - DEBUG(dbgs() << " In block '" << BB->getName() - << "' folding condition to '" << BranchDir << "': " - << *BB->getTerminator() << '\n'); - ++NumFolds; - Value *OldCond = DestBI->getCondition(); - DestBI->setCondition(ConstantInt::get(Type::getInt1Ty(BB->getContext()), - BranchDir)); - // Delete dead instructions before we fold the branch. Folding the branch - // can eliminate edges from the CFG which can end up deleting OldCond. - RecursivelyDeleteTriviallyDeadInstructions(OldCond); - ConstantFoldTerminator(BB); - return true; - } - - - // Next, figure out which successor we are threading to. - BasicBlock *SuccBB = DestBI->getSuccessor(!BranchDir); - - SmallVector<BasicBlock*, 2> Preds; - Preds.push_back(PredBB); - - // Ok, try to thread it! - return ThreadEdge(BB, Preds, SuccBB); -} - -/// ProcessSwitchOnDuplicateCond - We found a block and a predecessor of that -/// block that switch on exactly the same condition. This means that we almost -/// always know the direction of the edge in the DESTBB: -/// PREDBB: -/// switch COND [... DESTBB, BBY ... ] -/// DESTBB: -/// switch COND [... BBZ, BBW ] -/// -/// Optimizing switches like this is very important, because simplifycfg builds -/// switches out of repeated 'if' conditions. -bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, - BasicBlock *DestBB) { - // Can't thread edge to self. - if (PredBB == DestBB) - return false; - - SwitchInst *PredSI = cast<SwitchInst>(PredBB->getTerminator()); - SwitchInst *DestSI = cast<SwitchInst>(DestBB->getTerminator()); - - // There are a variety of optimizations that we can potentially do on these - // blocks: we order them from most to least preferable. - - // If DESTBB *just* contains the switch, then we can forward edges from PREDBB - // directly to their destination. This does not introduce *any* code size - // growth. Skip debug info first. - BasicBlock::iterator BBI = DestBB->begin(); - while (isa<DbgInfoIntrinsic>(BBI)) - BBI++; - - // FIXME: Thread if it just contains a PHI. - if (isa<SwitchInst>(BBI)) { - bool MadeChange = false; - // Ignore the default edge for now. - for (unsigned i = 1, e = DestSI->getNumSuccessors(); i != e; ++i) { - ConstantInt *DestVal = DestSI->getCaseValue(i); - BasicBlock *DestSucc = DestSI->getSuccessor(i); - - // Okay, DestSI has a case for 'DestVal' that goes to 'DestSucc'. See if - // PredSI has an explicit case for it. If so, forward. If it is covered - // by the default case, we can't update PredSI. - unsigned PredCase = PredSI->findCaseValue(DestVal); - if (PredCase == 0) continue; - - // If PredSI doesn't go to DestBB on this value, then it won't reach the - // case on this condition. - if (PredSI->getSuccessor(PredCase) != DestBB && - DestSI->getSuccessor(i) != DestBB) - continue; - - // Do not forward this if it already goes to this destination, this would - // be an infinite loop. - if (PredSI->getSuccessor(PredCase) == DestSucc) - continue; - - // Otherwise, we're safe to make the change. Make sure that the edge from - // DestSI to DestSucc is not critical and has no PHI nodes. - DEBUG(dbgs() << "FORWARDING EDGE " << *DestVal << " FROM: " << *PredSI); - DEBUG(dbgs() << "THROUGH: " << *DestSI); - - // If the destination has PHI nodes, just split the edge for updating - // simplicity. - if (isa<PHINode>(DestSucc->begin()) && !DestSucc->getSinglePredecessor()){ - SplitCriticalEdge(DestSI, i, this); - DestSucc = DestSI->getSuccessor(i); - } - FoldSingleEntryPHINodes(DestSucc); - PredSI->setSuccessor(PredCase, DestSucc); - MadeChange = true; - } - - if (MadeChange) - return true; - } - - return false; -} - /// SimplifyPartiallyRedundantLoad - If LI is an obviously partially redundant /// load instruction, eliminate it by replacing it with a PHI node. This is an |