X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fppc%2Farith.lisp;h=5f4bfe140771bcccdff7fcf6f37fe03f37e9c909;hb=bc7cd341567dd3b2978c2accb6063356280fb80e;hp=9f8c2f34d3857ae3c2695bb686dcac4f7e1a25ce;hpb=1907ad030ca773162bcd9ff90fdc485a035591f4;p=sbcl.git diff --git a/src/compiler/ppc/arith.lisp b/src/compiler/ppc/arith.lisp index 9f8c2f3..5f4bfe1 100644 --- a/src/compiler/ppc/arith.lisp +++ b/src/compiler/ppc/arith.lisp @@ -459,7 +459,7 @@ (:temporary (:scs (non-descriptor-reg)) temp) (:translate *) (:generator 2 - (inst srawi temp y 2) + (inst srawi temp y n-fixnum-tag-bits) (inst mullw r x temp))) (define-vop (fast-*-c/fixnum=>fixnum fast-fixnum-binop-c) @@ -679,15 +679,27 @@ (: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) (:args (x :scs (signed-reg))) - (:arg-types signed-num (:constant (integer 1 29)) (:constant (integer 0 29))) + (:arg-types signed-num (:constant (integer 1 29)) (:constant (integer 0 31))) (:info size posn) (:results (res :scs (any-reg))) (:result-types tagged-num) @@ -701,7 +713,7 @@ (define-vop (ldb-c/unsigned) (:translate %%ldb) (:args (x :scs (unsigned-reg))) - (:arg-types unsigned-num (:constant (integer 1 29)) (:constant (integer 0 29))) + (:arg-types unsigned-num (:constant (integer 1 29)) (:constant (integer 0 31))) (:info size posn) (:results (res :scs (any-reg))) (:result-types tagged-num) @@ -711,7 +723,6 @@ (mod (- (+ 32 n-fixnum-tag-bits) posn) 32) (- 32 size n-fixnum-tag-bits) (- 31 n-fixnum-tag-bits)))) - ;;;; Modular functions: (define-modular-fun lognot-mod32 (x) lognot :untagged nil 32) @@ -1006,28 +1017,6 @@ ;;;; 32-bit logical operations -(define-vop (merge-bits) - (:translate merge-bits) - (:args (shift :scs (signed-reg unsigned-reg)) - (prev :scs (unsigned-reg)) - (next :scs (unsigned-reg))) - (:arg-types tagged-num unsigned-num unsigned-num) - (:temporary (:scs (unsigned-reg) :to (:result 0)) temp) - (:temporary (:scs (unsigned-reg) :to (:result 0) :target result) res) - (:results (result :scs (unsigned-reg))) - (:result-types unsigned-num) - (:policy :fast-safe) - (:generator 4 - (let ((done (gen-label))) - (inst cmpwi shift 0) - (inst beq done) - (inst srw res next shift) - (inst sub temp zero-tn shift) - (inst slw temp prev temp) - (inst or res res temp) - (emit-label done) - (move result res)))) - (define-vop (shift-towards-someplace) (:policy :fast-safe) (:args (num :scs (unsigned-reg)) @@ -1176,6 +1165,34 @@ (inst mullw lo x y) (inst mulhwu hi x y))) +#!+multiply-high-vops +(define-vop (mulhi) + (:translate sb!kernel:%multiply-high) + (:policy :fast-safe) + (:args (x :scs (unsigned-reg)) + (y :scs (unsigned-reg))) + (:arg-types unsigned-num unsigned-num) + (:results (hi :scs (unsigned-reg))) + (:result-types unsigned-num) + (:generator 20 + (inst mulhwu hi x y))) + +#!+multiply-high-vops +(define-vop (mulhi/fx) + (:translate sb!kernel:%multiply-high) + (:policy :fast-safe) + (:args (x :scs (any-reg)) + (y :scs (unsigned-reg))) + (:arg-types positive-fixnum unsigned-num) + (:temporary (:sc non-descriptor-reg :from :eval :to :result) temp) + (:temporary (:sc non-descriptor-reg :from :eval :to :result) mask) + (:results (hi :scs (any-reg))) + (:result-types positive-fixnum) + (:generator 15 + (inst mulhwu temp x y) + (inst lr mask fixnum-tag-mask) + (inst andc hi temp mask))) + (define-vop (bignum-lognot lognot-mod32/unsigned=>unsigned) (:translate sb!bignum:%lognot)) @@ -1187,11 +1204,11 @@ (:results (digit :scs (unsigned-reg))) (:result-types unsigned-num) (:generator 1 - (inst srawi digit fixnum 2))) + (inst srawi digit fixnum n-fixnum-tag-bits))) (define-vop (bignum-floor) - (:translate sb!bignum:%floor) + (:translate sb!bignum:%bigfloor) (:policy :fast-safe) (:args (num-high :scs (unsigned-reg) :target rem) (num-low :scs (unsigned-reg) :target rem-low) @@ -1229,7 +1246,7 @@ #| (define-vop (bignum-floor) - (:translate sb!bignum:%floor) + (:translate sb!bignum:%bigfloor) (:policy :fast-safe) (:args (div-high :scs (unsigned-reg) :target rem) (div-low :scs (unsigned-reg) :target quo) @@ -1254,7 +1271,7 @@ (:generator 1 (sc-case res (any-reg - (inst slwi res digit 2)) + (inst slwi res digit n-fixnum-tag-bits)) (signed-reg (move res digit)))))