Using MUST_ITERATE and _nassert to Enable SIMD and Expand Compiler Knowledge of Loops

Through the use of MUST_ITERATE and _nassert, you can guarantee that a loop executes a certain number of times.

This example tells the compiler that the loop is guaranteed to run exactly 10 times:

#pragma MUST_ITERATE(10,10); for (I = 0; I < trip_count; I++) { ...

MUST_ITERATE can also be used to specify a range for the trip count as well as a factor of the trip count. For example:

#pragma MUST_ITERATE(8,48,8); for (I = 0; I < trip; I++) { ...

This example tells the compiler that the loop executes between 8 and 48 times and that the trip variable is a multiple of 8 (8, 16, 24, 32, 40, 48). The compiler can now use all this information to generate the best loop possible by unrolling better even when the --interrupt_thresholdn option is used to specify that interrupts do occur every n cycles.

The TMS320C6000 Programmer's Guide states that one of the ways to refine C/C++ code is to use word accesses to operate on 16-bit data stored in the high and low parts of a 32-bit register. Examples using casts to int pointers are shown with the use of intrinsics to use certain instructions like _mpyh. This can be automated by using the _nassert(); intrinsic to specify that 16-bit short arrays are aligned on a 32-bit (word) boundary.

The following examples generate the same assembly code:

NOTE

C++ Syntax for _nassert

In C++ code, _nassert is part of the standard namespace. Thus, the correct syntax is std::_nassert().