Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll

llvm-svn: 28758
This commit is contained in:
Chris Lattner 2006-06-12 20:18:01 +00:00
parent 9c4ddf8314
commit b5c9d7a0af
1 changed files with 10 additions and 1 deletions

View File

@ -1521,6 +1521,15 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
BasicBlock *CommonDest = PBI->getSuccessor(PBIOp);
BasicBlock *OtherDest = BI->getSuccessor(BIOp ^ 1);
// If OtherDest *is* BB, then this is a basic block with just
// a conditional branch in it, where one edge (OtherDesg) goes
// back to the block. We know that the program doesn't get
// stuck in the infinite loop, so the condition must be such
// that OtherDest isn't branched through. Forward to CommonDest,
// and avoid an infinite loop at optimizer time.
if (OtherDest == BB)
OtherDest = CommonDest;
DEBUG(std::cerr << "FOLDING BRs:" << *PBI->getParent()
<< "AND: " << *BI->getParent());