From 6a71280af32d6bb02ed07d1a576df2cd9c5dfb79 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sat, 29 Oct 2011 21:13:07 +0300 Subject: [PATCH] fix ROTATE-BYTE on 64-bit words using constant negative rotation Fixes lp#882151. --- NEWS | 2 ++ contrib/sb-rotate-byte/rotate-byte-tests.lisp | 12 ++++++++---- contrib/sb-rotate-byte/x86-64-vm.lisp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index e1b4f28..64fdd90 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ changes relative to sbcl-1.0.52: * bug fix: floating-point traps now work on darwin/x86 and /x86-64. * bug fix: repair crash in x86oid darwin signal handling emulation when built with certain compilers. + * bug fix: SB-ROTATE-BYTE misrotated to the right when using constant + rotation arguments on x86-64. (lp#882151) changes in sbcl-1.0.52 relative to sbcl-1.0.51: * enhancement: ASDF has been updated to version 2.017. diff --git a/contrib/sb-rotate-byte/rotate-byte-tests.lisp b/contrib/sb-rotate-byte/rotate-byte-tests.lisp index 11f9b63..6e6b7f6 100644 --- a/contrib/sb-rotate-byte/rotate-byte-tests.lisp +++ b/contrib/sb-rotate-byte/rotate-byte-tests.lisp @@ -73,10 +73,14 @@ (declare (type (unsigned-byte 64) integer)) (rotate-byte 6 (byte 64 0) integer)) -(assert (= (ub64/c 5) 320)) -(assert (= (ub64/c 1) 64)) -(assert (= (ub64/c (ash 1 57)) (ash 1 63))) -(assert (= (ub64/c (ash 1 58)) 1)) +(defun ub64/-c (integer) + (declare (type (unsigned-byte 64) integer)) + (rotate-byte -6 (byte 64 0) integer)) + +(assert (= (ub64/-c 320) 5)) +(assert (= (ub64/-c 64) 1)) +(assert (= (ub64/-c (ash 1 63)) (ash 1 57))) +(assert (= (ub64/-c 1) (ash 1 58))) (defun ub64 (count integer) (declare (type (unsigned-byte 64) integer) diff --git a/contrib/sb-rotate-byte/x86-64-vm.lisp b/contrib/sb-rotate-byte/x86-64-vm.lisp index d45b596..a311933 100644 --- a/contrib/sb-rotate-byte/x86-64-vm.lisp +++ b/contrib/sb-rotate-byte/x86-64-vm.lisp @@ -59,7 +59,7 @@ (move result integer) (if (> count 0) (inst rol result count) - (inst ror result count)))) + (inst ror result (- count))))) (define-vop (%64bit-rotate-byte) (:policy :fast-safe) -- 1.7.10.4