mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-29 15:17:14 +00:00
Clarified the SCEV getSmallConstantTripCount interface with in-your-face comments.
This interface is misleading and dangerous, but it is actually what we need for unrolling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147926 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -730,16 +730,21 @@ namespace llvm {
|
|||||||
const SCEV *LHS, const SCEV *RHS);
|
const SCEV *LHS, const SCEV *RHS);
|
||||||
|
|
||||||
/// getSmallConstantTripCount - Returns the maximum trip count of this loop
|
/// getSmallConstantTripCount - Returns the maximum trip count of this loop
|
||||||
/// as a normal unsigned value, if possible. Returns 0 if the trip count is
|
/// as a normal unsigned value. Returns 0 if the trip count is unknown or
|
||||||
/// unknown or not constant.
|
/// not constant. This "trip count" assumes that control exits via
|
||||||
unsigned getSmallConstantTripCount(Loop *L, BasicBlock *ExitBlock);
|
/// ExitingBlock. More precisely, it is the number of times that control may
|
||||||
|
/// reach ExitingBlock before taking the branch. For loops with multiple
|
||||||
|
/// exits, it may not be the number times that the loop header executes if
|
||||||
|
/// the loop exits prematurely via another branch.
|
||||||
|
unsigned getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock);
|
||||||
|
|
||||||
/// getSmallConstantTripMultiple - Returns the largest constant divisor of
|
/// getSmallConstantTripMultiple - Returns the largest constant divisor of
|
||||||
/// the trip count of this loop as a normal unsigned value, if
|
/// the trip count of this loop as a normal unsigned value, if
|
||||||
/// possible. This means that the actual trip count is always a multiple of
|
/// possible. This means that the actual trip count is always a multiple of
|
||||||
/// the returned value (don't forget the trip count could very well be zero
|
/// the returned value (don't forget the trip count could very well be zero
|
||||||
/// as well!).
|
/// as well!). As explained in the comments for getSmallConstantTripCount,
|
||||||
unsigned getSmallConstantTripMultiple(Loop *L, BasicBlock *ExitBlock);
|
/// this assumes that control exits the loop via ExitingBlock.
|
||||||
|
unsigned getSmallConstantTripMultiple(Loop *L, BasicBlock *ExitingBlock);
|
||||||
|
|
||||||
// getExitCount - Get the expression for the number of loop iterations for
|
// getExitCount - Get the expression for the number of loop iterations for
|
||||||
// which this loop is guaranteed not to exit via ExitingBlock. Otherwise
|
// which this loop is guaranteed not to exit via ExitingBlock. Otherwise
|
||||||
|
@@ -3939,13 +3939,19 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
|
/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
|
||||||
/// normal unsigned value, if possible. Returns 0 if the trip count is unknown
|
/// normal unsigned value. Returns 0 if the trip count is unknown or not
|
||||||
/// or not constant. Will also return 0 if the maximum trip count is very large
|
/// constant. Will also return 0 if the maximum trip count is very large (>=
|
||||||
/// (>= 2^32)
|
/// 2^32).
|
||||||
unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L,
|
///
|
||||||
BasicBlock *ExitBlock) {
|
/// This "trip count" assumes that control exits via ExitingBlock. More
|
||||||
|
/// precisely, it is the number of times that control may reach ExitingBlock
|
||||||
|
/// before taking the branch. For loops with multiple exits, it may not be the
|
||||||
|
/// number times that the loop header executes because the loop may exit
|
||||||
|
/// prematurely via another branch.
|
||||||
|
unsigned ScalarEvolution::
|
||||||
|
getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock) {
|
||||||
const SCEVConstant *ExitCount =
|
const SCEVConstant *ExitCount =
|
||||||
dyn_cast<SCEVConstant>(getExitCount(L, ExitBlock));
|
dyn_cast<SCEVConstant>(getExitCount(L, ExitingBlock));
|
||||||
if (!ExitCount)
|
if (!ExitCount)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -3968,9 +3974,12 @@ unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L,
|
|||||||
/// multiple of a constant (which is also the case if the trip count is simply
|
/// multiple of a constant (which is also the case if the trip count is simply
|
||||||
/// constant, use getSmallConstantTripCount for that case), Will also return 1
|
/// constant, use getSmallConstantTripCount for that case), Will also return 1
|
||||||
/// if the trip count is very large (>= 2^32).
|
/// if the trip count is very large (>= 2^32).
|
||||||
unsigned ScalarEvolution::getSmallConstantTripMultiple(Loop *L,
|
///
|
||||||
BasicBlock *ExitBlock) {
|
/// As explained in the comments for getSmallConstantTripCount, this assumes
|
||||||
const SCEV *ExitCount = getExitCount(L, ExitBlock);
|
/// that control exits the loop via ExitingBlock.
|
||||||
|
unsigned ScalarEvolution::
|
||||||
|
getSmallConstantTripMultiple(Loop *L, BasicBlock *ExitingBlock) {
|
||||||
|
const SCEV *ExitCount = getExitCount(L, ExitingBlock);
|
||||||
if (ExitCount == getCouldNotCompute())
|
if (ExitCount == getCouldNotCompute())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user