diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-21 23:37:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-21 23:37:18 +0000 |
commit | 58be2d4413008ebadbcc67bffa739c4a7327311e (patch) | |
tree | 65ddb3ef529f94acaf21fa5f2e4d5be094d988e3 /llvm/lib/Transforms/Utils/InlineCost.cpp | |
parent | eff7c6a2d6cb57960df71f7825c6a50834ee80e5 (diff) | |
download | bcm5719-llvm-58be2d4413008ebadbcc67bffa739c4a7327311e.tar.gz bcm5719-llvm-58be2d4413008ebadbcc67bffa739c4a7327311e.zip |
use predicate instead of hand-rolled loop
llvm-svn: 69752
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineCost.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineCost.cpp b/llvm/lib/Transforms/Utils/InlineCost.cpp index ce8b542bdf4..c9eb0ea1c90 100644 --- a/llvm/lib/Transforms/Utils/InlineCost.cpp +++ b/llvm/lib/Transforms/Utils/InlineCost.cpp @@ -76,10 +76,8 @@ unsigned InlineCostAnalyzer::FunctionInfo:: Reduction += 10; else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I)) { // If the GEP has variable indices, we won't be able to do much with it. - for (Instruction::op_iterator I = GEP->op_begin()+1, E = GEP->op_end(); - I != E; ++I) - if (!isa<Constant>(*I)) return 0; - Reduction += CountCodeReductionForAlloca(GEP)+15; + if (!GEP->hasAllConstantIndices()) + Reduction += CountCodeReductionForAlloca(GEP)+15; } else { // If there is some other strange instruction, we're not going to be able // to do much if we inline this. @@ -143,13 +141,8 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { 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; + if (GEPI->hasAllConstantIndices()) + continue; } ++NumInsts; |