From 50ab4a5c49a1e437e95f405b9014a411f8b0d80a Mon Sep 17 00:00:00 2001 From: Sebastian Melzer Date: Sat, 26 Jul 2025 04:53:37 +0200 Subject: [PATCH] Don't use the type of checked TYPED-FORMs to rewrite acode Optimizations that rely on ASSERTED-TYPE might change the value (hence type) of the inner form if it isn't actually of the given type, which would defeat the point of typechecking. This looks like it may hurt the performance of code that both trusts declarations and generates checked TYPED-FORMs, but at the time of writing, this can only happen when the user provides a compiler policy that has both TRUST-DECLARATIONS and DECLARATIONS-TYPECHECK enabled; in the default policy, they're mutually exclusive. --- compiler/acode-rewrite.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/acode-rewrite.lisp b/compiler/acode-rewrite.lisp index f750ec976..d62b61384 100644 --- a/compiler/acode-rewrite.lisp +++ b/compiler/acode-rewrite.lisp @@ -638,7 +638,7 @@ (rewrite-acode-form form type)) (def-acode-rewrite rewrite-typed-form typed-form asserted-type (&whole w type form &optional check) - (rewrite-acode-form form (if (or check *acode-rewrite-trust-declarations*) type t))) + (rewrite-acode-form form (if (and (not check) *acode-rewrite-trust-declarations*) type t))) (def-acode-rewrite rewrite-trivial-unary (fixnum immediate simple-function closed-function lexical-reference bound-special-ref special-ref local-go %function global-ref free-reference inherited-arg) asserted-type (&whole w val) (declare (ignore val)))