mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-07 04:21:39 +00:00
[SCEV] Bring some methods up to coding style; NFC
- Start methods with lower case - Reflow a comment - Delete header comment repeated in .cpp file git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249716 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7db72f8f99
commit
8b6e5f368c
@ -446,16 +446,16 @@ namespace llvm {
|
|||||||
const BackedgeTakenInfo &getBackedgeTakenInfo(const Loop *L);
|
const BackedgeTakenInfo &getBackedgeTakenInfo(const Loop *L);
|
||||||
|
|
||||||
/// Compute the number of times the specified loop will iterate.
|
/// Compute the number of times the specified loop will iterate.
|
||||||
BackedgeTakenInfo ComputeBackedgeTakenCount(const Loop *L);
|
BackedgeTakenInfo computeBackedgeTakenCount(const Loop *L);
|
||||||
|
|
||||||
/// Compute the number of times the backedge of the specified loop will
|
/// Compute the number of times the backedge of the specified loop will
|
||||||
/// execute if it exits via the specified block.
|
/// execute if it exits via the specified block.
|
||||||
ExitLimit ComputeExitLimit(const Loop *L, BasicBlock *ExitingBlock);
|
ExitLimit computeExitLimit(const Loop *L, BasicBlock *ExitingBlock);
|
||||||
|
|
||||||
/// Compute the number of times the backedge of the specified loop will
|
/// Compute the number of times the backedge of the specified loop will
|
||||||
/// execute if its exit condition were a conditional branch of ExitCond,
|
/// execute if its exit condition were a conditional branch of ExitCond,
|
||||||
/// TBB, and FBB.
|
/// TBB, and FBB.
|
||||||
ExitLimit ComputeExitLimitFromCond(const Loop *L,
|
ExitLimit computeExitLimitFromCond(const Loop *L,
|
||||||
Value *ExitCond,
|
Value *ExitCond,
|
||||||
BasicBlock *TBB,
|
BasicBlock *TBB,
|
||||||
BasicBlock *FBB,
|
BasicBlock *FBB,
|
||||||
@ -464,7 +464,7 @@ namespace llvm {
|
|||||||
/// Compute the number of times the backedge of the specified loop will
|
/// Compute the number of times the backedge of the specified loop will
|
||||||
/// execute if its exit condition were a conditional branch of the ICmpInst
|
/// execute if its exit condition were a conditional branch of the ICmpInst
|
||||||
/// ExitCond, TBB, and FBB.
|
/// ExitCond, TBB, and FBB.
|
||||||
ExitLimit ComputeExitLimitFromICmp(const Loop *L,
|
ExitLimit computeExitLimitFromICmp(const Loop *L,
|
||||||
ICmpInst *ExitCond,
|
ICmpInst *ExitCond,
|
||||||
BasicBlock *TBB,
|
BasicBlock *TBB,
|
||||||
BasicBlock *FBB,
|
BasicBlock *FBB,
|
||||||
@ -474,12 +474,12 @@ namespace llvm {
|
|||||||
/// execute if its exit condition were a switch with a single exiting case
|
/// execute if its exit condition were a switch with a single exiting case
|
||||||
/// to ExitingBB.
|
/// to ExitingBB.
|
||||||
ExitLimit
|
ExitLimit
|
||||||
ComputeExitLimitFromSingleExitSwitch(const Loop *L, SwitchInst *Switch,
|
computeExitLimitFromSingleExitSwitch(const Loop *L, SwitchInst *Switch,
|
||||||
BasicBlock *ExitingBB, bool IsSubExpr);
|
BasicBlock *ExitingBB, bool IsSubExpr);
|
||||||
|
|
||||||
/// Given an exit condition of 'icmp op load X, cst', try to see if we can
|
/// Given an exit condition of 'icmp op load X, cst', try to see if we can
|
||||||
/// compute the backedge-taken count.
|
/// compute the backedge-taken count.
|
||||||
ExitLimit ComputeLoadConstantCompareExitLimit(LoadInst *LI,
|
ExitLimit computeLoadConstantCompareExitLimit(LoadInst *LI,
|
||||||
Constant *RHS,
|
Constant *RHS,
|
||||||
const Loop *L,
|
const Loop *L,
|
||||||
ICmpInst::Predicate p);
|
ICmpInst::Predicate p);
|
||||||
@ -489,7 +489,7 @@ namespace llvm {
|
|||||||
/// of the loop until we get the exit condition gets a value of ExitWhen
|
/// of the loop until we get the exit condition gets a value of ExitWhen
|
||||||
/// (true or false). If we cannot evaluate the exit count of the loop,
|
/// (true or false). If we cannot evaluate the exit count of the loop,
|
||||||
/// return CouldNotCompute.
|
/// return CouldNotCompute.
|
||||||
const SCEV *ComputeExitCountExhaustively(const Loop *L,
|
const SCEV *computeExitCountExhaustively(const Loop *L,
|
||||||
Value *Cond,
|
Value *Cond,
|
||||||
bool ExitWhen);
|
bool ExitWhen);
|
||||||
|
|
||||||
|
@ -4878,10 +4878,10 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
|
|||||||
if (!Pair.second)
|
if (!Pair.second)
|
||||||
return Pair.first->second;
|
return Pair.first->second;
|
||||||
|
|
||||||
// ComputeBackedgeTakenCount may allocate memory for its result. Inserting it
|
// computeBackedgeTakenCount may allocate memory for its result. Inserting it
|
||||||
// into the BackedgeTakenCounts map transfers ownership. Otherwise, the result
|
// into the BackedgeTakenCounts map transfers ownership. Otherwise, the result
|
||||||
// must be cleared in this scope.
|
// must be cleared in this scope.
|
||||||
BackedgeTakenInfo Result = ComputeBackedgeTakenCount(L);
|
BackedgeTakenInfo Result = computeBackedgeTakenCount(L);
|
||||||
|
|
||||||
if (Result.getExact(this) != getCouldNotCompute()) {
|
if (Result.getExact(this) != getCouldNotCompute()) {
|
||||||
assert(isLoopInvariant(Result.getExact(this), L) &&
|
assert(isLoopInvariant(Result.getExact(this), L) &&
|
||||||
@ -4934,7 +4934,7 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-lookup the insert position, since the call to
|
// Re-lookup the insert position, since the call to
|
||||||
// ComputeBackedgeTakenCount above could result in a
|
// computeBackedgeTakenCount above could result in a
|
||||||
// recusive call to getBackedgeTakenInfo (on a different
|
// recusive call to getBackedgeTakenInfo (on a different
|
||||||
// loop), which would invalidate the iterator computed
|
// loop), which would invalidate the iterator computed
|
||||||
// earlier.
|
// earlier.
|
||||||
@ -5115,10 +5115,10 @@ void ScalarEvolution::BackedgeTakenInfo::clear() {
|
|||||||
delete[] ExitNotTaken.getNextExit();
|
delete[] ExitNotTaken.getNextExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ComputeBackedgeTakenCount - Compute the number of times the backedge
|
/// computeBackedgeTakenCount - Compute the number of times the backedge
|
||||||
/// of the specified loop will execute.
|
/// of the specified loop will execute.
|
||||||
ScalarEvolution::BackedgeTakenInfo
|
ScalarEvolution::BackedgeTakenInfo
|
||||||
ScalarEvolution::ComputeBackedgeTakenCount(const Loop *L) {
|
ScalarEvolution::computeBackedgeTakenCount(const Loop *L) {
|
||||||
SmallVector<BasicBlock *, 8> ExitingBlocks;
|
SmallVector<BasicBlock *, 8> ExitingBlocks;
|
||||||
L->getExitingBlocks(ExitingBlocks);
|
L->getExitingBlocks(ExitingBlocks);
|
||||||
|
|
||||||
@ -5132,7 +5132,7 @@ ScalarEvolution::ComputeBackedgeTakenCount(const Loop *L) {
|
|||||||
// and compute maxBECount.
|
// and compute maxBECount.
|
||||||
for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) {
|
||||||
BasicBlock *ExitBB = ExitingBlocks[i];
|
BasicBlock *ExitBB = ExitingBlocks[i];
|
||||||
ExitLimit EL = ComputeExitLimit(L, ExitBB);
|
ExitLimit EL = computeExitLimit(L, ExitBB);
|
||||||
|
|
||||||
// 1. For each exit that can be computed, add an entry to ExitCounts.
|
// 1. For each exit that can be computed, add an entry to ExitCounts.
|
||||||
// CouldComputeBECount is true only if all exits can be computed.
|
// CouldComputeBECount is true only if all exits can be computed.
|
||||||
@ -5174,13 +5174,11 @@ ScalarEvolution::ComputeBackedgeTakenCount(const Loop *L) {
|
|||||||
return BackedgeTakenInfo(ExitCounts, CouldComputeBECount, MaxBECount);
|
return BackedgeTakenInfo(ExitCounts, CouldComputeBECount, MaxBECount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ComputeExitLimit - Compute the number of times the backedge of the specified
|
|
||||||
/// loop will execute if it exits via the specified block.
|
|
||||||
ScalarEvolution::ExitLimit
|
ScalarEvolution::ExitLimit
|
||||||
ScalarEvolution::ComputeExitLimit(const Loop *L, BasicBlock *ExitingBlock) {
|
ScalarEvolution::computeExitLimit(const Loop *L, BasicBlock *ExitingBlock) {
|
||||||
|
|
||||||
// Okay, we've chosen an exiting block. See what condition causes us to
|
// Okay, we've chosen an exiting block. See what condition causes us to exit
|
||||||
// exit at this block and remember the exit block and whether all other targets
|
// at this block and remember the exit block and whether all other targets
|
||||||
// lead to the loop header.
|
// lead to the loop header.
|
||||||
bool MustExecuteLoopHeader = true;
|
bool MustExecuteLoopHeader = true;
|
||||||
BasicBlock *Exit = nullptr;
|
BasicBlock *Exit = nullptr;
|
||||||
@ -5243,19 +5241,19 @@ ScalarEvolution::ComputeExitLimit(const Loop *L, BasicBlock *ExitingBlock) {
|
|||||||
if (BranchInst *BI = dyn_cast<BranchInst>(Term)) {
|
if (BranchInst *BI = dyn_cast<BranchInst>(Term)) {
|
||||||
assert(BI->isConditional() && "If unconditional, it can't be in loop!");
|
assert(BI->isConditional() && "If unconditional, it can't be in loop!");
|
||||||
// Proceed to the next level to examine the exit condition expression.
|
// Proceed to the next level to examine the exit condition expression.
|
||||||
return ComputeExitLimitFromCond(L, BI->getCondition(), BI->getSuccessor(0),
|
return computeExitLimitFromCond(L, BI->getCondition(), BI->getSuccessor(0),
|
||||||
BI->getSuccessor(1),
|
BI->getSuccessor(1),
|
||||||
/*ControlsExit=*/IsOnlyExit);
|
/*ControlsExit=*/IsOnlyExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SwitchInst *SI = dyn_cast<SwitchInst>(Term))
|
if (SwitchInst *SI = dyn_cast<SwitchInst>(Term))
|
||||||
return ComputeExitLimitFromSingleExitSwitch(L, SI, Exit,
|
return computeExitLimitFromSingleExitSwitch(L, SI, Exit,
|
||||||
/*ControlsExit=*/IsOnlyExit);
|
/*ControlsExit=*/IsOnlyExit);
|
||||||
|
|
||||||
return getCouldNotCompute();
|
return getCouldNotCompute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ComputeExitLimitFromCond - Compute the number of times the
|
/// computeExitLimitFromCond - Compute the number of times the
|
||||||
/// backedge of the specified loop will execute if its exit condition
|
/// backedge of the specified loop will execute if its exit condition
|
||||||
/// were a conditional branch of ExitCond, TBB, and FBB.
|
/// were a conditional branch of ExitCond, TBB, and FBB.
|
||||||
///
|
///
|
||||||
@ -5264,7 +5262,7 @@ ScalarEvolution::ComputeExitLimit(const Loop *L, BasicBlock *ExitingBlock) {
|
|||||||
/// condition is true and can infer that failing to meet the condition prior to
|
/// condition is true and can infer that failing to meet the condition prior to
|
||||||
/// integer wraparound results in undefined behavior.
|
/// integer wraparound results in undefined behavior.
|
||||||
ScalarEvolution::ExitLimit
|
ScalarEvolution::ExitLimit
|
||||||
ScalarEvolution::ComputeExitLimitFromCond(const Loop *L,
|
ScalarEvolution::computeExitLimitFromCond(const Loop *L,
|
||||||
Value *ExitCond,
|
Value *ExitCond,
|
||||||
BasicBlock *TBB,
|
BasicBlock *TBB,
|
||||||
BasicBlock *FBB,
|
BasicBlock *FBB,
|
||||||
@ -5274,9 +5272,9 @@ ScalarEvolution::ComputeExitLimitFromCond(const Loop *L,
|
|||||||
if (BO->getOpcode() == Instruction::And) {
|
if (BO->getOpcode() == Instruction::And) {
|
||||||
// Recurse on the operands of the and.
|
// Recurse on the operands of the and.
|
||||||
bool EitherMayExit = L->contains(TBB);
|
bool EitherMayExit = L->contains(TBB);
|
||||||
ExitLimit EL0 = ComputeExitLimitFromCond(L, BO->getOperand(0), TBB, FBB,
|
ExitLimit EL0 = computeExitLimitFromCond(L, BO->getOperand(0), TBB, FBB,
|
||||||
ControlsExit && !EitherMayExit);
|
ControlsExit && !EitherMayExit);
|
||||||
ExitLimit EL1 = ComputeExitLimitFromCond(L, BO->getOperand(1), TBB, FBB,
|
ExitLimit EL1 = computeExitLimitFromCond(L, BO->getOperand(1), TBB, FBB,
|
||||||
ControlsExit && !EitherMayExit);
|
ControlsExit && !EitherMayExit);
|
||||||
const SCEV *BECount = getCouldNotCompute();
|
const SCEV *BECount = getCouldNotCompute();
|
||||||
const SCEV *MaxBECount = getCouldNotCompute();
|
const SCEV *MaxBECount = getCouldNotCompute();
|
||||||
@ -5309,9 +5307,9 @@ ScalarEvolution::ComputeExitLimitFromCond(const Loop *L,
|
|||||||
if (BO->getOpcode() == Instruction::Or) {
|
if (BO->getOpcode() == Instruction::Or) {
|
||||||
// Recurse on the operands of the or.
|
// Recurse on the operands of the or.
|
||||||
bool EitherMayExit = L->contains(FBB);
|
bool EitherMayExit = L->contains(FBB);
|
||||||
ExitLimit EL0 = ComputeExitLimitFromCond(L, BO->getOperand(0), TBB, FBB,
|
ExitLimit EL0 = computeExitLimitFromCond(L, BO->getOperand(0), TBB, FBB,
|
||||||
ControlsExit && !EitherMayExit);
|
ControlsExit && !EitherMayExit);
|
||||||
ExitLimit EL1 = ComputeExitLimitFromCond(L, BO->getOperand(1), TBB, FBB,
|
ExitLimit EL1 = computeExitLimitFromCond(L, BO->getOperand(1), TBB, FBB,
|
||||||
ControlsExit && !EitherMayExit);
|
ControlsExit && !EitherMayExit);
|
||||||
const SCEV *BECount = getCouldNotCompute();
|
const SCEV *BECount = getCouldNotCompute();
|
||||||
const SCEV *MaxBECount = getCouldNotCompute();
|
const SCEV *MaxBECount = getCouldNotCompute();
|
||||||
@ -5346,7 +5344,7 @@ ScalarEvolution::ComputeExitLimitFromCond(const Loop *L,
|
|||||||
// With an icmp, it may be feasible to compute an exact backedge-taken count.
|
// With an icmp, it may be feasible to compute an exact backedge-taken count.
|
||||||
// Proceed to the next level to examine the icmp.
|
// Proceed to the next level to examine the icmp.
|
||||||
if (ICmpInst *ExitCondICmp = dyn_cast<ICmpInst>(ExitCond))
|
if (ICmpInst *ExitCondICmp = dyn_cast<ICmpInst>(ExitCond))
|
||||||
return ComputeExitLimitFromICmp(L, ExitCondICmp, TBB, FBB, ControlsExit);
|
return computeExitLimitFromICmp(L, ExitCondICmp, TBB, FBB, ControlsExit);
|
||||||
|
|
||||||
// Check for a constant condition. These are normally stripped out by
|
// Check for a constant condition. These are normally stripped out by
|
||||||
// SimplifyCFG, but ScalarEvolution may be used by a pass which wishes to
|
// SimplifyCFG, but ScalarEvolution may be used by a pass which wishes to
|
||||||
@ -5362,14 +5360,11 @@ ScalarEvolution::ComputeExitLimitFromCond(const Loop *L,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it's not an integer or pointer comparison then compute it the hard way.
|
// If it's not an integer or pointer comparison then compute it the hard way.
|
||||||
return ComputeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
|
return computeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ComputeExitLimitFromICmp - Compute the number of times the
|
|
||||||
/// backedge of the specified loop will execute if its exit condition
|
|
||||||
/// were a conditional branch of the ICmpInst ExitCond, TBB, and FBB.
|
|
||||||
ScalarEvolution::ExitLimit
|
ScalarEvolution::ExitLimit
|
||||||
ScalarEvolution::ComputeExitLimitFromICmp(const Loop *L,
|
ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
|
||||||
ICmpInst *ExitCond,
|
ICmpInst *ExitCond,
|
||||||
BasicBlock *TBB,
|
BasicBlock *TBB,
|
||||||
BasicBlock *FBB,
|
BasicBlock *FBB,
|
||||||
@ -5386,7 +5381,7 @@ ScalarEvolution::ComputeExitLimitFromICmp(const Loop *L,
|
|||||||
if (LoadInst *LI = dyn_cast<LoadInst>(ExitCond->getOperand(0)))
|
if (LoadInst *LI = dyn_cast<LoadInst>(ExitCond->getOperand(0)))
|
||||||
if (Constant *RHS = dyn_cast<Constant>(ExitCond->getOperand(1))) {
|
if (Constant *RHS = dyn_cast<Constant>(ExitCond->getOperand(1))) {
|
||||||
ExitLimit ItCnt =
|
ExitLimit ItCnt =
|
||||||
ComputeLoadConstantCompareExitLimit(LI, RHS, L, Cond);
|
computeLoadConstantCompareExitLimit(LI, RHS, L, Cond);
|
||||||
if (ItCnt.hasAnyInfo())
|
if (ItCnt.hasAnyInfo())
|
||||||
return ItCnt;
|
return ItCnt;
|
||||||
}
|
}
|
||||||
@ -5451,7 +5446,7 @@ ScalarEvolution::ComputeExitLimitFromICmp(const Loop *L,
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
#if 0
|
#if 0
|
||||||
dbgs() << "ComputeBackedgeTakenCount ";
|
dbgs() << "computeBackedgeTakenCount ";
|
||||||
if (ExitCond->getOperand(0)->getType()->isUnsigned())
|
if (ExitCond->getOperand(0)->getType()->isUnsigned())
|
||||||
dbgs() << "[unsigned] ";
|
dbgs() << "[unsigned] ";
|
||||||
dbgs() << *LHS << " "
|
dbgs() << *LHS << " "
|
||||||
@ -5460,11 +5455,11 @@ ScalarEvolution::ComputeExitLimitFromICmp(const Loop *L,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ComputeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
|
return computeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScalarEvolution::ExitLimit
|
ScalarEvolution::ExitLimit
|
||||||
ScalarEvolution::ComputeExitLimitFromSingleExitSwitch(const Loop *L,
|
ScalarEvolution::computeExitLimitFromSingleExitSwitch(const Loop *L,
|
||||||
SwitchInst *Switch,
|
SwitchInst *Switch,
|
||||||
BasicBlock *ExitingBlock,
|
BasicBlock *ExitingBlock,
|
||||||
bool ControlsExit) {
|
bool ControlsExit) {
|
||||||
@ -5497,11 +5492,11 @@ EvaluateConstantChrecAtConstant(const SCEVAddRecExpr *AddRec, ConstantInt *C,
|
|||||||
return cast<SCEVConstant>(Val)->getValue();
|
return cast<SCEVConstant>(Val)->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ComputeLoadConstantCompareExitLimit - Given an exit condition of
|
/// computeLoadConstantCompareExitLimit - Given an exit condition of
|
||||||
/// 'icmp op load X, cst', try to see if we can compute the backedge
|
/// 'icmp op load X, cst', try to see if we can compute the backedge
|
||||||
/// execution count.
|
/// execution count.
|
||||||
ScalarEvolution::ExitLimit
|
ScalarEvolution::ExitLimit
|
||||||
ScalarEvolution::ComputeLoadConstantCompareExitLimit(
|
ScalarEvolution::computeLoadConstantCompareExitLimit(
|
||||||
LoadInst *LI,
|
LoadInst *LI,
|
||||||
Constant *RHS,
|
Constant *RHS,
|
||||||
const Loop *L,
|
const Loop *L,
|
||||||
@ -5826,7 +5821,7 @@ ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCEV *ScalarEvolution::ComputeExitCountExhaustively(const Loop *L,
|
const SCEV *ScalarEvolution::computeExitCountExhaustively(const Loop *L,
|
||||||
Value *Cond,
|
Value *Cond,
|
||||||
bool ExitWhen) {
|
bool ExitWhen) {
|
||||||
PHINode *PN = getConstantEvolvingPHI(Cond, L);
|
PHINode *PN = getConstantEvolvingPHI(Cond, L);
|
||||||
|
Loading…
Reference in New Issue
Block a user