1.0.4.57: Make the compiler's bit-vector functions use standard CL idioms
authorNathan Froyd <froydnj@cs.rice.edu>
Tue, 10 Apr 2007 18:10:31 +0000 (18:10 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Tue, 10 Apr 2007 18:10:31 +0000 (18:10 +0000)
* We can do this and still get inline loops because of the
  REPLACE/UB*-BASH-COPY/SUBSEQ/COPY-SEQ work committed early;
* ...and, as a nice bonus, make them slightly faster by doing so.

src/compiler/bit-util.lisp
version.lisp-expr

index 0bc7498..ca564bb 100644 (file)
 ;;; Clear a SIMPLE-BIT-VECTOR to zeros.
 (defun clear-bit-vector (vec)
   (declare (type simple-bit-vector vec))
-  (bit-xor vec vec t))
-
-;;; The old (pre-1999) code had a more-efficient-looking, but also
-;;; less-portable implementation of CLEAR-BIT-VECTOR:
-;;;  (do ((i sb!vm:vector-data-offset (1+ i))
-;;;       (end (+ sb!vm:vector-data-offset
-;;;            (ash (+ (length vec) (1- sb!vm:n-word-bits))
-;;;                 (- (1- (integer-length sb!vm:n-word-bits)))))))
-;;;      ((= i end) vec)
-;;;    (setf (sb!kernel:%raw-bits vec i) 0)))
-;;; We could use this in the target SBCL if the new version turns out to be a
-;;; bottleneck. I (WHN 19990321) will stick to the portable version for now.
-;;; And by the way, if we do revisit this file with efficiency on our mind, it
-;;; might be good to check whether it's really that helpful to implement
-;;; all these functions as INLINE. (How expensive can it be to call a
-;;; 1-argument function? How expensive is it to fill up our cache with
-;;; a bunch of redundant loop expansions?)
-;;;
-;;; FIXME: Perhaps do simple benchmarks against CMU CL to check this.
+  (fill vec 0))
 
 ;;; Fill a bit vector with ones.
 (defun set-bit-vector (vec)
   (declare (type simple-bit-vector vec))
-  (bit-orc2 vec vec t))
+  (fill vec 1))
 
 ;;; Replace the bits in To with the bits in From.
 (defun bit-vector-replace (to from)
   (declare (type simple-bit-vector to from))
-  (bit-ior from from to))
+  (replace to from))
 
 ;;; Copy a bit-vector.
 (defun bit-vector-copy (vec)
   (declare (type simple-bit-vector vec))
-  (bit-ior vec vec (make-array (length vec) :element-type 'bit)))
+  (copy-seq vec))
index aebc90c..50e8753 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.4.56"
+"1.0.4.57"