AVX512, gug in k-register selection

arthur miller <[email protected]>
Newsgroups gmane.lisp.steel-bank.devel
Message-ID <VI1PR09MB2496447C1A56E57653B706A596DB2@VI1PR09MB2496.eurprd09.prod.outlook.com>
Looks like an obvious bug in avx512-insts.lisp.  After applying the
patch everything builds fine, but that is just because it never comes
into play. I don't have yet a finished support for k-registers, so I
can't really test it yet, but this was one of the problems I encountered
working on the support.

_______________________________________________
Sbcl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
0001-Fix-bug-in-selecting-kregister-in-avx512-insts.lisp.patch (text/x-patch, 1.6 KB)
From 83b7a4fd88ba128bc6bbed4d747287b0ac21259e Mon Sep 17 00:00:00 2001
From: arthur <[email protected]>
Date: Thu, 13 Aug 2026 12:42:23 +0200
Subject: [PATCH] Fix bug in selecting kregister in avx512-insts.lisp

---
 src/compiler/x86-64/avx512-insts.lisp | 2 +-
 src/compiler/x86-64/insts.lisp        | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compiler/x86-64/avx512-insts.lisp b/src/compiler/x86-64/avx512-insts.lisp
index 4906a1508..f62ae489f 100644
--- a/src/compiler/x86-64/avx512-insts.lisp
+++ b/src/compiler/x86-64/avx512-insts.lisp
@@ -302,7 +302,7 @@
 (macrolet ((def (name prefix opcode-from opcode-to w)
              `(define-instruction ,name (segment dst src)
                 (:emitter
-                 (cond ((xmm-register-p dst)
+                 (cond ((k-register-p dst)
                         ;; k <- k/m or k <- gpr
                         (emit-vex segment nil src dst ,prefix #x0F nil ,w)
                         (emit-bytes segment ,opcode-from)
diff --git a/src/compiler/x86-64/insts.lisp b/src/compiler/x86-64/insts.lisp
index 1302cbe6c..3d517f474 100644
--- a/src/compiler/x86-64/insts.lisp
+++ b/src/compiler/x86-64/insts.lisp
@@ -1038,6 +1038,10 @@
 (defun zmm-register-p (thing)
   (and (register-p thing) (is-zmm-id-p (reg-id thing))))
 
+;;; Return true if THING is a K register (mask reg k0 - k7).
+(defun k-register-p (thing)
+  (and (register-p thing) (is-kreg-id-p (reg-id thing))))
+
 ;;; Return true if THING is AL, AX, EAX, or RAX
 (defun accumulator-p (thing)
   (and (gpr-p thing) (= 0 (reg-id-num (reg-id thing)))))
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.