Insert new pre-header before new header. Original pre-header may

happen to be an entry, in such case, it is not a good idea to
insert new block before entry.

Also fix typo in assertion check.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35833 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2007-04-09 21:40:43 +00:00
parent 050d541d08
commit c415afc726

View File

@ -429,7 +429,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) {
// exit block. Insert new block between original pre-header and
// new header such that loop's new pre-header has only one successor.
BasicBlock *NewPreHeader = new BasicBlock("bb.nph", OrigHeader->getParent(),
OrigPreHeader);
NewHeader);
LoopInfo &LI = LPM.getAnalysis<LoopInfo>();
if (Loop *PL = LI.getLoopFor(OrigPreHeader))
PL->addBasicBlockToLoop(NewPreHeader, LI);
@ -439,7 +439,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) {
if (OrigPH_BI->getSuccessor(0) == NewHeader)
OrigPH_BI->setSuccessor(0, NewPreHeader);
else {
assert (OrigPH_BI->getSuccessor(1) == NewPreHeader &&
assert (OrigPH_BI->getSuccessor(1) == NewHeader &&
"Unexpected original pre-header terminator");
OrigPH_BI->setSuccessor(1, NewPreHeader);
}