Avoid inserting noop's in the middle of a loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60141 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2008-11-27 01:16:00 +00:00
parent 884c70c912
commit df90841690
2 changed files with 39 additions and 1 deletions

View File

@ -64,8 +64,14 @@ bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
MachineBasicBlock *MBB = I;
if (MLI->isLoopHeader(MBB))
if (MLI->isLoopHeader(MBB)) {
MachineBasicBlock *PredBB = prior(I);
if (MLI->getLoopFor(MBB) == MLI->getLoopFor(PredBB))
// If previously BB is in the same loop, don't align this BB. We want
// to prevent adding noop's inside a loop.
continue;
MBB->setAlignment(Align);
}
}
return true;