Accelerating Polynomial Evaluation
Function approximation and spline interpolation
Fast polynomial evaluation (N coefficients)
- y(x) = c0 + c1 x + c2 x2 + c3 x3 Expanded form
- y(x) = c0 + x (c1 + x (c2 + x (c3))) Horner’s form
- POLY reduces 2 N cycles using MAC+ADD to N cycles
; ar2 contains address of array [c3 c2 c1 c0]; poly uses temporary register t for multiplicand x; first two times poly instruction executes gives; 1. a = c(3) + x * 0 = c(3); b = c2; 2. a = c(2) + x * c(3); b = c1
ld *ar2+,16,b ; b = c3 << 16 ld *ar3,t ; t = x (ar3 contains addr of x)
rptz a,#3 ; a = 0, repeat next inst. 4 times
poly *ar2+ ; a = b + x*a || b = c(i-1) << 16 sth a,*ar4 ; store result (ar4 is addr of y)