InstCombine: Simplify code, no functionality change.

llvm-svn: 212449
This commit is contained in:
Benjamin Kramer 2014-07-07 11:01:16 +00:00
parent f0831ee8d2
commit d0993e0077
1 changed files with 2 additions and 16 deletions

View File

@ -683,26 +683,12 @@ Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
} }
// If one of the GEPs has all zero indices, recurse. // If one of the GEPs has all zero indices, recurse.
bool AllZeros = true; if (GEPLHS->hasAllZeroIndices())
for (unsigned i = 1, e = GEPLHS->getNumOperands(); i != e; ++i)
if (!isa<Constant>(GEPLHS->getOperand(i)) ||
!cast<Constant>(GEPLHS->getOperand(i))->isNullValue()) {
AllZeros = false;
break;
}
if (AllZeros)
return FoldGEPICmp(GEPRHS, GEPLHS->getOperand(0), return FoldGEPICmp(GEPRHS, GEPLHS->getOperand(0),
ICmpInst::getSwappedPredicate(Cond), I); ICmpInst::getSwappedPredicate(Cond), I);
// If the other GEP has all zero indices, recurse. // If the other GEP has all zero indices, recurse.
AllZeros = true; if (GEPRHS->hasAllZeroIndices())
for (unsigned i = 1, e = GEPRHS->getNumOperands(); i != e; ++i)
if (!isa<Constant>(GEPRHS->getOperand(i)) ||
!cast<Constant>(GEPRHS->getOperand(i))->isNullValue()) {
AllZeros = false;
break;
}
if (AllZeros)
return FoldGEPICmp(GEPLHS, GEPRHS->getOperand(0), Cond, I); return FoldGEPICmp(GEPLHS, GEPRHS->getOperand(0), Cond, I);
bool GEPsInBounds = GEPLHS->isInBounds() && GEPRHS->isInBounds(); bool GEPsInBounds = GEPLHS->isInBounds() && GEPRHS->isInBounds();