From: Michael Zolotukhin Date: Tue, 28 Jul 2015 19:21:21 +0000 (+0000) Subject: [Unroll] Don't analyze blocks outside the loop. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8ae1a0f7895286c7435ffc0519c830f480266d5e;p=oota-llvm.git [Unroll] Don't analyze blocks outside the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243466 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index 89b3d47c88f..513c5a4dc51 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -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(SimpleCond)->isZero() ? 1 : 0)); + BasicBlock *Succ = BI->getSuccessor( + cast(SimpleCond)->isZero() ? 1 : 0); + if (L->contains(Succ)) + BBWorklist.insert(Succ); continue; } } } else if (SwitchInst *SI = dyn_cast(TI)) { if (Constant *SimpleCond = SimplifiedValues.lookup(SI->getCondition())) { - BBWorklist.insert( - SI->getSuccessor(cast(SimpleCond)->getSExtValue())); + BasicBlock *Succ = + SI->getSuccessor(cast(SimpleCond)->getSExtValue()); + if (L->contains(Succ)) + BBWorklist.insert(Succ); continue; } }