forked from OSchip/llvm-project
[SCEV] Split computeExitLimitFromICmp into two versions [NFC]
This is in advance of a following change which needs to the non-icmp API.
This commit is contained in:
parent
eda5bbfb9d
commit
f19a95bbed
|
@ -1713,6 +1713,17 @@ private:
|
|||
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.
|
||||
|
|
|
@ -8203,6 +8203,28 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
|
|||
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);
|
||||
|
@ -8312,14 +8334,7 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *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
|
||||
|
|
Loading…
Reference in New Issue