Refining C/C++ Code
3-49
Optimizing C/C++ Code
3.4.3.5
Speculative Execution (–mh option)
The –mh option facilitates the compiler’s ability to remove prologs and epilogs.
Indirectly, it can reduce register pressure. With the possibility of reducing epi-
log code or elimination of redundant loops, use of this option can lead to better
code size and performance. This option may cause a loop to read past the end
of an array. Thus, the user assumes responsibility for safety. For a complete
discussion of the -mh option, including how to use it safely, see the
TMS320C6000 Optimizing C/C++ Compiler User’s Guide.
3.4.3.6
What Disqualifies a Loop from Being Software-Pipelined
In a sequence of nested loops, the innermost loop is the only one that can be
software-pipelined. The following restrictions apply to the software pipelining
of loops:
-
If a register value is live too long, the code is not software-pipelined. See
section 6.6.6.2,
Live Too Long, on page 6-67 and section 6.10, Live-Too-
Long Issues, on page 6-101 for examples of code that is live too long.
-
If the loop has complex condition code within the body that requires more
than the five ’C6000 condition registers on the ’C62x and ’C67x, or six con-
dition registers for the ’C64x, the loop is not software pipelined. Try to elim-
inate or combine these conditions.
-
Although a software pipelined loop can contain intrinsics, it cannot contain
function calls, including code that will call the run-time support routines.
The exceptions are function calls that will be inlined.
for (i = 0; i < 100; i++)
x[i] = x[i] % 5;
This will call the run-time support _remi routine.
-
In general, you should not have a conditional break (early exit) in the loop.
You may need to rewrite your code to use if statements instead. In some,
but not all cases, the compiler can do this automatically. Use the if state-
ments only around code that updates memory (stores to pointers and ar-
rays) and around variables whose values calculated inside the loop and
are used outside the loop.