OK, let's change the variable names (thanks for the explanation!) and get rid of the implicit boxing by introducing an explicit array holding the unboxed double-float.
This leaves us with this core issue:
(defun fmod (num div) (declare (optimize speed) (double-float num div)) (make-array 1 :element-type 'double-float :initial-contents (list (nth-value 1 (ffloor num div)))))
; file: /tmp/slimeZppxvS ; in: DEFUN FMOD ; (FFLOOR NUM DIV) ; --> BLOCK MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL FTRUNCATE BLOCK ; --> MACROLET SB-KERNEL::NUMBER-DISPATCH BLOCK TAGBODY RETURN-FROM ; --> TYPECASE LET COND IF IF IF PROGN TYPECASE LET COND IF PROGN ; --> SB-KERNEL::FTRUNCATE-FLOAT LET* SB-KERNEL:%UNARY-FTRUNCATE ; ==> ; (SB-C::%UNARY-FTRUNCATE/DOUBLE SB-C::X) ; ; note: doing float to pointer coercion (cost 13) ; ; compilation unit finished ; printed 1 note
OK, let's change the variable names (thanks for the explanation!) and get rid of the implicit boxing by introducing an explicit array holding the unboxed double-float.
This leaves us with this core issue:
(defun fmod (num div)
:initial- contents (list (nth-value 1 (ffloor num div)))))
(declare (optimize speed) (double-float num div))
(make-array 1 :element-type 'double-float
; file: /tmp/slimeZppxvS :NUMBER- DISPATCH BLOCK TAGBODY RETURN-FROM :FTRUNCATE- FLOAT LET* SB-KERNEL: %UNARY- FTRUNCATE %UNARY- FTRUNCATE/ DOUBLE SB-C::X)
; in: DEFUN FMOD
; (FFLOOR NUM DIV)
; --> BLOCK MULTIPLE-VALUE-BIND MULTIPLE-VALUE-CALL FTRUNCATE BLOCK
; --> MACROLET SB-KERNEL:
; --> TYPECASE LET COND IF IF IF PROGN TYPECASE LET COND IF PROGN
; --> SB-KERNEL:
; ==>
; (SB-C::
;
; note: doing float to pointer coercion (cost 13)
;
; compilation unit finished
; printed 1 note