1.0.28.9: open code ARRAY-RANK
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 4 May 2009 19:28:44 +0000 (19:28 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 4 May 2009 19:28:44 +0000 (19:28 +0000)
 * Faster multidimensional AREF if the array rank is not known
   at compile-time.

NEWS
src/compiler/array-tran.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index b7a366b..3d05ffc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,7 @@
 ;;;; -*- coding: utf-8; fill-column: 78 -*-
+  * optimization: multidimensional array accesses in the absence of type
+    information regarding array rank are approximately 10% faster due to
+    open coding of ARRAY-RANK.
   * bug fix: disable address space randomization Linux/x86-64 as well,
     not just x86-64. (reported by Ken Olum)
   * bug fix: #201; type inference for CONS and ARRAY types could derive
index dfd1664..dadb0dc 100644 (file)
 (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
index 8033af8..9d0525a 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.28.8"
+"1.0.28.9"