X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Farray-tran.lisp;h=baf1b9809d92df8c8f80bc3b3ca32e43698c60a3;hb=bcd323c39d6f5f80020ba4a5d9eb8d348c6cc499;hp=efa768bdc68bb020dddb1363afb7e08eae1f1f29;hpb=0c0d8909984b5b33bb6b59b350b2d5cee6dc1715;p=sbcl.git diff --git a/src/compiler/array-tran.lisp b/src/compiler/array-tran.lisp index efa768b..baf1b98 100644 --- a/src/compiler/array-tran.lisp +++ b/src/compiler/array-tran.lisp @@ -73,7 +73,7 @@ (apply #'type-intersection element-supertypes))))) (union-type (let ((union-types (union-type-types type)) - (element-type *empty-type*) + (element-type nil) (element-supertypes nil)) (dolist (union-type union-types) (multiple-value-bind (cur-type cur-supertype) @@ -81,7 +81,7 @@ (cond ((eq element-type *wild-type*) nil) - ((eq element-type *empty-type*) + ((eq element-type nil) (setf element-type cur-type)) ((or (eq cur-type *wild-type*) ;; If each of the two following tests fail, it is not @@ -98,6 +98,10 @@ (values element-type (when (eq *wild-type* element-type) (apply #'type-union element-supertypes))))) + (member-type + ;; Convert member-type to an union-type. + (array-type-upgraded-element-type + (apply #'type-union (mapcar #'ctype-of (member-type-members type))))) (t ;; KLUDGE: there is no good answer here, but at least ;; *wild-type* won't cause HAIRY-DATA-VECTOR-{REF,SET} to be @@ -165,6 +169,11 @@ (block nil (let ((dimensions (array-type-dimensions-or-give-up (lvar-conservative-type array)))) + ;; Might be *. (Note: currently this is never true, because the type + ;; derivation infers the rank from the call to ARRAY-IN-BOUNDS-P, but + ;; let's keep this future proof.) + (when (eq '* dimensions) + (give-up-ir1-transform "array bounds unknown")) ;; shortcut for zero dimensions (when (some (lambda (dim) (and (bound-known-p dim) (zerop dim))) @@ -174,9 +183,14 @@ ;; we can already decide on the result of the optimization without ;; even taking a look at the dimensions. (flet ((subscript-bounds (subscript) - (let* ((type (lvar-type subscript)) - (low (numeric-type-low type)) - (high (numeric-type-high type))) + (let* ((type1 (lvar-type subscript)) + (type2 (if (csubtypep type1 (specifier-type 'integer)) + (weaken-integer-type type1 :range-only t) + (give-up))) + (low (if (integer-type-p type2) + (numeric-type-low type2) + (give-up))) + (high (numeric-type-high type2))) (cond ((and (or (not (bound-known-p low)) (minusp low)) (or (not (bound-known-p high)) (not (minusp high)))) @@ -337,8 +351,9 @@ ;;; can pick them apart in the DEFTRANSFORMS, and transform '(3) style ;;; dimensions to integer args directly. (define-source-transform make-array (dimensions &rest keyargs &environment env) - (if (and (fun-lexically-notinline-p 'list) - (fun-lexically-notinline-p 'vector)) + (if (or (and (fun-lexically-notinline-p 'list) + (fun-lexically-notinline-p 'vector)) + (oddp (length keyargs))) (values nil t) (multiple-value-bind (new-dimensions rank) (flet ((constant-dims (dimensions) @@ -1090,7 +1105,8 @@ `(deftransform ,name ((array index ,@extra)) (let* ((type (lvar-type array)) (element-type (array-type-upgraded-element-type type)) - (declared-type (array-type-declared-element-type type))) + (declared-type (type-specifier + (array-type-declared-element-type type)))) ;; If an element type has been declared, we want to ;; use that information it for type checking (even ;; if the access can't be optimized due to the array