Comment 1 for bug 2012990

Revision history for this message
ari pro (aripro) wrote :

I think the issue might be with f64.2-shuffle, which is used by f64.2-values, which in turn is used to define the horizontal functions mentioned above.

(require "SB-SIMD")
(setf sb-ext:*evaluator-mode* :compile)

(sb-simd-sse2:f64.2-shuffle (sb-simd-sse2:make-f64.2 1.2d0 3.9d0) 1)
=> #<SIMD-PACK 3.9000000000000d+0 1.2000000000000d+0>

(let ((x (sb-simd-sse2:make-f64.2 1.2d0 3.9d0)))
  (sb-simd-sse2:f64.2-shuffle x 1))
=> #<SIMD-PACK 0.0000000000000d+0 1.2000000000000d+0>

(let ((x (sb-simd-sse2:make-f64.2 1.2d0 3.9d0)))
  (declare (optimize (debug 2)))
  (sb-simd-sse2:f64.2-shuffle x 1))
=> #<SIMD-PACK 3.9000000000000d+0 1.2000000000000d+0>

As above, f64.2-shuffle works fine with sb-eval and sb-fasteval.

You could "fix" f64.2-values and the horizontal functions with the following, but it would be better to figure out the cause of the f64.2-shuffle trouble.

From d4a01c7c1d10087e33c025023b727cd41cbd1441 Mon Sep 17 00:00:00 2001
From: me <email address hidden>
Date: Wed, 29 Mar 2023 01:32:58 +0000
Subject: [PATCH] Adjust sb-simd-sse2:f64.2-values

---
 contrib/sb-simd/code/define-fake-vops.lisp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/sb-simd/code/define-fake-vops.lisp b/contrib/sb-simd/code/define-fake-vops.lisp
index 4432791c4..e0099c63e 100644
--- a/contrib/sb-simd/code/define-fake-vops.lisp
+++ b/contrib/sb-simd/code/define-fake-vops.lisp
@@ -420,7 +420,7 @@
 (define-fake-vop f64.2-values (x)
   (values
    (%f64!-from-p128 x)
- (%f64!-from-p128 (%f64.2-shuffle x 1))))
+ (%f64!-from-p128 (%f64.2-unpackhi x x))))

 (define-fake-vop f64.2-broadcast (x)
   (let ((v (%f64.2!-from-f64 x)))
--
2.39.1