forked from OSchip/llvm-project
[LoopUnswitch] Check OptimizeForSize before traversing over all basic blocks in current loop
Summary: This patch moves the check of OptimizeForSize before traversing over all basic blocks in current loop. If OptimizeForSize is set to true, no non-trivial unswitch is ever allowed. Therefore, the early exit will help reduce compilation time. This patch should be NFC. Reviewers: reames, weimingz, broune Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11997 llvm-svn: 244868
This commit is contained in:
parent
1193f2cbc0
commit
f458c6f313
|
@ -463,6 +463,12 @@ bool LoopUnswitch::processCurrentLoop() {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Do not do non-trivial unswitch while optimizing for size.
|
||||
// FIXME: Use Function::optForSize().
|
||||
if (OptimizeForSize ||
|
||||
loopHeader->getParent()->hasFnAttribute(Attribute::OptimizeForSize))
|
||||
return false;
|
||||
|
||||
// Loop over all of the basic blocks in the loop. If we find an interior
|
||||
// block that is branching on a loop-invariant condition, we can unswitch this
|
||||
// loop.
|
||||
|
@ -586,8 +592,6 @@ static BasicBlock *isTrivialLoopExitBlock(Loop *L, BasicBlock *BB) {
|
|||
/// unswitch the loop, reprocess the pieces, then return true.
|
||||
bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,
|
||||
TerminatorInst *TI) {
|
||||
Function *F = loopHeader->getParent();
|
||||
|
||||
// Check to see if it would be profitable to unswitch current loop.
|
||||
if (!BranchesInfo.CostAllowsUnswitching()) {
|
||||
DEBUG(dbgs() << "NOT unswitching loop %"
|
||||
|
@ -598,11 +602,6 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Do not do non-trivial unswitch while optimizing for size.
|
||||
// FIXME: Use Function::optForSize().
|
||||
if (OptimizeForSize || F->hasFnAttribute(Attribute::OptimizeForSize))
|
||||
return false;
|
||||
|
||||
UnswitchNontrivialCondition(LoopCond, Val, currentLoop, TI);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue