Assembly Optimizer Options and Directives
6-5
Optimizing Assembly Code via Linear Assembly
For a full description on the implications of .no_mdep and the -mt option, refer
to Appendix B, Memory Alias Disambiguation. Refer to the
TMS320C6000
Optimizing C/C++ Compiler User’s Guide for more information on both the -mt
option and the .no_mdep directive.
6.2.3
The .mdep Directive
Should you need to specify a dependence between two or more memory refer-
ences, use the .mdep directive. Annotate your code with memory reference
symbols and add the .mdep directive to your linear assembly function.
Example 6–2. Block copy With .mdep
.mdep ld1, st1
LDW *p1++ {ld1}, inp1 ; annotate memory reference ld1
; other code ...
STW outp2,*p2++ {st1} ; annotate memory reference st1
The .mdep directive indicates there is a memory dependence from the LDW
instruction to the STW instruction. This means that the STW instruction must
come after the LDW instruction. The .mdep directive does not imply that there
is a memory dependence from the STW to the LDW. Another .mdep directive
would be needed to handle that case.
6.2.4
The .mptr Directive
The .mptr directive gives the assembly optimizer information on how to avoid
memory bank conflicts. The assembly optimizer will rearrange the memory ref-
erences generated in the assembly code to avoid the memory bank conflicts
that were specified with the .mptr directive. This means that code generated
by the assembly optimizer will be faster by avoiding the memory bank conflicts.
Example 6–3 shows linear assembly code and the generated loop kernel for
a dot product without the .mptr directive.
Example 6–3. Linear Assembly Dot Product
dotp:
.cproc ptr_a, ptr_b, cnt
.reg
val1, val2, val3, val4
.reg
prod1, prod2, sum1, sum2
zero
sum1
zero
sum2
loop:
.trip
20
, 20