[LLVMdev] determining the number of iteration of a loop

Trevor Harmon Trevor.W.Harmon at nasa.gov
Wed Apr 21 14:28:14 PDT 2010


On Apr 21, 2010, at 7:31 AM, khaled hamidouche wrote:

> I'm wandring to know how many times a block is executed inside a  
> loop  ?
> knowing that I can't use  getSmallConstantTripCount() because the  
> number is unkown  "for (i=0;i<N;i++)  for example"

In general, the number of iterations is undecidable. For example:

int main(char **argv, int N) {
     for (int i = 0; i < N; i++) {
         std::cout << "arg: " << argv[i] << std::endl;
     }
     return 0;
}

If you are parsing code whose iterations can be determined, please  
post it.

Trevor




More information about the llvm-dev mailing list