Erann Gat <gat@jpl.nasa.gov> wrote:
+---------------
| P.S. Here's what MCL does.
| ? (defun m-f (x y) (declare (fixnum x) (fixnum y)) (the fixnum (* x y)))
| M-F
| ? (disassemble 'm-f)
| (TWNEI NARGS 8)
| (MFLR LOC-PC)
| (BLA .SPSAVECONTEXTVSP)
| (VPUSH ARG_Y)
| (VPUSH ARG_Z)
| (LWZ NARGS 331 RNIL)
| (TWGTI NARGS 0)
| (LWZ ARG_Y 4 VSP)
| (LWZ ARG_Z 0 VSP)
| (SRAWI IMM0 ARG_Z 2)
| (MULLW ARG_Z ARG_Y IMM0)
| (BA .SPPOPJ)
| ?
+---------------
For CMUCL, you have to crank SPEED up and SAFETY down, but then you get
something even faster:
> (defun m-f (x y)
(declare (fixnum x y) (optimize (speed 3) (safety 0)))
(the fixnum (* x y)))
M-F
> (disassemble 'm-f)
; Compiling LAMBDA (X Y):
; In: LAMBDA (X Y)
; (* X Y)
; Note: Unable to recode as shift and add due to type uncertainty:
; The first argument is a FIXNUM, not a (UNSIGNED-BYTE 32).
; The second argument is a FIXNUM, not a (UNSIGNED-BYTE 32).
; The result is a FIXNUM, not a (UNSIGNED-BYTE 32).
; Compilation unit finished.
; 1 note
483F4468: .ENTRY "LAMBDA (X Y)"(x y) ; (FUNCTION (FIXNUM FIXNUM) FIXNUM)
80: POP DWORD PTR [EBP-8]
83: LEA ESP, [EBP-32]
86: SAR EDX, 2 ; No-arg-parsing entry point
89: IMUL EDX, EDI
8C: MOV ECX, [EBP-8]
8F: MOV EAX, [EBP-4]
92: ADD ECX, 2
95: MOV ESP, EBP
97: MOV EBP, EAX
99: JMP ECX
9B: NOP
9C: NOP
9D: NOP
9E: NOP
9F: NOP
>
-Rob
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607