diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2020-02-25 21:53:12 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2020-02-25 23:05:59 +0300 |
commit | 400ceda425ab392096ff2800acad41a4322974d2 (patch) | |
tree | afa6f4c4a0ed8ead0440dba12078359d54ae27e7 /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 44edc6fd2c63b7db43e13cc8caf1fee79bebdb5f (diff) | |
download | llvm-400ceda425ab392096ff2800acad41a4322974d2.zip llvm-400ceda425ab392096ff2800acad41a4322974d2.tar.gz llvm-400ceda425ab392096ff2800acad41a4322974d2.tar.bz2 |
[SCEV][IndVars] Always provide insertion point to the SCEVExpander::isHighCostExpansion()
Summary: This addresses the `llvm/test/Transforms/IndVarSimplify/elim-extend.ll` `@nestedIV` regression from D73728
Reviewers: reames, mkazantsev, wmi, sanjoy
Reviewed By: mkazantsev
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73777
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 65a88ea..a09f1f3 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -2136,7 +2136,7 @@ SCEVExpander::getRelatedExistingExpansion(const SCEV *S, const Instruction *At, } bool SCEVExpander::isHighCostExpansionHelper( - const SCEV *S, Loop *L, const Instruction *At, int &BudgetRemaining, + const SCEV *S, Loop *L, const Instruction &At, int &BudgetRemaining, const TargetTransformInfo &TTI, SmallPtrSetImpl<const SCEV *> &Processed) { if (BudgetRemaining < 0) return true; // Already run out of budget, give up. @@ -2147,7 +2147,7 @@ bool SCEVExpander::isHighCostExpansionHelper( // If we can find an existing value for this scev available at the point "At" // then consider the expression cheap. - if (At && getRelatedExistingExpansion(S, At, L)) + if (getRelatedExistingExpansion(S, &At, L)) return false; // Consider the expression to be free. switch (S->getSCEVType()) { @@ -2198,18 +2198,12 @@ bool SCEVExpander::isHighCostExpansionHelper( // UDiv from the user's code. If we can't find a UDiv in the code with some // simple searching, we need to account for it's cost. - BasicBlock *ExitingBB = L->getExitingBlock(); - if (At || ExitingBB) { - if (!At) - At = &ExitingBB->back(); - - // At the beginning of this function we already tried to find existing - // value for plain 'S'. Now try to lookup 'S + 1' since it is common - // pattern involving division. This is just a simple search heuristic. - if (getRelatedExistingExpansion( - SE.getAddExpr(S, SE.getConstant(S->getType(), 1)), At, L)) - return false; // Consider it to be free. - } + // At the beginning of this function we already tried to find existing + // value for plain 'S'. Now try to lookup 'S + 1' since it is common + // pattern involving division. This is just a simple search heuristic. + if (getRelatedExistingExpansion( + SE.getAddExpr(S, SE.getConstant(S->getType(), 1)), &At, L)) + return false; // Consider it to be free. // Need to count the cost of this UDiv. BudgetRemaining -= TTI.getOperationCost(Instruction::UDiv, S->getType()); |