[llvm] r244868 - [LoopUnswitch] Check OptimizeForSize before traversing over all basic blocks in current loop
Chen Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 22:24:30 PDT 2015
Author: chenli
Date: Thu Aug 13 00:24:29 2015
New Revision: 244868
URL: http://llvm.org/viewvc/llvm-project?rev=244868&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=244868&r1=244867&r2=244868&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Aug 13 00:24:29 2015
@@ -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 *isTrivialLoopExitBloc
/// 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(
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;
}
More information about the llvm-commits
mailing list