开发者

immediate number test in llvm

In LLVM, I'd like to test whether the trip count obtained by LoopInfo pass is an immediate number. For example, the following loop

for(i=0; i<10; i++) { ... }

has a trip count of 10, and it's an immediate number. The member function getTripCount() of Loop can be called to get a Value representing the trip count. How can I decide this 开发者_开发问答value is an immediate number or not?


Use the following getter provided by the Scalar Evolution analysis:

unsigned ScalarEvolution::getSmallConstantTripCount(Loop *L, BasicBlock *ExitingBlock)

/// getSmallConstantTripCount - Returns the maximum trip count of this loop as a
/// normal unsigned value. Returns 0 if the trip count is unknown or not
/// constant. Will also return 0 if the maximum trip count is very large (>=
/// 2^32).
///
/// 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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜