From 5fbaded1c55f908a403e52b85bf16f85641c9453 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Mon, 8 Sep 2003 13:42:12 +0000 Subject: [PATCH] 0.8.3.45: Fix bug 285 ... %MULTIPLY vop was feeling free to scribble over its inputs ... add :FROM and :TO clauses to try to prevent this ... %MULTIPLY-AND-ADD vops are unchanged, but could quite easily be wrong OK, OK, I give in ... relax the type declaration on signed-immediate instructions to allow (unsigned-byte 16)s through --- BUGS | 25 ------------------------- NEWS | 3 +++ src/compiler/ppc/arith.lisp | 8 ++++---- src/compiler/ppc/float.lisp | 2 +- src/compiler/ppc/insts.lisp | 3 ++- tests/arith.pure.lisp | 6 ++++++ version.lisp-expr | 2 +- 7 files changed, 17 insertions(+), 32 deletions(-) diff --git a/BUGS b/BUGS index 13c5cc4..29b0af6 100644 --- a/BUGS +++ b/BUGS @@ -1204,31 +1204,6 @@ WORKAROUND: least some of them are indicative of potentially thread-unsafe parts of the system. See doc/internals/notes/threading-specials -285: PPC randomness - In SBCL 0.8.3.1x on a powerpc running Linux (dunno if Darwin is - similarly affected): - * (dotimes (i 100) (random 1663553320000000)) - - NIL - * (dotimes (i 100) (random 1663553340000000)) - - NIL - * (dotimes (i 100) (random 1663553350000000)) - - debugger invoked on condition of type TYPE-ERROR: - The value -30653269094906 - is not of type - (OR (SINGLE-FLOAT 0.0) (DOUBLE-FLOAT 0.0d0) (RATIONAL 0)). - - and, weirdly, the frame is: - ("hairy arg processor for top level local call RANDOM" - 1663553347392000 - #S(RANDOM-STATE - :STATE #(0 2567483615 188 1503590015 2333049409 322761517 ...))) - - (the type error doesn't seem to be terribly deterministic in when it - occurs. Bigger numbers seem better able to trigger the error) - 286: "recursive known functions" Self-call recognition conflicts with known function recognition. Currently cross compiler and target COMPILE do not diff --git a/NEWS b/NEWS index faea919..fbbdb39 100644 --- a/NEWS +++ b/NEWS @@ -2018,6 +2018,9 @@ changes in sbcl-0.8.4 relative to sbcl-0.8.3: (reported by Rainer Joswig) * bug fix: ASH on an (UNSIGNED-BYTE 32) with a shift of -32 or lower no longer ever returns 1 instead of 0. (thanks to Lars Brinkhoff) + * fixed bug 285: TRUNCATE on bignum arguments, and indeed bignum + arithmetic in general, is now much more reliable on the PPC + platform. * optimization: restored some effective method precomputation in CLOS (turned off by an ANSI fix in sbcl-0.8.3); the amount of precomputation is now tunable. diff --git a/src/compiler/ppc/arith.lisp b/src/compiler/ppc/arith.lisp index 9cc48ee..91f23bf 100644 --- a/src/compiler/ppc/arith.lisp +++ b/src/compiler/ppc/arith.lisp @@ -835,11 +835,11 @@ (define-vop (bignum-mult) (:translate sb!bignum::%multiply) (:policy :fast-safe) - (:args (x :scs (unsigned-reg) :to (:result 1)) - (y :scs (unsigned-reg) :to (:result 1))) + (:args (x :scs (unsigned-reg) :to (:eval 1)) + (y :scs (unsigned-reg) :to (:eval 1))) (:arg-types unsigned-num unsigned-num) - (:results (hi :scs (unsigned-reg)) - (lo :scs (unsigned-reg))) + (:results (hi :scs (unsigned-reg) :from (:eval 1)) + (lo :scs (unsigned-reg) :from (:eval 0))) (:result-types unsigned-num unsigned-num) (:generator 40 (inst mullw lo x y) diff --git a/src/compiler/ppc/float.lisp b/src/compiler/ppc/float.lisp index 86a5a9d..d2bd56f 100644 --- a/src/compiler/ppc/float.lisp +++ b/src/compiler/ppc/float.lisp @@ -467,7 +467,7 @@ (temp-offset-low (* (1+ stack-offset) sb!vm:n-word-bytes))) (inst lis rtemp #x4330) ; High word of magic constant (inst stw rtemp nfp-tn temp-offset-high) - (inst lis rtemp #x-8000) + (inst lis rtemp #x8000) (inst stw rtemp nfp-tn temp-offset-low) (inst lfd fmagic nfp-tn temp-offset-high) (inst xor rtemp rtemp x) ; invert sign bit of x : rtemp had #x80000000 diff --git a/src/compiler/ppc/insts.lisp b/src/compiler/ppc/insts.lisp index 81e9b76..26bad5c 100644 --- a/src/compiler/ppc/insts.lisp +++ b/src/compiler/ppc/insts.lisp @@ -858,7 +858,8 @@ (multiple-value-bind (other-reads other-writes) (classify-dependencies other-dependencies) `(define-instruction ,name (segment rt ra si) (:declare (type (or ,@(when fixup '(fixup)) - (signed-byte 16)) si)) + (unsigned-byte 16) (signed-byte 16)) + si)) (:printer d-si ((op ,op))) (:delay ,cost) (:cost ,cost) diff --git a/tests/arith.pure.lisp b/tests/arith.pure.lisp index de583e5..00ff6af 100644 --- a/tests/arith.pure.lisp +++ b/tests/arith.pure.lisp @@ -110,3 +110,9 @@ (assert (= (gcd 0 x) (abs x)))) ;;; LCM returns a non-negative number (assert (= (lcm 4 -10) 20)) + +;;; PPC bignum arithmetic bug: +(multiple-value-bind (quo rem) + (truncate 291351647815394962053040658028983955 10000000000000000000000000) + (assert (= quo 29135164781)) + (assert (= rem 5394962053040658028983955))) diff --git a/version.lisp-expr b/version.lisp-expr index 9d398ae..cefce68 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.3.44" +"0.8.3.45" -- 1.7.10.4