-/// SingleDominatingExit - Checks that there is only a single blocks that
-/// branches out of the loop, and that it also g the latch block. Loops
-/// with multiple or non-latch-dominating exiting blocks could be dead, but we'd
-/// have to do more extensive analysis to make sure, for instance, that the
-/// control flow logic involved was or could be made loop-invariant.
-bool LoopDeletion::SingleDominatingExit(Loop* L,
- SmallVector<BasicBlock*, 4>& exitingBlocks) {
-
- if (exitingBlocks.size() != 1)
- return false;
-
- BasicBlock* latch = L->getLoopLatch();
- if (!latch)
- return false;
-
- DominatorTree& DT = getAnalysis<DominatorTree>();
- return DT.dominates(exitingBlocks[0], latch);
-}
-
-/// IsLoopInvariantInst - Checks if an instruction is invariant with respect to
-/// a loop, which is defined as being true if all of its operands are defined
-/// outside of the loop. These instructions can be hoisted out of the loop
-/// if their results are needed. This could be made more aggressive by
-/// recursively checking the operands for invariance, but it's not clear that
-/// it's worth it.
-bool LoopDeletion::IsLoopInvariantInst(Instruction *I, Loop* L) {
- // PHI nodes are not loop invariant if defined in the loop.
- if (isa<PHINode>(I) && L->contains(I->getParent()))
- return false;
-
- // The instruction is loop invariant if all of its operands are loop-invariant
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (!L->isLoopInvariant(I->getOperand(i)))
- return false;
-
- // If we got this far, the instruction is loop invariant!
- return true;
-}
-
-/// IsLoopDead - Determined if a loop is dead. This assumes that we've already