From fa6891bcd19066601d081010e747ecd2df9ecbdd Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Tue, 4 Aug 2026 17:36:24 +0300 Subject: [PATCH] Avoid creating bignums for (zerop (mask-field ...)) Which is a transformation of (ldb-test ...) --- src/compiler/srctran.lisp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp index 373f1ef51..9eeef6208 100644 --- a/src/compiler/srctran.lisp +++ b/src/compiler/srctran.lisp @@ -3618,13 +3618,22 @@ (let* ((size (lvar-value size)) (posn (lvar-value posn)) (mask (mask-field (byte size posn) -1))) - (if (and (<= mask most-positive-word) - (or (combination-matches '= '(* 0) (node-dest node)) - (combination-matches '> '(* 0) (node-dest node)))) - (progn - (erase-node-type node (specifier-type 'word)) - `(logand integer ,mask)) - (give-up-ir1-transform)))) + (cond ((and (<= mask most-positive-word) + (or (combination-matches '= '(* 0) (node-dest node)) + (combination-matches '> '(* 0) (node-dest node)))) + (erase-node-type node (specifier-type 'word)) + `(logand integer ,mask)) + (t + (give-up-ir1-transform))))) + +;;; Avoid creating bignums +(deftransform %mask-field ((size posn int) * * :node node) + (cond ((or (combination-matches '= '(* 0) (node-dest node)) + (combination-matches '> '(* 0) (node-dest node))) + (erase-node-type node (specifier-type 'unsigned-byte)) + `(%ldb size posn int)) + (t + (give-up-ir1-transform)))) (deftransform %mask-field ((size posn int) ((integer 0 #.sb-vm:n-word-bits) fixnum integer) word) "convert to inline logical operations"