From d131dfb49a3e6522d2358d14252f3f52cfcd202a Mon Sep 17 00:00:00 2001 From: Alexey Dejneka Date: Sun, 26 Oct 2003 14:15:06 +0000 Subject: [PATCH] 0.8.5.7: * Fix bug MISC.99 found by Paul Dietz: on X86 in FAST-ASH-C/UNSIGNED=>UNSIGNED VOP add case (>= shift 32) (the code is shared with -MOD32 version, where "result type constraint" does not guarantee overflow absence). --- NEWS | 2 ++ src/compiler/x86/arith.lisp | 10 +++++++--- tests/compiler.pure.lisp | 9 +++++++++ version.lisp-expr | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0b8c6c485..bb0555bb3 100644 --- a/NEWS +++ b/NEWS @@ -2178,6 +2178,8 @@ changes in sbcl-0.8.6 relative to sbcl-0.8.5: * fixed some bugs revealed by Paul Dietz' test suite: ** compiler failure in compiling LOGAND expressions including a constant 0. + ** implementation of ASH-MOD32 on X86 did not work for the shift + greater than 32. planned incompatible changes in 0.8.x: * (not done yet, but planned:) When the profiling interface settles diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index 39efee17b..36b869d71 100644 --- a/src/compiler/x86/arith.lisp +++ b/src/compiler/x86/arith.lisp @@ -683,9 +683,13 @@ (inst lea result (make-ea :dword :index number :scale 8))) (t (move result number) - (cond ((plusp amount) (inst shl result amount)) - ((< amount -31) (inst xor result result)) - (t (inst shr result (- amount)))))))) + (cond ((< -32 amount 32) + ;; this code is used both in ASH and ASH-MOD32, so + ;; be careful + (if (plusp amount) + (inst shl result amount) + (inst shr result (- amount)))) + (t (inst xor result result))))))) (define-vop (fast-ash-left/signed=>signed) (:translate ash) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 89b89254f..bd999b71c 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -695,3 +695,12 @@ (assert (= (funcall (compile nil (lambda (x) (logand x x 0))) -1) 0)) + +;;; MISC.99 from Paul Dietz' random tester: FAST-ASH-MOD32-C VOP +;;; produced wrong result for shift >=32 on X86 +(assert (= 0 (funcall + (compile nil + '(lambda (a) + (declare (type (integer 4303063 101130078) a)) + (mask-field (byte 18 2) (ash a 77)))) + 57132532))) diff --git a/version.lisp-expr b/version.lisp-expr index 07a3e59bd..55ab16bf7 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.5.6" +"0.8.5.7" -- 2.11.4.GIT