X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Ftypetran.lisp;h=612d2bcc199e1e95e52d32c141e19da67a240122;hb=94ea2b2082deaa0331dfb66fa6af6ca12dd8dc83;hp=5d0fa9d2aba2dfb0835ee5f48c6b2cbeaf8530a3;hpb=8987be18e94b9ef8ba393f05d1157587528810b3;p=sbcl.git diff --git a/src/compiler/typetran.lisp b/src/compiler/typetran.lisp index 5d0fa9d..612d2bc 100644 --- a/src/compiler/typetran.lisp +++ b/src/compiler/typetran.lisp @@ -537,6 +537,16 @@ ;;;; coercion +;;; Constant-folding. +;;; +#-sb-xc-host +(defoptimizer (coerce optimizer) ((x type) node) + (when (and (constant-lvar-p x) (constant-lvar-p type)) + (let ((value (lvar-value x))) + (when (or (numberp value) (characterp value)) + (constant-fold-call node) + t)))) + (deftransform coerce ((x type) (* *) * :node node) (unless (constant-lvar-p type) (give-up-ir1-transform))