수치 계산을 위해 SBCL (64 비트 v1.4.0)을 사용합니다.Common Lisp에서 float to pointer coercion 피하기
(defun add (a b)
(declare (optimize (speed 3) (safety 0)))
(declare (double-float a b))
(the double-float (+ a b)))
또한 ftype
을 시도하고 같은 메모를 가지고 :
note: doing float to pointer coercion (cost 13) to "<return value>"
내가 사용하는 코드는대로 : 최적화를 활성화 한 후, 컴파일러 메모를 다음 나타납니다. 한편
, 메모 표시되지 않는 코드를 다음(defun add-fixnum (a b)
(declare (optimize (speed 3) (safety 0)))
(declare (fixnum a b))
(the fixnum (+ a b)))
내가 두 번 플로트와 Fixnum이라는 폭 모두 64 비트 생각합니다. SBCL이 C 언어와 같은 레지스터를 통해 double float 값을 반환 할 수없는 이유는 무엇입니까? 그리고 인라인 확장없이 float에서 포인터 강제 변환을 피할 수있는 방법이 있습니까?
https://groups.google.com/forum/#!topic/comp.lang.lisp/AsKvR0emFtU – Barmar