diff --git a/src/compiler/modarith.lisp b/src/compiler/modarith.lisp index 0f009367a..f3c7f1d44 100644 --- a/src/compiler/modarith.lisp +++ b/src/compiler/modarith.lisp @@ -200,12 +200,9 @@ (unless (cond ((and (vop-existsp :named sb-vm::logand-word-mask) ;; logand-word-mask works without inserting additional cuts (combination-match2 ((lvar-dest lvar) :transform nil) - ((logand a b) - (let ((other-type - (lvar-type (if (lvar-from-lvar-p b lvar) - a - b)))) - (csubtypep other-type type)))))) + ((logand (:type unsigned-byte a) b) + (when (lvar-from-lvar-p b lvar) + (csubtypep (lvar-type a) type)))))) (t (combination-match2 ((lvar-dest lvar) :transform nil) diff --git a/tests/arith-2.pure.lisp b/tests/arith-2.pure.lisp index 8a49ce477..85ab85ed5 100644 --- a/tests/arith-2.pure.lisp +++ b/tests/arith-2.pure.lisp @@ -2655,3 +2655,11 @@ ((5 11) t) ((5 10) nil) (((ash 1 (1- sb-vm:n-word-bits)) 0) (condition 'type-error)))) + +(with-test (:name :cut-to-width-omit-logand) + (checked-compile-and-assert + () + `(lambda (d) + (logand (lognot (logand d -3)) 1)) + ((-7726172277034401953) 0) + ((0) 1)))