master: x86-64: fix mask-signed-field-integer for 64 and any-reg result
stassats via Sbcl-commits <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via d81da0bd3fd665cbe99b26878b2fcfd1e4b29915 (commit)
from 79752fb42ac4af7026c808375371abcd776a7ade (commit)
- Log -----------------------------------------------------------------
commit d81da0bd3fd665cbe99b26878b2fcfd1e4b29915
Author: Stas Boukarev <[email protected]>
Date: Mon Apr 20 22:57:30 2026 +0300
x86-64: fix mask-signed-field-integer for 64 and any-reg result
---
src/compiler/x86-64/arith.lisp | 16 +++++++++++-----
tests/arith-2.pure.lisp | 10 ++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/compiler/x86-64/arith.lisp b/src/compiler/x86-64/arith.lisp
index f9083f8a7..6d2c167e8 100644
--- a/src/compiler/x86-64/arith.lisp
+++ b/src/compiler/x86-64/arith.lisp
@@ -4375,10 +4375,16 @@
(:vop-var vop)
(:generator 6
(move r x)
- (inst sar r n-fixnum-tag-bits)
- (inst jmp :nc (if (> width n-fixnum-bits)
- DONE
- DO))
+ (cond ((and (sc-is r any-reg)
+ (= width n-word-bits))
+ (inst test :byte r fixnum-tag-mask)
+ (inst jmp :z DONE))
+ (t
+ (inst sar r n-fixnum-tag-bits)
+ (inst jmp :nc (if (> width n-fixnum-bits)
+ DONE
+ DO))))
+
(let* ((integerp (eq (tn-kind temp) :unused))
(error (unless integerp
(generate-error-code vop 'object-not-integer-error x))))
@@ -4398,7 +4404,7 @@
(cond
((zerop shift)
(when (sc-is r any-reg)
- (inst sar r n-fixnum-tag-bits)))
+ (inst shl r n-fixnum-tag-bits)))
(t
(inst shl r shift)
(inst sar r (if (sc-is r any-reg)
diff --git a/tests/arith-2.pure.lisp b/tests/arith-2.pure.lisp
index 58eda9c91..76956d874 100644
--- a/tests/arith-2.pure.lisp
+++ b/tests/arith-2.pure.lisp
@@ -2522,3 +2522,13 @@
(ldb (byte sb-vm:n-fixnum-bits 0) (ash 1 b))))
(((1- sb-vm:n-fixnum-bits)) (ash 1 (1- sb-vm:n-fixnum-bits)))
((0) nil)))
+
+(with-test (:name :mask-signed-field-fixnum-result)
+ (checked-compile-and-assert
+ ()
+ `(lambda (x)
+ (truly-the fixnum (sb-c::mask-signed-field sb-vm:n-word-bits x)))
+ (((* most-positive-fixnum (ash 2 sb-vm:n-fixnum-tag-bits)))
+ (ash -2 sb-vm:n-fixnum-tag-bits))
+ ((10)
+ 10)))
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL