[LLVMdev] determining the number of iteration of a loop
Eugene Toder
eltoder at gmail.com
Wed Apr 21 14:48:38 PDT 2010
In your example the the number of iterations is known -- it is N. It
is not known at compile time, but it's known at run-time before you
enter the loop. So you can do transforms like if( N < threshold ) copy
of loop optimized for small iterations count; else copy of loop
optimized for large iterations count;
But you are right, in general, the number of iterations in unknown. I
think Khaled is interested in a large number of cases when it is
known, either as a constant or value.
Eugene
On Wed, Apr 21, 2010 at 10:28 PM, Trevor Harmon
<Trevor.W.Harmon at nasa.gov> wrote:
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list