master: x86-64/truncate-c: correctly determine if the quotient is unused
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 cfdbd482aa0e894d85f23664bfeece658df325f1 (commit)
from 566883ab44ee474bfa5b12a00e8b6aeb2d946fdb (commit)
- Log -----------------------------------------------------------------
commit cfdbd482aa0e894d85f23664bfeece658df325f1
Author: Stas Boukarev <[email protected]>
Date: Sun Apr 19 20:05:31 2026 +0300
x86-64/truncate-c: correctly determine if the quotient is unused
Fixes lp#2148782
---
src/compiler/x86-64/arith.lisp | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/compiler/x86-64/arith.lisp b/src/compiler/x86-64/arith.lisp
index 2b5b9de99..4f7da4e0c 100644
--- a/src/compiler/x86-64/arith.lisp
+++ b/src/compiler/x86-64/arith.lisp
@@ -2066,6 +2066,7 @@
(:temporary (:sc any-reg :from :eval :to :result) y-arg)
(:results (quo :scs (any-reg))
(rem :scs (any-reg)))
+ (:optional-results quo)
(:result-types tagged-num tagged-num)
(:note "inline fixnum arithmetic")
(:vop-var vop)
@@ -2075,7 +2076,7 @@
;; on TRUNCATE and I don't understand how they get tried in the optimal order.
;; The benefit of that is we could just invoke the fastrem-32 or fastrem-64 vop
;; rather than having to replicate them inside here.
- (when (and (not (sb-c::tn-reads quo))
+ (when (and (eq (tn-kind quo) :unused)
(typep y '(unsigned-byte 64))
(csubtypep (tn-ref-type (vop-args vop)) (specifier-type '(unsigned-byte 64))))
;; The reason for the concern about inputs is that the general algorithm to accept
@@ -2112,11 +2113,12 @@
(inst cqo)
(inst mov y-arg (fixnumize y))
(inst idiv y-arg)
- (if (location= quo rax)
- (inst shl rax n-fixnum-tag-bits)
- (if (= n-fixnum-tag-bits 1)
- (inst lea quo (ea rax rax))
- (inst lea quo (ea nil rax (ash 1 n-fixnum-tag-bits)))))
+ (unless (eq (tn-kind quo) :unused)
+ (if (location= quo rax)
+ (inst shl rax n-fixnum-tag-bits)
+ (if (= n-fixnum-tag-bits 1)
+ (inst lea quo (ea rax rax))
+ (inst lea quo (ea nil rax (ash 1 n-fixnum-tag-bits))))))
(move rem rdx))))
(define-vop (fast-truncate/unsigned=>unsigned fast-safe-arith-op)
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL