【问题标题】:immediate number test in llvmllvm中的立即数测试
【发布时间】:2011-04-27 14:18:06
【问题描述】:

在LLVM中,我想测试LoopInfo pass 得到的trip count是否是立即数 数字。比如下面的循环

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

行程计数为 10,它是一个立即数。可以调用 Loop 的成员函数getTripCount() 来获取表示行程计数的Value。我怎样才能确定这个值是否是立即数?

【问题讨论】:

标签: optimization compiler-construction llvm


【解决方案1】:

使用 Scalar Evolution 分析提供的以下 getter:

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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-19
    • 2017-10-30
    • 2012-11-25
    • 1970-01-01
    • 2013-09-17
    • 2020-03-24
    • 2016-11-17
    • 2020-05-16
    相关资源
    最近更新 更多