`(let ((array ,creation-form))
(multiple-value-bind (vector)
(%data-vector-and-index array 0)
- (fill vector initial-element))
+ (fill vector (the ,(sb!vm:saetp-specifier saetp) initial-element)))
array)))))
;;; The integer type restriction on the length ensures that it will be
,@(when element-type
'(:element-type element-type))))
(setf (%array-displaced-p header) nil)
+ (setf (%array-displaced-from header) nil)
,@(let ((axis -1))
(mapcar (lambda (dim)
`(setf (%array-dimension header ,(incf axis))
(deftransform array-rank ((array))
(let ((array-type (lvar-type array)))
(let ((dims (array-type-dimensions-or-give-up array-type)))
- (if (not (listp dims))
- (give-up-ir1-transform
- "The array rank is not known at compile time: ~S"
- dims)
- (length dims)))))
+ (cond ((listp dims)
+ (length dims))
+ ((eq t (array-type-complexp array-type))
+ '(%array-rank array))
+ (t
+ `(if (array-header-p array)
+ (%array-rank array)
+ 1))))))
;;; If we know the dimensions at compile time, just use it. Otherwise,
;;; if we can tell that the axis is in bounds, convert to
(array index))
(unless (constant-lvar-p axis)
(give-up-ir1-transform "The axis is not constant."))
- (let ((array-type (lvar-type array))
+ ;; Dimensions may change thanks to ADJUST-ARRAY, so we need the
+ ;; conservative type.
+ (let ((array-type (lvar-conservative-type array))
(axis (lvar-value axis)))
(let ((dims (array-type-dimensions-or-give-up array-type)))
(unless (listp dims)
((t)
'(%array-dimension array 0))
((nil)
- '(length array))
+ '(vector-length array))
((:maybe)
- (give-up-ir1-transform
- "can't tell whether array is simple"))))
+ `(if (array-header-p array)
+ (%array-dimension array axis)
+ (vector-length array)))))
(t
'(%array-dimension array axis)))))))