From 96c58393bebcf502919736ca2e00874ce46a6aee Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Wed, 27 Dec 2017 09:46:59 -0800
Subject: [PATCH] Modify random-state-jump to use 32-bit ints

Break the constants in the jump function into 32-bit chunks so we
operate on 32-bit integers instead of 64-bit integers.

This is a minor optimization.
---
 src/code/rand-xoroshiro.lisp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/code/rand-xoroshiro.lisp b/src/code/rand-xoroshiro.lisp
index 5cfd7021a..a7af285ea 100644
--- a/src/code/rand-xoroshiro.lisp
+++ b/src/code/rand-xoroshiro.lisp
@@ -485,9 +485,12 @@
 	(s1-1 0))
     (declare (type (unsigned-byte 32) s0-0 s0-1 s1-0 s1-1)
 	     (optimize (speed 3) (safety 0)))
-    (dolist (jump '(#xbeac0467eba5facb #xd86b048b86aa9922))
-      (declare (type (unsigned-byte 64) jump))
-      (dotimes (b 64)
+    ;; The constants are #xbeac0467eba5facb and #xd86b048b86aa9922,
+    ;; and we process these numbers starting from the LSB.  We want ot
+    ;; process these in 32-bit chunks, so word-reverse the constants.
+    (dolist (jump '(#xeba5facb #xbeac0467 #x86aa9922 #xd86b048b))
+      (declare (type (unsigned-byte 32) jump))
+      (dotimes (b 32)
 	(declare (fixnum b))
 	(when (logbitp b jump)
 	  (multiple-value-bind (x1 x0)
-- 
GitLab