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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 12:11:16 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1622f3e074cb: [NFC][SCEV] SCEVExpander::isHighCostExpansionHelper(): check that we processed… (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73706/new/

https://reviews.llvm.org/D73706

Files:
  llvm/lib/Analysis/ScalarEvolutionExpander.cpp


Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -2138,6 +2138,10 @@
 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 @@
                                      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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73706.246532.patch
Type: text/x-patch
Size: 1096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200225/73b45f43/attachment.bin>


More information about the llvm-commits mailing list