diff options
author | Eric Christopher <echristo@apple.com> | 2010-01-14 20:12:34 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-01-14 20:12:34 +0000 |
commit | f3ac06641843b27f525284fc6243cb93cc1c9586 (patch) | |
tree | 9b7f3a1c7bcd2240f1efed4fc80300b614274616 /llvm/lib/Analysis | |
parent | 8cb7a8a39c4d4dfdc164fc0d1a3bcb7a91d9b0df (diff) | |
download | bcm5719-llvm-f3ac06641843b27f525284fc6243cb93cc1c9586.tar.gz bcm5719-llvm-f3ac06641843b27f525284fc6243cb93cc1c9586.zip |
Reduce the inlining cost of functions that contain calls to easily,
and frequently optimized functions.
llvm-svn: 93448
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index bd9377bf87f..206f4c968a6 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -102,6 +102,32 @@ unsigned InlineCostAnalyzer::FunctionInfo:: return Reduction; } +// callIsSmall - If a call will lower to a single selection DAG node, or +// is otherwise deemed small return true. +// TODO: Perhaps calls like memcpy, strcpy, etc? +static bool callIsSmall(const Function *F) { + if (F && !F->hasLocalLinkage() && F->hasName()) { + StringRef Name = F->getName(); + + // These will all likely lower to a single selection DAG node. + if (Name == "copysign" || Name == "copysignf" || + Name == "fabs" || Name == "fabsf" || Name == "fabsl" || + Name == "sin" || Name == "sinf" || Name == "sinl" || + Name == "cos" || Name == "cosf" || Name == "cosl" || + Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ) + return true; + + // These are all likely to be optimized into something smaller. + if (Name == "pow" || Name == "powf" || Name == "powl" || + Name == "exp2" || Name == "exp2l" || Name == "exp2f" || + Name == "floor" || Name == "floorf" || Name == "ceil" || + Name == "round" || Name == "ffs" || Name == "ffsl" || + Name == "abs" || Name == "labs" || Name == "llabs") + return true; + } + return false; +} + /// analyzeBasicBlock - Fill in the current structure with information gleaned /// from the specified block. void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) { @@ -129,7 +155,7 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) { // Calls often compile into many machine instructions. Bump up their // cost to reflect this. - if (!isa<IntrinsicInst>(II)) + if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction())) NumInsts += InlineConstants::CallPenalty; } |