aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorChen Zheng <czhengsz@cn.ibm.com>2020-11-26 04:26:23 -0500
committerChen Zheng <czhengsz@cn.ibm.com>2020-12-01 22:29:33 -0500
commit3cb7d6245249d61f443abfacc6d7b0272a71535e (patch)
tree61bf4bea5d24fb2295d6b5b0e9f55dd3def7da91 /llvm/lib/Transforms/Scalar
parent60653e24b6297f2830b9de649f575840ecb364b6 (diff)
downloadllvm-project-3cb7d6245249d61f443abfacc6d7b0272a71535e.tar.gz
[LSR][NFC] don't collect chains when isNumRegsMajorCostOfLSR is false.
Reviewed By: samparker Differential Revision: https://reviews.llvm.org/D92159
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index a1d182931d0f..bfd8f00c228e 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -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;
@@ -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();