Micro-optimize vector creation.
authorStas Boukarev <stassats@gmail.com>
Sat, 30 Nov 2013 16:12:22 +0000 (20:12 +0400)
committerStas Boukarev <stassats@gmail.com>
Sat, 30 Nov 2013 16:52:26 +0000 (20:52 +0400)
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.

src/compiler/array-tran.lisp

index 3403ac3..14b2fa5 100644 (file)
                   (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))