Skip to content

Commit

Permalink
[LSR][NFC] don't collect chains when isNumRegsMajorCostOfLSR is false.
Browse files Browse the repository at this point in the history
Reviewed By: samparker

Differential Revision: https://reviews.llvm.org/D92159
  • Loading branch information
chenzheng1030 committed Dec 2, 2020
1 parent 60653e2 commit 3cb7d62
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Expand Up @@ -2858,20 +2858,12 @@ static bool isProfitableChain(IVChain &Chain,
unsigned NumVarIncrements = 0;
unsigned NumReusedIncrements = 0;

// If any LSRUse in the chain is marked as profitable by target, mark this
// chain as profitable.
for (const IVInc &Inc : Chain.Incs)
if (TTI.isProfitableLSRChainElement(Inc.UserInst))
return true;

// If number of registers is not the major cost, we cannot benefit from this
// profitable chain which is based on number of registers.
// FIXME: add profitable chain optimization for other kinds major cost, for
// example number of instructions.
if (!TTI.isNumRegsMajorCostOfLSR())
return false;
if (TTI.isProfitableLSRChainElement(Chain.Incs[0].UserInst))
return true;

for (const IVInc &Inc : Chain) {
if (TTI.isProfitableLSRChainElement(Inc.UserInst))
return true;
if (Inc.IncExpr->isZero())
continue;

Expand Down Expand Up @@ -5635,7 +5627,13 @@ LSRInstance::LSRInstance(Loop *L, IVUsers &IU, ScalarEvolution &SE,
}

// Start collecting data and preparing for the solver.
CollectChains();
// If number of registers is not the major cost, we cannot benefit from the
// current profitable chain optimization which is based on number of
// registers.
// FIXME: add profitable chain optimization for other kinds major cost, for
// example number of instructions.
if (TTI.isNumRegsMajorCostOfLSR() || StressIVChain)
CollectChains();
CollectInterestingTypesAndFactors();
CollectFixupsAndInitialFormulae();
CollectLoopInvariantFixupsAndFormulae();
Expand Down

0 comments on commit 3cb7d62

Please sign in to comment.