Redundant Load Elimination
6-112
6.11.2 Translating C Code to Linear Assembly
Example 6–62 shows the linear assembly that perform the inner loop of the
FIR filter C code.
Element x0 is read by the MPY p00 before it is loaded by the LDH x0 instruc-
tion; x[j] (the first x0) is loaded outside the loop, but successive even elements
are loaded inside the loop.
Example 6–62. Linear Assembly for FIR Inner Loop
LDH
.D2
*x_1++[2],x1
; x1 = x[j+i+1]
LDH
.D1
*h++[2],h0
; h0 = h[i]
MPY
.M1
x0,h0,p00
; x0 * h0
MPY
.M1X
x1,h0,p10
; x1 * h0
ADD
.L1
p00,sum0,sum0
; sum0 += x0 * h0
ADD
.L2X
p10,sum1,sum1
; sum1 += x1 * h0
LDH
.D1
*x++[2],x0
; x0 = x[j+i+2]
LDH
.D2
*h_1++[2],h1
; h1 = h[i+1]
MPY
.M2
x1,h1,p01
; x1 * h1
MPY
.M2X
x0,h1,p11
; x0 * h1
ADD
.L1X
p01,sum0,sum0
; sum0 += x1 * h1
ADD
.L2
p11,sum1,sum1
; sum1 += x0 * h1
[ctr]
SUB
.S2
ctr,1,ctr
; decrement loop counter
[ctr]
B
.S2
LOOP
; branch to loop