aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp22
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());