On Tue, 2008-12-09 at 20:39 +0000, Christophe Rhodes wrote:
Guenther Thomsen <email@example.com> writes:
> Am I wrong to expect an "ADD" in the disassembled code below?
> CL-USER> (defun h (x)
> (declare (type fixnum x) (optimize (safety 0)))
> (the fixnum (+ x 3)))
> STYLE-WARNING: redefining H in DEFUN
> CL-USER> (disassemble 'h)
> ; 02C3D4D2: 488D5118 LEA RDX, [RCX+24] ; no-arg-parsing entry point
Yes. On x86oids, fixnum adds of constants can be implemented using
the Load Effective Address instruction. (I haven't measured recently
to find whether or not this is faster than using ADD, but it has been
at least at some points in the past.
Ah, I see. With a variant of that function (adding 5 instead of 3, the LEA instruction becomes "LEA RDX, [RCX+40]", the 3 bit left shift is due to implied type information, I suppose).