Hi there,

I'm wondering why in the following code SBCL complains about being unable to optimize the arithmetic despite my type declarations? I am on 1.0.46 on Mac OS X (64-bit, threaded).

The code:

(declaim (optimize (speed 3) (safety 0)))

(defun dot-sa (a b)
  (declare (type (simple-array fixnum (4)) a b))
  (+ (* (aref a 0) (aref b 0))
     (* (aref a 1) (aref b 1))
     (* (aref a 2) (aref b 2))
     (* (aref a 3) (aref b 3))))

(defun test-dot-sa ()
  (let ((a (vector 1 2 3 4))
        (b (vector 4 3 2 1)))
    (time (loop for i from 1 to 100000000 do (dot-sa a b)))))

And an example warning:

; in: DEFUN DOT-SA
;     (* (AREF A 0) (AREF B 0))
; note: forced to do GENERIC-* (cost 30)
;       unable to do inline fixnum arithmetic (cost 4) because:
;       The result is a (VALUES
;                        (INTEGER -1329227995784915871750885555673497600
;                         1329227995784915872903807060280344576)
;                        &OPTIONAL), not a (VALUES FIXNUM &REST T).
;       unable to do inline (signed-byte 64) arithmetic (cost 5) because:
;       The result is a (VALUES
;                        (INTEGER -1329227995784915871750885555673497600
;                         1329227995784915872903807060280344576)
;                        &OPTIONAL), not a (VALUES (SIGNED-BYTE 64) &REST T).
;       etc.

Thanks.

--
Elliott Slaughter

"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay