[llvm] 1622f3e - [NFC][SCEV] SCEVExpander::isHighCostExpansionHelper(): check that we processed expression first

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 12:07:02 PST 2020


Author: Roman Lebedev
Date: 2020-02-25T23:05:57+03:00
New Revision: 1622f3e074cb72feadd6f9d32f21d2030d3bdc47

URL: https://github.com/llvm/llvm-project/commit/1622f3e074cb72feadd6f9d32f21d2030d3bdc47
DIFF: https://github.com/llvm/llvm-project/commit/1622f3e074cb72feadd6f9d32f21d2030d3bdc47.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolutionExpander.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index 146db097d6aa..e8f267a39225 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -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


        


More information about the llvm-commits mailing list