X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fppc%2Farith.lisp;h=5f4bfe140771bcccdff7fcf6f37fe03f37e9c909;hb=5d3a728a1d9a91e7218fe53f12f96ab63b846810;hp=6e90c89be40fa58ee87728f5ba429aeed62b5b33;hpb=cf99421496d43693774e361d33c7c7496a693d6c;p=sbcl.git diff --git a/src/compiler/ppc/arith.lisp b/src/compiler/ppc/arith.lisp index 6e90c89..5f4bfe1 100644 --- a/src/compiler/ppc/arith.lisp +++ b/src/compiler/ppc/arith.lisp @@ -679,10 +679,22 @@ (:result-types tagged-num) (:policy :fast-safe) (:generator 2 - (inst rlwinm res x - (mod (- 32 posn) 32) ; effectively rotate right - (- 32 size n-fixnum-tag-bits) - (- 31 n-fixnum-tag-bits)))) + (let ((phantom-bits (- (+ size posn) 30))) + (cond + ((plusp phantom-bits) + ;; The byte to be loaded into RES includes sign bits which are not + ;; present in the input X physically. RLWINM as used below would + ;; mask these out with 0 even for negative inputs. + (inst srawi res x phantom-bits) + (inst rlwinm res x + (mod (- 32 posn (- phantom-bits)) 32) + (- 32 size n-fixnum-tag-bits) + (- 31 n-fixnum-tag-bits))) + (t + (inst rlwinm res x + (mod (- 32 posn) 32) ; effectively rotate right + (- 32 size n-fixnum-tag-bits) + (- 31 n-fixnum-tag-bits))))))) (define-vop (ldb-c/signed) (:translate %%ldb)