1.0.43.46: Simplify some type tests to EQL comparisons
authorPaul Khuong <pvk@pvk.ca>
Tue, 12 Oct 2010 04:52:24 +0000 (04:52 +0000)
committerPaul Khuong <pvk@pvk.ca>
Tue, 12 Oct 2010 04:52:24 +0000 (04:52 +0000)
 * When the type to test is a singleton type, check for EQLity
   against the one value inhabiting that type.

src/compiler/typetran.lisp
version.lisp-expr

index c1f818d..4f1fa05 100644 (file)
           ((eq type *empty-type*)
            nil)
           (t
-           (give-up-ir1-transform)))))
+           (let ((intersect (type-intersection2 type otype)))
+             (unless intersect
+               (give-up-ir1-transform))
+             (multiple-value-bind (constantp value)
+                 (type-singleton-p intersect)
+               (if constantp
+                   `(eql object ',value)
+                   (give-up-ir1-transform))))))))
 
 ;;; Flush %TYPEP tests whose result is known at compile time.
 (deftransform %typep ((object type))
     (or (when (not ctype)
           (compiler-warn "illegal type specifier for TYPEP: ~S" type)
           (return-from source-transform-typep (values nil t)))
+        (multiple-value-bind (constantp value) (type-singleton-p ctype)
+          (and constantp
+               `(eql ,object ',value)))
         (let ((pred (cdr (assoc ctype *backend-type-predicates*
                                 :test #'type=))))
           (when pred `(,pred ,object)))
index c3b6308..b1d24d0 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.43.45"
+"1.0.43.46"