[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AREF/SVREF
- To: Jim Hurd <71501.1347@CompuServe.COM>
- Subject: Re: AREF/SVREF
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Thu, 23 Apr 1992 15:57:26 -0500
- Cc: info-mcl
>Thanks all for help with parsers.
>
>While we are on the subject of compiler optimizations, is there any magic
>declarations to inline aref/svref? Performance is pretty abysmal calling
>subroutines all the time.
2.0b1 will in-line aref or svref of a declared simple-vector if you
are optimizing for speed and no safety:
? (defun foo (x y)
(declare (optimize (speed 3) (safety 0)))
(declare (simple-vector x))
(svref x y))
FOO
? (disassemble *)
0 (MOVEQ (FIXNUM -1) D3)
2 (ADD.W D4 D3)
4 (CHK (A5 -756) D3)
8 (SPUSH VSP)
10 (VPUSH D1)
12 (VPUSH D0)
14 (MOVE.L (VSP 4) ATEMP0)
18 (MOVE.L @VSP D1)
20 (ASR.L 1 D1)
22 (MOVE.L (ATEMP0 D1.L 7) D0)
26 (SPOP VSP)
28 (RTS)
? (defun foo (x y)
(declare (optimize (speed 3) (safety 0)))
(declare (simple-vector x))
(aref x y))
FOO
? (disassemble *)
0 (MOVEQ (FIXNUM -1) D3)
2 (ADD.W D4 D3)
4 (CHK (A5 -756) D3)
8 (SPUSH VSP)
10 (VPUSH D1)
12 (VPUSH D0)
14 (MOVE.L (VSP 4) ATEMP0)
18 (MOVE.L @VSP D1)
20 (ASR.L 1 D1)
22 (MOVE.L (ATEMP0 D1.L 7) D0)
26 (SPOP VSP)
28 (RTS)
You may wish to wrap the (speed 3) (safety 0) declaration around
only the aref (or svref):
? (defun foo (x y)
(declare (simple-vector x))
(locally (declare (optimize (speed 3) (safety 0)))
(aref x y)))
FOO
? (disassemble *)
0 (JSR_SUBPRIM $SP-TWO-ARGS-VPUSH)
4 (MOVE.L (VSP 4) ATEMP0)
8 (MOVE.L @VSP D1)
10 (ASR.L 1 D1)
12 (MOVE.L (ATEMP0 D1.L 7) D0)
16 (SPOP VSP)
18 (RTS)
?
2.0 final will inline aref of certain other types of simple arrays,
e.g. (signed-byte 8), though I don't know the full list.
>
>Is the semi-supported LAP with 2.0b1 the latest?
It's the only one that works with 2.0b1. We've added a little bit to
it since then (and I think the lap sources will be on the CD), but
not much.
-----
Bill St. Clair
bill@cambridge.apple.com