use predicate instead of hand-rolled loop

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-04-21 23:37:18 +00:00
parent f8a8be86e3
commit 41b1a489f5

View File

@ -76,10 +76,8 @@ unsigned InlineCostAnalyzer::FunctionInfo::
Reduction += 10; Reduction += 10;
else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I)) { else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I)) {
// If the GEP has variable indices, we won't be able to do much with it. // 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(); if (!GEP->hasAllConstantIndices())
I != E; ++I) Reduction += CountCodeReductionForAlloca(GEP)+15;
if (!isa<Constant>(*I)) return 0;
Reduction += CountCodeReductionForAlloca(GEP)+15;
} else { } else {
// If there is some other strange instruction, we're not going to be able // If there is some other strange instruction, we're not going to be able
// to do much if we inline this. // to do much if we inline this.
@ -143,13 +141,8 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) {
dyn_cast<GetElementPtrInst>(II)) { dyn_cast<GetElementPtrInst>(II)) {
// If a GEP has all constant indices, it will probably be folded with // If a GEP has all constant indices, it will probably be folded with
// a load/store. // a load/store.
bool AllConstant = true; if (GEPI->hasAllConstantIndices())
for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i) continue;
if (!isa<ConstantInt>(GEPI->getOperand(i))) {
AllConstant = false;
break;
}
if (AllConstant) continue;
} }
++NumInsts; ++NumInsts;