[llvm-branch-commits] [llvm] 3cb7d62 - [LSR][NFC] don't collect chains when isNumRegsMajorCostOfLSR is false.
Chen Zheng via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 1 19:34:22 PST 2020
Author: Chen Zheng
Date: 2020-12-01T22:29:33-05:00
New Revision: 3cb7d6245249d61f443abfacc6d7b0272a71535e
URL: https://github.com/llvm/llvm-project/commit/3cb7d6245249d61f443abfacc6d7b0272a71535e
DIFF: https://github.com/llvm/llvm-project/commit/3cb7d6245249d61f443abfacc6d7b0272a71535e.diff
LOG: [LSR][NFC] don't collect chains when isNumRegsMajorCostOfLSR is false.
Reviewed By: samparker
Differential Revision: https://reviews.llvm.org/D92159
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Removed:
################################################################################
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();
More information about the llvm-branch-commits
mailing list