Assembly Optimizer Options and Directives
6-6
Example 6–3.Linear Assembly Dot Product (Continued)
ldh
*ptr_a++, val1
ldh
*ptr_b++, val2
mpy
val1, val2, prod1
add
sum1, prod1, sum1
ldh
*ptr_a++, val1
ldh
*ptr_b++, val2
mpy
val3, val4, prod2
add
sum2, prod2, sum2
[cnt] add
–1, cnt, cnt
[cnt] b
loop
add
sum1, sum2, sum1
return sum1
.endproc
<loop kernel generated>
loop: ; PIPED LOOP KERNEL
[!A1] ADD .L2 B4,B6,B4
|| MPY .M2X B7,A0,B6
|| [ B0] B .S1 loop
|| LDH .D2T2 *–B5(2),B6
|| LDH .D1T1 *–A4(2),A0
[ A1] SUB .S1 A1,1,A1
|| [!A1] ADD .L1 A5,A3,A5
|| MPY .M1X B6,A0,A3
|| [ B0] ADD .L2 –1,B0,B0
|| LDH .D2T2 *B5++(4),B7
|| LDH .D1T1 *A4++(4),A0
If the arrays pointed to by ptr_a and ptr_b begin on the same bank, then there
will be memory bank conflicts at every cycle of the loop due to how the LDH
instructions are paired.
By adding the .mptr directive information, you can avoid the memory bank con-
flicts. Example 6–4 shows the linear assembly dot product with the .mptr direc-
tive and the resulting loop kernel.