X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.pure.lisp;h=948d419bbc8d7b2d882a2efda56e893b4d0da6e4;hb=2b596efa9a6b08a22bbdcdf88198c5d2af1d0335;hp=928780cef199b59dcfcac64ec68dc86c1c3e0806;hpb=d4073df37f0540f148b1b702a32ffba8c646a0ca;p=sbcl.git diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 928780c..948d419 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -446,8 +446,8 @@ (declare (notinline mapcar)) (1+ (mapcar #'print '(1 2 3))))))) -;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant -;; index was effectless +;;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant +;;; index was effectless (let ((f (compile nil '(lambda (a v) (declare (type simple-bit-vector a) (type bit v)) (declare (optimize (speed 3) (safety 0))) @@ -463,7 +463,7 @@ (declare (type (simple-array (simple-string 3) (5)) x)) (aref (aref x 0) 0)))) -;; compiler failure +;;; compiler failure (let ((f (compile nil '(lambda (x) (typep x '(not (member 0d0))))))) (assert (funcall f 1d0))) @@ -471,3 +471,52 @@ (declare (double-float x)) (let ((y (* x pi))) (atan y y)))) + +;;; bogus optimization of BIT-NOT +(multiple-value-bind (result x) + (eval '(let ((x (eval #*1001))) + (declare (optimize (speed 2) (space 3)) + (type (bit-vector) x)) + (values (bit-not x nil) x))) + (assert (equal x #*1001)) + (assert (equal result #*0110))) + +;;; the VECTOR type in CONCATENATE/MERGE/MAKE-SEQUENCE means (VECTOR T). +(handler-bind ((sb-ext:compiler-note #'error)) + (assert (equalp (funcall + (compile + nil + '(lambda () + (let ((x (make-sequence 'vector 10 :initial-element 'a))) + (setf (aref x 4) 'b) + x)))) + #(a a a a b a a a a a)))) + +;;; this is not a check for a bug, but rather a test of compiler +;;; quality +(dolist (type '((integer 0 *) ; upper bound + (real (-1) *) + float ; class + (real * (-10)) ; lower bound + )) + (assert (nth-value + 1 (compile nil + `(lambda (n) + (declare (optimize (speed 3) (compilation-speed 0))) + (loop for i from 1 to (the (integer -17 10) n) by 2 + collect (when (> (random 10) 5) + (the ,type (- i 11))))))))) + +;;; bug 278b +;;; +;;; We suppose that INTEGER arithmetic cannot be efficient, and the +;;; compiler has an optimized VOP for +; so this code should cause an +;;; efficiency note. +(assert (eq (block nil + (handler-case + (compile nil '(lambda (i) + (declare (optimize speed)) + (declare (type integer i)) + (+ i 2))) + (sb-ext:compiler-note (c) (return :good)))) + :good))