[llvm-commits] [llvm] r49061 - in /llvm/trunk/lib/Transforms: IPO/Inliner.cpp Utils/InlineCost.cpp

Evan Cheng evan.cheng at apple.com
Tue Apr 1 16:59:29 PDT 2008


Author: evancheng
Date: Tue Apr  1 18:59:29 2008
New Revision: 49061

URL: http://llvm.org/viewvc/llvm-project?rev=49061&view=rev
Log:
1. Drop default inline threshold back down to 200.
2. Do not use # of basic blocks as part of the cost computation since it doesn't really figure into function size.
3. More aggressively inline function with vector code.

Modified:
    llvm/trunk/lib/Transforms/IPO/Inliner.cpp
    llvm/trunk/lib/Transforms/Utils/InlineCost.cpp

Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=49061&r1=49060&r2=49061&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Apr  1 18:59:29 2008
@@ -32,8 +32,8 @@
 
 namespace {
   cl::opt<int>
-  InlineLimit("inline-threshold", cl::Hidden, cl::init(400),
-        cl::desc("Control the amount of inlining to perform (default = 400)"));
+  InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
+        cl::desc("Control the amount of inlining to perform (default = 200)"));
 }
 
 Inliner::Inliner(const void *ID) 

Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=49061&r1=49060&r2=49061&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Tue Apr  1 18:59:29 2008
@@ -234,14 +234,12 @@
   // Now that we have considered all of the factors that make the call site more
   // likely to be inlined, look at factors that make us not want to inline it.
   
-  // Don't inline into something too big, which would make it bigger.  Here, we
-  // count each basic block as a single unit.
+  // Don't inline into something too big, which would make it bigger.
   //
   InlineCost += Caller->size()/20;
   
-  // Look at the size of the callee.  Each basic block counts as 20 units, and
-  // each instruction counts as 5.
-  InlineCost += CalleeFI.NumInsts*5 + CalleeFI.NumBlocks*20;
+  // Look at the size of the callee. Each instruction counts as 5.
+  InlineCost += CalleeFI.NumInsts*5;
 
   return InlineCost;
 }
@@ -258,9 +256,16 @@
   if (CalleeFI.NumBlocks == 0)
     CalleeFI.analyzeFunction(Callee);
 
+  float Factor = 1.0f;
+  // Single BB functions are often written to be inlined.
+  if (CalleeFI.NumBlocks == 1)
+    Factor += 0.5f;
+
   // Be more aggressive if the function contains a good chunk (if it mades up
   // at least 10% of the instructions) of vector instructions.
-  if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/10)
-    return 1.5f;
-  return 1.0f;
+  if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/2)
+    Factor += 2.0f;
+  else if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/10)
+    Factor += 1.5f;
+  return Factor;
 }





More information about the llvm-commits mailing list