[NFC] Rename variable from Cond to Pred to make it more sound

llvm-svn: 320144
This commit is contained in:
Max Kazantsev 2017-12-08 12:54:32 +00:00
parent 9c08b7a053
commit 63a3de057e
1 changed files with 12 additions and 12 deletions

View File

@ -7069,18 +7069,18 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
bool ControlsExit,
bool AllowPredicates) {
// If the condition was exit on true, convert the condition to exit on false
ICmpInst::Predicate Cond;
ICmpInst::Predicate Pred;
if (!L->contains(FBB))
Cond = ExitCond->getPredicate();
Pred = ExitCond->getPredicate();
else
Cond = ExitCond->getInversePredicate();
const ICmpInst::Predicate OriginalCond = Cond;
Pred = ExitCond->getInversePredicate();
const ICmpInst::Predicate OriginalPred = Pred;
// Handle common loops like: for (X = "string"; *X; ++X)
if (LoadInst *LI = dyn_cast<LoadInst>(ExitCond->getOperand(0)))
if (Constant *RHS = dyn_cast<Constant>(ExitCond->getOperand(1))) {
ExitLimit ItCnt =
computeLoadConstantCompareExitLimit(LI, RHS, L, Cond);
computeLoadConstantCompareExitLimit(LI, RHS, L, Pred);
if (ItCnt.hasAnyInfo())
return ItCnt;
}
@ -7097,11 +7097,11 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
if (isLoopInvariant(LHS, L) && !isLoopInvariant(RHS, L)) {
// If there is a loop-invariant, force it into the RHS.
std::swap(LHS, RHS);
Cond = ICmpInst::getSwappedPredicate(Cond);
Pred = ICmpInst::getSwappedPredicate(Pred);
}
// Simplify the operands before analyzing them.
(void)SimplifyICmpOperands(Cond, LHS, RHS);
(void)SimplifyICmpOperands(Pred, LHS, RHS);
// If we have a comparison of a chrec against a constant, try to use value
// ranges to answer this query.
@ -7110,13 +7110,13 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
if (AddRec->getLoop() == L) {
// Form the constant range.
ConstantRange CompRange =
ConstantRange::makeExactICmpRegion(Cond, RHSC->getAPInt());
ConstantRange::makeExactICmpRegion(Pred, RHSC->getAPInt());
const SCEV *Ret = AddRec->getNumIterationsInRange(CompRange, *this);
if (!isa<SCEVCouldNotCompute>(Ret)) return Ret;
}
switch (Cond) {
switch (Pred) {
case ICmpInst::ICMP_NE: { // while (X != Y)
// Convert to: while (X-Y != 0)
ExitLimit EL = howFarToZero(getMinusSCEV(LHS, RHS), L, ControlsExit,
@ -7132,7 +7132,7 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
}
case ICmpInst::ICMP_SLT:
case ICmpInst::ICMP_ULT: { // while (X < Y)
bool IsSigned = Cond == ICmpInst::ICMP_SLT;
bool IsSigned = Pred == ICmpInst::ICMP_SLT;
ExitLimit EL = howManyLessThans(LHS, RHS, L, IsSigned, ControlsExit,
AllowPredicates);
if (EL.hasAnyInfo()) return EL;
@ -7140,7 +7140,7 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
}
case ICmpInst::ICMP_SGT:
case ICmpInst::ICMP_UGT: { // while (X > Y)
bool IsSigned = Cond == ICmpInst::ICMP_SGT;
bool IsSigned = Pred == ICmpInst::ICMP_SGT;
ExitLimit EL =
howManyGreaterThans(LHS, RHS, L, IsSigned, ControlsExit,
AllowPredicates);
@ -7158,7 +7158,7 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
return ExhaustiveCount;
return computeShiftCompareExitLimit(ExitCond->getOperand(0),
ExitCond->getOperand(1), L, OriginalCond);
ExitCond->getOperand(1), L, OriginalPred);
}
ScalarEvolution::ExitLimit