Consider the following code:
(declaim (inline list<))
(defun list< (l1 l2)
(let ((a1 (first l1))
(a2 (first l2))
(b1 (second l1))
(b2 (second l2)))
(or (cl:< a1 a2)
(and (cl:= a1 a2) (cl:< b1 b2)))))
(deftype list-of (&rest elt-types)
(if (null elt-types)
'null
`(cons ,(first elt-types) (list-of ,@(rest elt-types)))))
(deftype u32 () `(unsigned-byte 32))
Then, the LIST-U32-< compiles optimally as expected.
(defun list-u32-< (l1 l2)
(declare (type (list-of u32 u32) l1 l2)
(optimize speed))
(list< l1 l2))
(defun list-loop-u32-< (l1 l)
(declare (type (list-of u32 u32) l1)
(optimize speed))
(loop :for elt :in l
:do (locally (declare (type (list-of u32 u32) elt))
(list< l1 elt))))
However, LIST-LOOP-U32-< emits the following compiler notes I do not expect:
; note: forced to do GENERIC-< (cost 10)
; unable to do inline fixnum comparison (cost 4) because:
; The second argument is a T, not a FIXNUM.
Am I missing something, or can SBCL be better?
I'm using SBCL 2.3.4.
_______________________________________________
Sbcl-help mailing list
Sbcl...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help