X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.pure.lisp;h=4b0af785abbc68f842ca87f96a571ffc49a7310e;hb=36a379d746b9eb74ba8c5afff40dc5dcb9f4557a;hp=e2eac2f949df8f8c94723b981c3601758cf8ffed;hpb=72fc4e4a1325e8761d97a36080fa50a8e75ed523;p=sbcl.git diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index e2eac2f..4b0af78 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -1977,3 +1977,112 @@ (declare (optimize (safety 3) (space 3) (compilation-speed 3) (speed 0) (debug 1))) (not (not (logbitp 0 (floor 2147483651 (min -23 0)))))))))) + +;; mistyping found by random-tester +(assert (zerop + (funcall + (compile + nil + '(lambda () + (declare (optimize (speed 1) (debug 0) + (space 2) (safety 0) (compilation-speed 0))) + (unwind-protect 0 + (* (/ (multiple-value-prog1 -29457482 -5602513511) 1)))))))) + +;; aggressive constant folding (bug #400) +(assert + (eq t (funcall (compile nil '(lambda () (or t (the integer (/ 1 0)))))))) + +(with-test (:name (:compiler :constraint-propagation :var-eql-to-non-var-1)) + (assert + (handler-case + (compile nil '(lambda (x y) + (when (eql x (length y)) + (locally + (declare (optimize (speed 3))) + (1+ x))))) + (compiler-note () (error "The code is not optimized."))))) + +(with-test (:name (:compiler :constraint-propagation :var-eql-to-non-var-2)) + (assert + (handler-case + (compile nil '(lambda (x y) + (when (eql (length y) x) + (locally + (declare (optimize (speed 3))) + (1+ x))))) + (compiler-note () (error "The code is not optimized."))))) + +(with-test (:name (:compiler :constraint-propagation :float-bounds-1)) + (handler-case + (compile nil '(lambda (x) + (declare (type (single-float * (3.0)) x)) + (when (<= x 2.0) + (when (<= 2.0 x) + x)))) + (compiler-note () (error "Deleted reachable code.")))) + +(with-test (:name (:compiler :constraint-propagation :float-bounds-2)) + (catch :note + (handler-case + (compile nil '(lambda (x) + (declare (type single-float x)) + (when (< 1.0 x) + (when (<= x 1.0) + (error "This is unreachable."))))) + (compiler-note () (throw :note nil))) + (error "Unreachable code undetected."))) + +;; Reported by John Wiseman, sbcl-devel +;; Subject: [Sbcl-devel] float type derivation bug? +;; Date: Tue, 4 Apr 2006 15:28:15 -0700 +(with-test (:name (:type-derivation :float-bounds)) + (compile nil '(lambda (bits) + (let* ((s (if (= (ash bits -31) 0) 1 -1)) + (e (logand (ash bits -23) #xff)) + (m (if (= e 0) + (ash (logand bits #x7fffff) 1) + (logior (logand bits #x7fffff) #x800000)))) + (float (* s m (expt 2 (- e 150)))))))) + +;; Reported by James Knight +;; Subject: [Sbcl-devel] AVER: "(EQ (SB-NAME (SC-SB (TN-SC TN))) 'REGISTERS)" +;; Date: Fri, 24 Mar 2006 19:30:00 -0500 +(with-test (:name :logbitp-vop) + (compile nil + '(lambda (days shift) + (declare (type fixnum shift days)) + (let* ((result 0) + (canonicalized-shift (+ shift 1)) + (first-wrapping-day (- 1 canonicalized-shift))) + (declare (type fixnum result)) + (dotimes (source-day 7) + (declare (type (integer 0 6) source-day)) + (when (logbitp source-day days) + (setf result + (logior result + (the fixnum + (if (< source-day first-wrapping-day) + (+ source-day canonicalized-shift) + (- (+ source-day + canonicalized-shift) 7))))))) + result)))) + +;;; MISC.637: incorrect delaying of conversion of optional entries +;;; with hairy constant defaults +(let ((f '(lambda () + (labels ((%f11 (f11-2 &key key1) + (labels ((%f8 (f8-2 &optional (f8-5 (if nil (return-from %f11 0) 0))) + :bad1)) + (%f8 (%f8 0))) + :bad2)) + :good)))) + (assert (eq (funcall (compile nil f)) :good))) + +;;; MISC.555: new reference to an already-optimized local function +(let* ((l '(lambda (p1) + (declare (optimize (speed 1) (safety 2) (debug 2) (space 0)) (type keyword p1)) + (keywordp p1))) + (f (compile nil l))) + (assert (funcall f :good)) + (assert (nth-value 1 (ignore-errors (funcall f 42)))))