X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fir1opt.lisp;h=d091f381e4353a5d08f0cd787f297184ccc502c0;hb=49e8403800426f37a54d9b87353a31af36e7af40;hp=62f019a3b4c7ea8a325af56e8ebbc6b2009e596e;hpb=b3c5951a9d24468a2a471fd6769d0e6b687c08f3;p=sbcl.git diff --git a/src/compiler/ir1opt.lisp b/src/compiler/ir1opt.lisp index 62f019a..d091f38 100644 --- a/src/compiler/ir1opt.lisp +++ b/src/compiler/ir1opt.lisp @@ -23,15 +23,28 @@ (defun constant-lvar-p (thing) (declare (type (or lvar null) thing)) (and (lvar-p thing) - (let ((use (principal-lvar-use thing))) - (and (ref-p use) (constant-p (ref-leaf use)))))) + (or (let ((use (principal-lvar-use thing))) + (and (ref-p use) (constant-p (ref-leaf use)))) + ;; check for EQL types (but not singleton numeric types) + (let ((type (lvar-type thing))) + (and (member-type-p type) + (eql 1 (member-type-size type))))))) ;;; Return the constant value for an LVAR whose only use is a constant ;;; node. (declaim (ftype (function (lvar) t) lvar-value)) (defun lvar-value (lvar) - (let ((use (principal-lvar-use lvar))) - (constant-value (ref-leaf use)))) + (let ((use (principal-lvar-use lvar)) + (type (lvar-type lvar)) + leaf) + (cond ((and (ref-p use) + (constant-p (setf leaf (ref-leaf use)))) + (constant-value leaf)) + ((and (member-type-p type) + (eql 1 (member-type-size type))) + (first (member-type-members type))) + (t + (error "~S used on non-constant LVAR ~S" 'lvar-value lvar))))) ;;;; interface for obtaining results of type inference