[NFC][SCEV] SCEVExpander::isHighCostExpansionHelper(): check that we processed expression first

Summary:
As far as i can tell this is still NFC.
Initially in rL146438 it was added at the top of the function,
later rL238507 dethroned it, and rL244474 did it again.

I'm not sure if we have already checked the cost of this expansion, we should be doing that again.

Reviewers: reames, mkazantsev, wmi, sanjoy, atrick, igor-laevsky

Reviewed By: mkazantsev

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73706
This commit is contained in:
Roman Lebedev 2020-02-25 21:51:06 +03:00
parent b99c91a087
commit 1622f3e074
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
1 changed files with 4 additions and 2 deletions

View File

@ -2138,6 +2138,10 @@ SCEVExpander::getRelatedExistingExpansion(const SCEV *S, const Instruction *At,
bool SCEVExpander::isHighCostExpansionHelper(
const SCEV *S, Loop *L, const Instruction *At, int &BudgetRemaining,
const TargetTransformInfo *TTI, SmallPtrSetImpl<const SCEV *> &Processed) {
// Was the cost of expansion of this expression already accounted for?
if (!Processed.insert(S).second)
return false; // We have already accounted for this expression.
// 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))
@ -2159,8 +2163,6 @@ bool SCEVExpander::isHighCostExpansionHelper(
L, At, BudgetRemaining, TTI, Processed);
}
if (!Processed.insert(S).second)
return false;
if (auto *UDivExpr = dyn_cast<SCEVUDivExpr>(S)) {
// If the divisor is a power of two and the SCEV type fits in a native