Comment 2 for bug 1382383

Revision history for this message
Douglas Katzman (dougk) wrote :

The transform looks right to me, but there is a bug in the DERIVE-TYPE optimization on ARRAY-HEADER-P.
A reduced example illustrates that bug.

(defvar *d* (make-array (list 2 5 5) :element-type 'double-float))
(defun baz ()
  (let ((a (make-array '(5 5)
                       :element-type 'double-float :displaced-to *d*)))
    (values (array-header-p (%array-data-vector a))
            (locally (declare (notinline array-header-p))
              (array-header-p (%array-data-vector a))))))

The optimization bug makes it appear that the transform misbehaves, which it doesn't really.

Additionally your example illustrates another shortcoming which is that the MAKE-ARRAY call was unable to derive the array type due to (LIST 5 5), whereas if it were given as '(5 5), then type derivation would have been precise, and then the whole TYPEP call would have been compile-time-folded, and in that case, been correct.

Except that, in my example, because I've "exploded" the code for the typep transform, the behavior is the same whether you give the dimensions as (LIST 5 5) or '(5 5) because in either case the DERIVE-TYPE bug exists.