From d28fd45be76a37fdb0106527aae61b5592f271b5 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sat, 1 Aug 2026 07:38:51 +0300 Subject: [PATCH] Fix do-conset-elements for big-endian --- src/compiler/constraint.lisp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/compiler/constraint.lisp b/src/compiler/constraint.lisp index 492ea442b8..fde14b0e61 100644 --- src/compiler/constraint.lisp +++ src/compiler/constraint.lisp @@ -530,14 +530,17 @@ (aref ,universe ;; COUNT-TRAILING-ZEROS produces slightly better code than ;; INTEGER-LENGTH. Either iteration direction is ok. - (logior (sb-c::if-vop-existsp (:translate count-trailing-zeros) - (prog1 (count-trailing-zeros ,word) - ;; Clear the lowest 1 bit via the Brian Kernighan - ;; technique (allegedly) - (setq ,word (logand ,word (sb-vm::+-mod64 ,word -1)))) - (let ((bit (1- (integer-length ,word)))) - (setq ,word (logxor ,word (ash 1 bit))) - bit)) + (logior (let ((bit + (sb-c::if-vop-existsp (:translate count-trailing-zeros) + (prog1 (count-trailing-zeros ,word) + ;; Clear the lowest 1 bit via the Brian Kernighan + ;; technique (allegedly) + (setq ,word (logand ,word (sb-vm::+-mod64 ,word -1)))) + (let ((bit (1- (integer-length ,word)))) + (setq ,word (logxor ,word (ash 1 bit))) + bit)))) + #+little-endian bit + #+big-endian (- sb-vm:n-word-bits 1 bit)) (* ,index sb-vm:n-word-bits)))))) ,@body))) finally (return ,result)))