mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Avoid non-trivial loop unswitching while optimizing for size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -127,7 +127,7 @@ LoopPass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
|
|||||||
//
|
//
|
||||||
// LoopUnswitch - This pass is a simple loop unswitching pass.
|
// LoopUnswitch - This pass is a simple loop unswitching pass.
|
||||||
//
|
//
|
||||||
LoopPass *createLoopUnswitchPass();
|
LoopPass *createLoopUnswitchPass(bool Os = false);
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
|
@@ -68,9 +68,11 @@ namespace {
|
|||||||
std::vector<Loop*> LoopProcessWorklist;
|
std::vector<Loop*> LoopProcessWorklist;
|
||||||
SmallPtrSet<Value *,8> UnswitchedVals;
|
SmallPtrSet<Value *,8> UnswitchedVals;
|
||||||
|
|
||||||
|
bool OptimizeForSize;
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass ID, replacement for typeid
|
static char ID; // Pass ID, replacement for typeid
|
||||||
LoopUnswitch() : LoopPass((intptr_t)&ID) {}
|
LoopUnswitch(bool Os = false) :
|
||||||
|
LoopPass((intptr_t)&ID), OptimizeForSize(Os) {}
|
||||||
|
|
||||||
bool runOnLoop(Loop *L, LPPassManager &LPM);
|
bool runOnLoop(Loop *L, LPPassManager &LPM);
|
||||||
|
|
||||||
@@ -116,7 +118,9 @@ namespace {
|
|||||||
RegisterPass<LoopUnswitch> X("loop-unswitch", "Unswitch loops");
|
RegisterPass<LoopUnswitch> X("loop-unswitch", "Unswitch loops");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopPass *llvm::createLoopUnswitchPass() { return new LoopUnswitch(); }
|
LoopPass *llvm::createLoopUnswitchPass(bool Os) {
|
||||||
|
return new LoopUnswitch(Os);
|
||||||
|
}
|
||||||
|
|
||||||
/// FindLIVLoopCondition - Cond is a condition that occurs in L. If it is
|
/// FindLIVLoopCondition - Cond is a condition that occurs in L. If it is
|
||||||
/// invariant in the loop, or has an invariant piece, return the invariant.
|
/// invariant in the loop, or has an invariant piece, return the invariant.
|
||||||
@@ -359,6 +363,11 @@ unsigned LoopUnswitch::getLoopUnswitchCost(Loop *L, Value *LIC) {
|
|||||||
bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
|
bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
|
||||||
// Check to see if it would be profitable to unswitch this loop.
|
// Check to see if it would be profitable to unswitch this loop.
|
||||||
unsigned Cost = getLoopUnswitchCost(L, LoopCond);
|
unsigned Cost = getLoopUnswitchCost(L, LoopCond);
|
||||||
|
|
||||||
|
// Do not do non-trivial unswitch while optimizing for size.
|
||||||
|
if (Cost && OptimizeForSize)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (Cost > Threshold) {
|
if (Cost > Threshold) {
|
||||||
// FIXME: this should estimate growth by the amount of code shared by the
|
// FIXME: this should estimate growth by the amount of code shared by the
|
||||||
// resultant unswitched loops.
|
// resultant unswitched loops.
|
||||||
|
Reference in New Issue
Block a user