X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fir1final.lisp;h=4dd2925dd62fb755c9d86d8cb92e14d2e1472473;hb=c47519c9e63fd32a635943a84ec13d8a60d95f08;hp=d2888c5f79bf91522d141c9a34a1b5168a881802;hpb=57e21c4b62e8c1a1ee7ef59ed2abb0c864fb06bc;p=sbcl.git diff --git a/src/compiler/ir1final.lisp b/src/compiler/ir1final.lisp index d2888c5..4dd2925 100644 --- a/src/compiler/ir1final.lisp +++ b/src/compiler/ir1final.lisp @@ -115,6 +115,27 @@ (setq atype (note-fun-use dest atype))))) (setf (info :function :assumed-type name) atype)))) +;;; Merge CASTs with preceding/following nodes. +(defun ir1-merge-casts (component) + (do-blocks-backwards (block component) + (do-nodes-backwards (node lvar block) + (let ((dest (when lvar (lvar-dest lvar)))) + (cond ((and (cast-p dest) + (not (cast-type-check dest)) + (immediately-used-p lvar node)) + (when (values-types-equal-or-intersect + (node-derived-type node) + (cast-asserted-type dest)) + ;; FIXME: We do not perform pathwise CAST->type-error + ;; conversion, and type errors can later cause + ;; backend failures. On the other hand, this version + ;; produces less efficient code. + (derive-node-type node (cast-asserted-type dest)))) + ((and (cast-p node) + (eq (cast-type-check node) :external)) + (aver (basic-combination-p dest)) + (delete-filter node lvar (cast-value node)))))))) + ;;; Do miscellaneous things that we want to do once all optimization ;;; has been done: ;;; -- Record the derived result type before the back-end trashes the @@ -136,4 +157,7 @@ (maphash (lambda (k v) (note-assumed-types component k v)) *free-funs*) + + (ir1-merge-casts component) + (values))