2011-04-27 2 views
1

LLVM에서 LoopInfo 패스로 얻은 트립 카운트가 즉각 인지 테스트하고 싶습니다. 예를 들어, 다음 루프는 다음과 같습니다.llvm에서 즉각적인 번호 테스트

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

의 여행 횟수는 10이며 즉각적인 수치입니다. 루프의 멤버 함수 getTripCount()을 호출하여 트립 횟수를 나타내는 값을 얻을 수 있습니다. 이 값이 즉각적인 숫자인지 어떻게 결정할 수 있습니까?

+0

, 참조 http://stackoverflow.com/questions/5315176/llvm-get-constant-integer-back-from-value. –

답변

0

사용하여 스칼라 진화 분석에 의해 제공되는 다음 게터 :

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. 
당신은 ConstantInt``에 dyn_cast``에 시도 할 수
관련 문제