Code Expansion with Partial Evaluation

By unrolling the loops of matrix multiply, substituting the values from the coefficient matrix, and performing partial evaluation on the result, a specialized version of the matrix multiply is obtained:


> (fnopt 'mxmult 'rotate-x '(b theta x))
(LAMBDA-BLOCK ROTATE-X (B THETA X)
 (PROGN (SETF (AREF X 0 0) (AREF B 0 0))
        (SETF (AREF X 0 1) (AREF B 0 1))
        (SETF (AREF X 0 2) (AREF B 0 2))
        (SETF (AREF X 0 3) (AREF B 0 3))
        (SETF (AREF X 1 0)
              (- (* (COS THETA) (AREF B 1 0))
                 (* (SIN THETA) (AREF B 2 0))))
        (SETF (AREF X 1 1)
              (- (* (COS THETA) (AREF B 1 1))
                 (* (SIN THETA) (AREF B 2 1))))
     . . . ))

This version saves many operations:

Version: Load Store Add/Sub Mul Total
General 128 16 48 64 256
Specialized 24 16 8 16 64

Contents    Page-10    Prev    Next    Page+10    Index