[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: computational efficiency lisping



The MCL compiler does pay attention to declarations and will put many
operations in-line if it can.  I've enclosed some macros for doing
fast integer arithmetic that I use (derived from Boxer).

Similar macros can speed up other operations.  Car, cdr, and svref
will compile in-line, but aref will not, as far as I can tell.  Nor
will integer multiply.  Perhaps the implementors can give more
authoritative advice.

(defmacro def-arith-op (int-name reg-name)
  `(defmacro ,int-name (&rest args)
     `(the fixnum (,',reg-name ,@(mapcar #'(lambda (arg) `(the fixnum ,arg)) args)))))
 
(def-arith-op +& +)                     ; Only addition-type ops actually get any boost in MCL2.0
(def-arith-op -& -)
(def-arith-op incf& incf)
(def-arith-op decf& decf)
(def-arith-op 1+& 1+)
(def-arith-op 1-& 1-)

Using &+ will compile an inline integer add instead of a subroutine
call.