Rename xmm-tn-p to float-register-tn-p
arthur miller <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.devel |
|---|---|
| Message-ID | <VI1PR09MB2496CFD75C28895214B4A10296A42@VI1PR09MB2496.eurprd09.prod.outlook.com> |
I would like to refactor an older function for Intel simd support. Is that OK please? The reason: The name xmm-tn-p is a misnomer. The code checks whether a register is in storage base for float registers which can be xmm, ymm, zmm, float, double, complex float and complex double registers. While it is true xmm-tn-p asks if a TN is in float registers SB, it also suggests we are differentiating between ymm-tn-p, zmm-tn-p etc, which is not really the case here. It caused me a bug and some investigation while working on mask registers support. Another question: do you prefer patches, pull requests on GH, or just to notify you when I have something? 🙂 I see you have applied the GH branch, not the patch I send yesterday. _______________________________________________ Sbcl-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sbcl-devel
0001-Rename-xmm-tn-p-to-float-register-tn-p.patch
(text/x-patch, 5 KB)
From 53207941914edfa53ad6c41e306b5dc2c0240b8b Mon Sep 17 00:00:00 2001 From: arthur <[email protected]> Date: Thu, 20 Aug 2026 19:05:16 +0200 Subject: [PATCH] Rename xmm-tn-p to float-register-tn-p Updated all call-sites to new name. Removed zmm-tn-p Motivation: The name xmm-tn-p is a misnomer. The code checks whether a register is in storage base for float registers which can be xmm, ymm, zmm, float, double, complex float and complex double registers. While it is true xmm-tn-p asks if a TN is in float registers SB, it also suggests we are differentiating between ymm-tn-p, zmm-tn-p etc, which is not really the case here. It caused me a bug and some investigation while working on mask registers support. To save others doing a similar mistake in the future, let us rename it to more descriptive name. zmm-tn-p was implemented inneficiently, but more importantly does not have any caller, and thus is not needed for avx512 support. I can put back a more efficient implementation if/when it is needed. --- src/compiler/x86-64/float.lisp | 4 ++-- src/compiler/x86-64/insts.lisp | 2 +- src/compiler/x86-64/macros.lisp | 16 ++++++++-------- src/compiler/x86-64/vm.lisp | 11 +++++------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/compiler/x86-64/float.lisp b/src/compiler/x86-64/float.lisp index 5e8b507ec..b76e6aa09 100644 --- a/src/compiler/x86-64/float.lisp +++ b/src/compiler/x86-64/float.lisp @@ -941,7 +941,7 @@ (:variant nil) (:generator 3 (when (or (location= y xmm) - (and (not (xmm-tn-p x)) (xmm-tn-p y))) + (and (not (float-register-tn-p x)) (float-register-tn-p y))) (rotatef x y)) (sc-case x (single-reg (setf xmm x)) @@ -975,7 +975,7 @@ (:vop-var vop) (:generator 3 (when (or (location= y xmm) - (and (not (xmm-tn-p x)) (xmm-tn-p y))) + (and (not (float-register-tn-p x)) (float-register-tn-p y))) (rotatef x y)) (sc-case x (double-reg diff --git a/src/compiler/x86-64/insts.lisp b/src/compiler/x86-64/insts.lisp index c0b9786a6..6c0575614 100644 --- a/src/compiler/x86-64/insts.lisp +++ b/src/compiler/x86-64/insts.lisp @@ -1021,7 +1021,7 @@ (ldb (byte 5 3) reg-id)) ;;; Note that SB-VM has its own variation on these predicates -;;; operating on TNs: GPR-TN-P, XMM-TN-P +;;; operating on TNs: GPR-TN-P, FLOAT-REGISTER-TN-P ;;; Return true if THING is a general-purpose register. (defun gpr-p (thing) diff --git a/src/compiler/x86-64/macros.lisp b/src/compiler/x86-64/macros.lisp index 24ce5c509..dcc8180ae 100644 --- a/src/compiler/x86-64/macros.lisp +++ b/src/compiler/x86-64/macros.lisp @@ -22,34 +22,34 @@ (unless (location= dst src) (sc-case dst ((single-reg complex-single-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst movaps dst src)) ((double-reg complex-double-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst movapd dst src)) #+sb-simd-pack ((int-sse-reg sse-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst movdqa dst src)) #+sb-simd-pack ((single-sse-reg double-sse-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst movaps dst src)) #+sb-simd-pack-256 (int-avx2-reg - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst vmovdqa dst src)) #+sb-simd-pack-256 ((single-avx2-reg double-avx2-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst vmovaps dst src)) #+sb-simd-pack-512 (int-avx512-reg - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst vmovdqu64 dst src)) #+sb-simd-pack-512 ((single-avx512-reg double-avx512-reg) - (aver (xmm-tn-p src)) + (aver (float-register-tn-p src)) (inst vmovups dst src)) (t (if size diff --git a/src/compiler/x86-64/vm.lisp b/src/compiler/x86-64/vm.lisp index e8a73b96b..1e279a41d 100644 --- a/src/compiler/x86-64/vm.lisp +++ b/src/compiler/x86-64/vm.lisp @@ -464,15 +464,14 @@ (defun gpr-tn-p (thing) (and (tn-p thing) (eq (sb-name (sc-sb (tn-sc thing))) 'registers))) -;;; Return true if THING is an XMM register TN. -(defun xmm-tn-p (thing) + +;;; Return true if THING is a TN in the FLOAT-REGISTERS storage base. This +;;; includes XMM, YMM, ZMM SIMD registers, but also scalar float, double and +;;; complex float/double, but does not include mask registers. +(defun float-register-tn-p (thing) (and (tn-p thing) (eq (sb-name (sc-sb (tn-sc thing))) 'float-registers))) -(defun zmm-tn-p (tn) - (member (tn-sc tn) (list (sc-or-lose 'single-avx512-reg) - (sc-or-lose 'double-avx512-reg) - (sc-or-lose 'int-avx512-reg)))) ;;; Return true if THING is on the stack (in whatever storage class). (defun stack-tn-p (thing) (and (tn-p thing) -- 2.55.0