From: Stas Boukarev Date: Sat, 30 Nov 2013 16:12:22 +0000 (+0400) Subject: Micro-optimize vector creation. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=1dff970a3514e323517d3ddd876821cc5e381d69;p=sbcl.git Micro-optimize vector creation. transform-make-array-vector expanded into (allocate-vector typecode (the index length) (ceiling length x)) but the transform applied to CEILING before it was known that LENGTH is of type INDEX was producing bad results, (ceiling (truly-the index length) x) solves that. --- diff --git a/src/compiler/array-tran.lisp b/src/compiler/array-tran.lisp index 3403ac3..14b2fa5 100644 --- a/src/compiler/array-tran.lisp +++ b/src/compiler/array-tran.lisp @@ -414,12 +414,13 @@ (t (let ((n-elements-per-word (/ sb!vm:n-word-bits n-bits))) (declare (type index n-elements-per-word)) ; i.e., not RATIO - `(ceiling ,padded-length-form ,n-elements-per-word))))))) + `(ceiling (truly-the index ,padded-length-form) + ,n-elements-per-word))))))) (result-spec `(simple-array ,(sb!vm:saetp-specifier saetp) (,(or c-length '*)))) (alloc-form - `(truly-the ,result-spec - (allocate-vector ,typecode (the index length) ,n-words-form)))) + `(truly-the ,result-spec + (allocate-vector ,typecode (the index length) ,n-words-form)))) (cond ((and initial-element initial-contents) (abort-ir1-transform "Both ~S and ~S specified." :initial-contents :initial-element))