From 2690dde0d3d90138d6b23832bee08672ea182034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 8 Dec 2023 20:43:29 +0100 Subject: [PATCH] cmp: inl: tighter type bounds for inlined arguments Also improve PRECISE-LOC-LISP-TYPE to AND both types instead of picking the "new type". --- src/cmp/cmpbackend-cxx/cmpc-arg-inl.lsp | 22 +++++++++------------- src/cmp/cmplocs.lsp | 7 ++++--- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/cmp/cmpbackend-cxx/cmpc-arg-inl.lsp b/src/cmp/cmpbackend-cxx/cmpc-arg-inl.lsp index 3526c39b5..a4749e868 100644 --- a/src/cmp/cmpbackend-cxx/cmpc-arg-inl.lsp +++ b/src/cmp/cmpbackend-cxx/cmpc-arg-inl.lsp @@ -132,19 +132,15 @@ (defun emit-inline-form (form forms) (with-c1form-env (form form) - (case (c1form-name form) - (LOCATION - (precise-loc-lisp-type (c1form-arg 0 form) (c1form-primary-type form))) - (VARIABLE - (emit-inlined-variable form forms)) - (SETQ - (emit-inlined-setq form forms)) - (PROGN - (emit-inlined-progn form forms)) - (VALUES - (emit-inlined-values form forms)) - (t - (emit-inlined-temp-var form (c1form-primary-type form) :object))))) + (precise-loc-lisp-type + (case (c1form-name form) + (LOCATION (c1form-arg 0 form) ) + (VARIABLE (emit-inlined-variable form forms)) + (SETQ (emit-inlined-setq form forms)) + (PROGN (emit-inlined-progn form forms)) + (VALUES (emit-inlined-values form forms)) + (t (emit-inlined-temp-var form t :object))) + (c1form-primary-type form)))) ;;; ;;; inline-args: diff --git a/src/cmp/cmplocs.lsp b/src/cmp/cmplocs.lsp index 29ad64f26..8bba6ceff 100644 --- a/src/cmp/cmplocs.lsp +++ b/src/cmp/cmplocs.lsp @@ -155,9 +155,10 @@ ;;; CL-VA-ARG (defun precise-loc-lisp-type (loc new-type) - (if (subtypep (loc-lisp-type loc) new-type) - loc - `(the ,new-type ,loc))) + (let ((loc-type (loc-lisp-type loc))) + (if (subtypep loc-type new-type) + loc + `(the ,(type-and loc-type new-type) ,loc)))) (defun loc-in-c1form-movable-p (loc) "A location that is in a C1FORM and can be moved"