aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-21 23:37:18 +0000
committerChris Lattner <sabre@nondot.org>2009-04-21 23:37:18 +0000
commit41b1a489f567bd7744264c560daf4ee801bcf116 (patch)
tree686187662a8513667c7b13edc523d6aa29572d4d /lib/Transforms
parentf8a8be86e3972608741c1e1ecb89ec3c6f570552 (diff)
downloadexternal_llvm-41b1a489f567bd7744264c560daf4ee801bcf116.zip
external_llvm-41b1a489f567bd7744264c560daf4ee801bcf116.tar.gz
external_llvm-41b1a489f567bd7744264c560daf4ee801bcf116.tar.bz2
use predicate instead of hand-rolled loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69752 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Utils/InlineCost.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp
index ce8b542..c9eb0ea 100644
--- a/lib/Transforms/Utils/InlineCost.cpp
+++ b/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;