[Unroll] Don't analyze blocks outside the loop.

llvm-svn: 243466
This commit is contained in:
Michael Zolotukhin 2015-07-28 19:21:21 +00:00
parent d20aba7047
commit a425c9d0e3
1 changed files with 8 additions and 4 deletions

View File

@ -586,16 +586,20 @@ analyzeLoopUnrollCost(const Loop *L, unsigned TripCount, ScalarEvolution &SE,
if (BI->isConditional()) {
if (Constant *SimpleCond =
SimplifiedValues.lookup(BI->getCondition())) {
BBWorklist.insert(BI->getSuccessor(
cast<ConstantInt>(SimpleCond)->isZero() ? 1 : 0));
BasicBlock *Succ = BI->getSuccessor(
cast<ConstantInt>(SimpleCond)->isZero() ? 1 : 0);
if (L->contains(Succ))
BBWorklist.insert(Succ);
continue;
}
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
if (Constant *SimpleCond =
SimplifiedValues.lookup(SI->getCondition())) {
BBWorklist.insert(
SI->getSuccessor(cast<ConstantInt>(SimpleCond)->getSExtValue()));
BasicBlock *Succ =
SI->getSuccessor(cast<ConstantInt>(SimpleCond)->getSExtValue());
if (L->contains(Succ))
BBWorklist.insert(Succ);
continue;
}
}