Avoiding float to pointer coercion in Common Lisp
02:23 23 Nov 2017

I use SBCL (64-bit v1.4.0) for numerical calculation. After enabling optimization, following compiler note appears:

note: doing float to pointer coercion (cost 13) to ""

The code I use is as follows:

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

I've also tried ftype and got the same note.

On the other hand, following code doesn't show the note:

(defun add-fixnum (a b)
  (declare (optimize (speed 3) (safety 0)))
  (declare (fixnum a b))
  (the fixnum (+ a b)))

I think double-float and fixnum are both 64 bits wide. Why can not SBCL return a double-float value via a register like C language? And are there any way to avoid float to pointer coercion without inline expansion?

optimization double common-lisp