[llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Sep 9 13:40:58 PDT 2006
Changes in directory llvm/lib/Transforms/IPO:
InlineSimple.cpp updated: 1.73 -> 1.74
---
Log message:
Make inlining costs more accurate.
---
Diffs of the changes: (+26 -3)
InlineSimple.cpp | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.73 llvm/lib/Transforms/IPO/InlineSimple.cpp:1.74
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.73 Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/IPO/InlineSimple.cpp Sat Sep 9 15:40:44 2006
@@ -138,9 +138,32 @@
// each instruction counts as 10.
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
for (BasicBlock::const_iterator II = BB->begin(), E = BB->end();
- II != E; ++II)
- if (!isa<DbgInfoIntrinsic>(II))
- ++NumInsts;
+ II != E; ++II) {
+ if (isa<DbgInfoIntrinsic>(II)) continue; // Debug intrinsics don't count.
+
+ // Noop casts don't count.
+ if (const CastInst *CI = dyn_cast<CastInst>(II)) {
+ const Type *OpTy = CI->getOperand(0)->getType();
+ if (CI->getType()->isLosslesslyConvertibleTo(OpTy))
+ continue;
+ if ((isa<PointerType>(CI->getType()) && OpTy->isInteger()) ||
+ (isa<PointerType>(OpTy) && CI->getType()->isInteger()))
+ continue; // ptr <-> int is *probably* noop cast.
+ } else if (const GetElementPtrInst *GEPI =
+ dyn_cast<GetElementPtrInst>(II)) {
+ // If a GEP has all constant indices, it will probably be folded with
+ // a load/store.
+ bool AllConstant = true;
+ for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i)
+ if (!isa<ConstantInt>(GEPI->getOperand(i))) {
+ AllConstant = false;
+ break;
+ }
+ if (AllConstant) continue;
+ }
+
+ ++NumInsts;
+ }
++NumBlocks;
}
More information about the llvm-commits
mailing list