0.9.18.53:
authorNathan Froyd <froydnj@cs.rice.edu>
Wed, 15 Nov 2006 16:19:56 +0000 (16:19 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Wed, 15 Nov 2006 16:19:56 +0000 (16:19 +0000)
Optimize MAP and MAP-INTO with vector arguments.

* Introduce new optimization quality, INSERT-ARRAY-BOUNDS-CHECKS;
* Use it in the %MAP and MAP-INTO transforms.  (We needed something
  more fine-grained than (SAFETY 0), because we still want
  any necessary type-checking to take place.  But we know that
  eliminating the bounds checks are safe.)

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

diff --git a/NEWS b/NEWS
index b685d71..9455b9a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@ changes in sbcl-0.9.19 (1.0.0?) relative to sbcl-0.9.18:
     incompatible element types (thanks to Mario Mommer)
   * optimization: method calls with &OPTIONAL or &KEY arguments are faster
     and don't cause extra consing
+  * optimization: MAP and MAP-INTO are significantly faster on vectors
+    whose elements types have been declared.
   * Improvements to the Windows port:
     ** floating point exceptions are now reported correctly.
     ** stack exhaustion detection works partially.
index fd4e9a9..ee40d89 100644 (file)
 ;;; compile-time or we are generating unsafe code, don't bother with
 ;;; the VOP.
 (deftransform %check-bound ((array dimension index) * * :node node)
-  (cond ((policy node (and (> speed safety) (= safety 0)))
+  (cond ((policy node (= insert-array-bounds-checks 0))
          'index)
         ((not (constant-lvar-p dimension))
          (give-up-ir1-transform))
index 78759f4..3bcdcaa 100644 (file)
@@ -87,3 +87,7 @@
         3
         0)
   ("no" "no" "no" "yes"))
+
+(define-optimization-quality insert-array-bounds-checks
+    (if (= safety 0) 0 3)
+  ("no" "yes" "yes" "yes"))
index 0ce0497..57a9d0f 100644 (file)
                        (tests `(endp ,index))))
                     ((csubtypep type (specifier-type 'vector))
                      (process-vector `(length ,seq-name))
-                     (places `(aref ,seq-name index)))
+                     (places `(locally (declare (optimize (insert-array-bounds-checks 0)))
+                                (aref ,seq-name index))))
                     (t
                      (give-up-ir1-transform
                       "can't determine sequence argument type"))))
          :result '(when (array-has-fill-pointer-p result)
                    (setf (fill-pointer result) index))
          :into 'result
-         :body '(setf (aref result index) funcall-result))
+         :body '(locally (declare (optimize (insert-array-bounds-checks 0)))
+                 (setf (aref result index) funcall-result)))
        result)))
 
 \f
index 72f3f96..d63745c 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".)
-"0.9.18.52"
+"0.9.18.53"