In order to facilitate nested loop coalescing, in which an outer loop level containing instructions is merged into an inner loop level, the C7000 architecture provides a feature known as the Nested Loop Controller (NLC). This feature implements hardware loop control for no more than one level of loop nesting. This allows the compiler to coalesce loop levels while predicating the execution of outer loop instructions in the inner loop. This reduces loop control overhead and provides for better function unit resource utilization for software pipelined loops. Loop coalescing is something that the compiler attempts to do automatically if the operation is both legal and profitable. Profitability is determined by a heuristic.
The COALESCE_LOOP pragma explicitly enables coalescing of the nested loop construct that follows the pragma. The pragma can only be applied to loops and must appear immediately before a loop construct in C/C++.
The syntax of the pragma in C and C++ is:
#pragma COALESCE_LOOP |
If the compiler cannot guarantee that an inner loop is executed at least one time, then it will not coalesce the loop, even if you have used the COALESCE_LOOP pragma. To inform the compiler that a loop will always be executed, use a MUST_ITERATE pragma just prior to the loop body. For example, the following pragma tells the compiler that the loop executes at least once and no more than 65,535 times.
#pragma MUST_ITERATE(1,65535,)