bool IsSubExpr,
bool AllowPredicates = false);
+ /// Variant of previous which takes the components representing an ICmp
+ /// as opposed to the ICmpInst itself. Note that the prior version can
+ /// return more precise results in some cases and is preferred when caller
+ /// has a materialized ICmp.
+ ExitLimit computeExitLimitFromICmp(const Loop *L, ICmpInst::Predicate Pred,
+ const SCEV *LHS, const SCEV *RHS,
+ bool ExitIfTrue,
+ bool IsSubExpr,
+ bool AllowPredicates = false);
+
+
/// Compute the number of times the backedge of the specified loop will
/// execute if its exit condition were a switch with a single exiting case
/// to ExitingBB.
const SCEV *LHS = getSCEV(ExitCond->getOperand(0));
const SCEV *RHS = getSCEV(ExitCond->getOperand(1));
+ ExitLimit EL = computeExitLimitFromICmp(L, Pred, LHS, RHS, ExitIfTrue,
+ ControlsExit, AllowPredicates);
+ if (EL.hasAnyInfo()) return EL;
+
+ auto *ExhaustiveCount =
+ computeExitCountExhaustively(L, ExitCond, ExitIfTrue);
+
+ if (!isa<SCEVCouldNotCompute>(ExhaustiveCount))
+ return ExhaustiveCount;
+
+ return computeShiftCompareExitLimit(ExitCond->getOperand(0),
+ ExitCond->getOperand(1), L, OriginalPred);
+}
+ScalarEvolution::ExitLimit
+ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
+ ICmpInst::Predicate Pred,
+ const SCEV *LHS, const SCEV *RHS,
+ bool ExitIfTrue,
+ bool ControlsExit,
+ bool AllowPredicates) {
+
+
// Try to evaluate any dependencies out of the loop.
LHS = getSCEVAtScope(LHS, L);
RHS = getSCEVAtScope(RHS, L);
break;
}
- auto *ExhaustiveCount =
- computeExitCountExhaustively(L, ExitCond, ExitIfTrue);
-
- if (!isa<SCEVCouldNotCompute>(ExhaustiveCount))
- return ExhaustiveCount;
-
- return computeShiftCompareExitLimit(ExitCond->getOperand(0),
- ExitCond->getOperand(1), L, OriginalPred);
+ return getCouldNotCompute();
}
ScalarEvolution::ExitLimit