master: arm64: fix %make-simd-pack-double/single

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  d8768206569db5aeac11cde0ffad8035b72c472f (commit)
      from  856ed453f33dbb1f218218f5181a2ae3d57acf41 (commit)

- Log -----------------------------------------------------------------
commit d8768206569db5aeac11cde0ffad8035b72c472f
Author: Stas Boukarev <[email protected]>
Date:   Wed Aug 26 00:51:13 2026 +0300

    arm64: fix %make-simd-pack-double/single
    
    Don't overwrite the inputs before they are used.
---
 src/compiler/arm64/simd-pack.lisp | 42 +++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/compiler/arm64/simd-pack.lisp b/src/compiler/arm64/simd-pack.lisp
index 11f586b02..2f4811365 100644
--- a/src/compiler/arm64/simd-pack.lisp
+++ b/src/compiler/arm64/simd-pack.lisp
@@ -308,19 +308,25 @@
 (define-vop (%make-simd-pack-double)
   (:translate %make-simd-pack-double)
   (:policy :fast-safe)
-  (:args (lo :scs (double-reg))
+  (:args (lo :scs (double-reg) :target dst)
          (hi :scs (double-reg)))
   (:arg-types double-float double-float)
   (:results (dst :scs (double-neon-reg)))
   (:result-types simd-pack-double)
   (:generator 5
-    (inst ins dst 0 lo 0 :d)
-    (inst ins dst 1 hi 0 :d)))
+    (cond ((location= dst lo)
+           (inst ins dst 1 hi 0 :d))
+          ((location= dst hi)
+           (inst ins dst 1 hi 0 :d)
+           (inst ins dst 0 lo 0 :d))
+          (t
+           (inst ins dst 0 lo 0 :d)
+           (inst ins dst 1 hi 0 :d)))))
 
 (define-vop (%make-simd-pack-single)
   (:translate %make-simd-pack-single)
   (:policy :fast-safe)
-  (:args (x :scs (single-reg))
+  (:args (x :scs (single-reg) :target dst)
          (y :scs (single-reg))
          (z :scs (single-reg))
          (w :scs (single-reg)))
@@ -328,10 +334,30 @@
   (:results (dst :scs (single-neon-reg)))
   (:result-types simd-pack-single)
   (:generator 5
-    (inst ins dst 0 x 0 :s)
-    (inst ins dst 1 y 0 :s)
-    (inst ins dst 2 z 0 :s)
-    (inst ins dst 3 w 0 :s)))
+    (cond ((location= dst x)
+           (inst ins dst 1 y 0 :s)
+           (inst ins dst 2 z 0 :s)
+           (inst ins dst 3 w 0 :s))
+          ((location= dst y)
+           (inst ins dst 1 y 0 :s)
+           (inst ins dst 0 x 0 :s)
+           (inst ins dst 2 z 0 :s)
+           (inst ins dst 3 w 0 :s))
+          ((location= dst z)
+           (inst ins dst 2 z 0 :s)
+           (inst ins dst 0 x 0 :s)
+           (inst ins dst 1 y 0 :s)
+           (inst ins dst 3 w 0 :s))
+          ((location= dst w)
+           (inst ins dst 3 w 0 :s)
+           (inst ins dst 0 x 0 :s)
+           (inst ins dst 1 y 0 :s)
+           (inst ins dst 2 z 0 :s))
+          (t
+           (inst ins dst 0 x 0 :s)
+           (inst ins dst 1 y 0 :s)
+           (inst ins dst 2 z 0 :s)
+           (inst ins dst 3 w 0 :s)))))
 
 (defknown %simd-pack-single-item
   (simd-pack (integer 0 3)) single-float (flushable))

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
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.