[PATCH] D37087: [InlineCost] Small changes to early exit condition. NFC.

Haicheng Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 16:40:42 PDT 2017


haicheng created this revision.

If `Cost < Threshold`, we will try to inline the callee.  So, we can early exit when `Cost >= Threshold` which is earlier than `Cost > Threshold`.


Repository:
  rL LLVM

https://reviews.llvm.org/D37087

Files:
  lib/Analysis/InlineCost.cpp


Index: lib/Analysis/InlineCost.cpp
===================================================================
--- lib/Analysis/InlineCost.cpp
+++ lib/Analysis/InlineCost.cpp
@@ -1206,7 +1206,7 @@
       std::min((int64_t)CostUpperBound,
                (int64_t)SI.getNumCases() * InlineConstants::InstrCost + Cost);
 
-  if (CostLowerBound > Threshold && !ComputeFullInlineCost) {
+  if (CostLowerBound >= Threshold && !ComputeFullInlineCost) {
     Cost = CostLowerBound;
     return false;
   }
@@ -1384,7 +1384,7 @@
 
     // Check if we've past the maximum possible threshold so we don't spin in
     // huge basic blocks that will never inline.
-    if (Cost > Threshold && !ComputeFullInlineCost)
+    if (Cost >= Threshold && !ComputeFullInlineCost)
       return false;
   }
 
@@ -1470,7 +1470,7 @@
     Cost += InlineConstants::ColdccPenalty;
 
   // Check if we're done. This can happen due to bonuses and penalties.
-  if (Cost > Threshold && !ComputeFullInlineCost)
+  if (Cost >= Threshold && !ComputeFullInlineCost)
     return false;
 
   if (F.empty())
@@ -1536,7 +1536,7 @@
   for (unsigned Idx = 0; Idx != BBWorklist.size(); ++Idx) {
     // Bail out the moment we cross the threshold. This means we'll under-count
     // the cost, but only when undercounting doesn't matter.
-    if (Cost > Threshold && !ComputeFullInlineCost)
+    if (Cost >= Threshold && !ComputeFullInlineCost)
       break;
 
     BasicBlock *BB = BBWorklist[Idx];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37087.112481.patch
Type: text/x-patch
Size: 1451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170823/e65a782a/attachment.bin>


More information about the llvm-commits mailing list