This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MUST_ITERATE - known minimum trip count of 0

I am working on the TIDM6437 and had the following questions:

1.

for(i=0;i<N;i+=4)

{

//do something

}

 

N values can be 0, 8, 16, 24,...,720 which means the trip count is 0, 2, 4, 6, .., 180. I use #pragma MUST_ITERATE(0, 180, 2) to improve the loop execution time. After looking at the optimizer comments it seems that the loop unroll is 2x (as intended) but the known minimum trip count is 1. Also the minimum safe trip count is 1 (after unrolling). Does this mean I cannot safely use this piece of code for N=0 i.e. no loop?

2.

for(i=0;i<N;i++)

{

//do something

}

 

N values can be 0, 1, 2, 3,...,7 which means the trip count is 0, 1, 2, 3, .., 7. I use #pragma MUST_ITERATE(0, 7, 1) . After looking at the optimizer comments it seems that  the known minimum trip count is 1. Also the minimum safe trip count is 1. Does this mean I cannot safely use this piece of code for N=0 i.e. no loop?

 

Thanks

Deepak

 

  • Deepak,

     

    I believe that in the cases where the minimum trip count is zero,  the pragma will direct the optimizer to pipeline the loop as if the trip count is greater than zero, but it will add a check for zero to branch around the loop in the case that the value of N is zero.  So, as far as the minimum loop count and safe loop count are concerned, 1 is the value.  However, if N is zero, the loop doesn't get executed at all.

    There are some more details here: http://focus.ti.com/lit/an/spra666/spra666.pdf

    Regards,

    Dan