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.

"Unsafe schedule for irregular loop" -- what's going on?

Hi,

While trying to compile a loop, it starts with a low ii but this quickly increases with the message "Unsafe schedule for irregular loop". Eventually it ends up with an ii much higher than its theoretical minimum ii.

To make things worse, the process is very unstable. Small changes to the code which should lead to a decrease in operation count, often lead to significantly longer schedules (for instance jumping from 23 to 37 cycles after removing code).

Can somebody explain under exactly what circumstances this "unsafe schedule for irregular loop" message may appear?

Used compiler version C6000 v6.1.20; target C64x+. I cannot share the source code.

Thanks in advance,

Antoine van Wel

  • A suggestion which may help ... Try the advice in section 5.1.2 of this app note.

    Thanks and regards,

    -George

  • I'm looking into it, but this does not seem to be a problem; only a few memory accesses take place which should not interfere, restrict qualifiers are in place.

    Under what circumstances does the compiler generate this "Unsafe schedule for irregular loop" message? When does it consider a loop to be "irregular"?

    Regards

    Antoine

  • An irregular loop is any loop for which the number of iterations is not known before entering the loop.  For example, strcpy is an irregular loop, because it stops when a NULL character is seen in the input.  memcpy is a regular loop, because the number of bytes to copy is fixed at the time of the function call.

    There are many small things that can cause that specific message.  It would be quite difficult to explain why they occur and how to avoid them, because they depend on the compiler's internal bookkeeping.  The typical reason is that it wasn't possible to adjust the code so to handle the unusual requirements of an irregular loop.  One reason an irregular loop might get this message is if the code to test the termination condition is a memory read which cannot be speculated.

    Your best bet at improving the loop is to try to convert it into a regular, down-counting loop.  You might also try increasing the --speculate_loads (-mh) option.

    The compiler puts a big comment just above successfully software pipelined loops with a bunch of information.  Could you post that here?

  • "An irregular loop is any loop for which the number of iterations is not known before entering the loop."

    You hit the nail right on its head.

    Luckily I can get rid of that and make it a regular loop due to a recent refactor... Cycle count dropped from 23 to 14 and I'm sure I can push the scheduler more now..

    Thanks a lot!