Re: Numerical code efficiency

"Chris Double" <[email protected]> Mon, 13 Oct 2003 08:22:26 +1300
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
On Sun, 12 Oct 2003 11:17:21 -0400, "Dan Muller"
<[email protected]> said:
> 2. Looking at the disassembled functions, i noticed that svref results
>    in an actual function call, as does the call to #'+. Is there any
>    way around this? Declaiming these inline doesn't work; I get a
>    warning that the source isn't accessible.

It looks like there is no inlining of #'+ for floats. The following
inlines correctly for fixnums for example:

(defun test (a b)
    (declare (optimize (speed 3) (safety 0))
             (type fixnum a)
             (type fixnum b))
    (the fixnum (+ a b)))

But the following doesn't for floats:

(defun test (a b)
    (declare (optimize (speed 3) (safety 0))
             (type double-float a)
             (type double-float b))
    (the double-float (+ a b)))

As for whether it's typical for Lisp compilers, I don't know. CMUCL
(which is well known for its optmisation abilities) will inline the
second example.

Chris.
-- 
  Chris Double
  [email protected]

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/SyjtlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/