X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86-64%2Farith.lisp;h=cd06c8e59d3fdb68d1ad0159b57452631a6cb65a;hb=3254e1b6fb33e4ff5be5f37ba4bbcc34ca151cf7;hp=cfe4ad4e5c3167716776159567cadbfa7c96de32;hpb=7deecae2d959173eda6a153d490c752c32050a9e;p=sbcl.git diff --git a/src/compiler/x86-64/arith.lisp b/src/compiler/x86-64/arith.lisp index cfe4ad4..cd06c8e 100644 --- a/src/compiler/x86-64/arith.lisp +++ b/src/compiler/x86-64/arith.lisp @@ -667,6 +667,8 @@ (location= number result))))) (:result-types tagged-num) (:note "inline ASH") + (:variant nil) + (:variant-vars modularp) (:generator 2 (cond ((and (= amount 1) (not (location= number result))) (inst lea result (make-ea :qword :base number :index number))) @@ -685,8 +687,11 @@ (inst sar result (- amount)) (inst and result (lognot fixnum-tag-mask))))) ((plusp amount) + (unless modularp + (aver (not "Impossible: fixnum ASH should not be called with +constant shift greater than word length"))) (if (sc-is result any-reg) - (inst xor result result) + (zeroize result) (inst mov result 0))) (t (inst sar result 63) (inst and result (lognot fixnum-tag-mask)))))))) @@ -1367,6 +1372,7 @@ (define-vop (fast-ash-left-smod61-c/fixnum=>fixnum fast-ash-c/fixnum=>fixnum) + (:variant :modular) (:translate ash-left-smod61)) (define-vop (fast-ash-left-smod61/fixnum=>fixnum fast-ash-left/fixnum=>fixnum)) @@ -1604,6 +1610,42 @@ (move hi edx) (move lo eax))) +#!+multiply-high-vops +(define-vop (mulhi) + (:translate sb!kernel:%multiply-high) + (:policy :fast-safe) + (:args (x :scs (unsigned-reg) :target eax) + (y :scs (unsigned-reg unsigned-stack))) + (:arg-types unsigned-num unsigned-num) + (:temporary (:sc unsigned-reg :offset eax-offset :from (:argument 0)) + eax) + (:temporary (:sc unsigned-reg :offset edx-offset :from (:argument 1) + :to (:result 0) :target hi) edx) + (:results (hi :scs (unsigned-reg))) + (:result-types unsigned-num) + (:generator 20 + (move eax x) + (inst mul eax y) + (move hi edx))) + +#!+multiply-high-vops +(define-vop (mulhi/fx) + (:translate sb!kernel:%multiply-high) + (:policy :fast-safe) + (:args (x :scs (any-reg) :target eax) + (y :scs (unsigned-reg unsigned-stack))) + (:arg-types positive-fixnum unsigned-num) + (:temporary (:sc any-reg :offset eax-offset :from (:argument 0)) eax) + (:temporary (:sc any-reg :offset edx-offset :from (:argument 1) + :to (:result 0) :target hi) edx) + (:results (hi :scs (any-reg))) + (:result-types positive-fixnum) + (:generator 15 + (move eax x) + (inst mul eax y) + (move hi edx) + (inst and hi (lognot fixnum-tag-mask)))) + (define-vop (bignum-lognot lognot-mod64/unsigned=>unsigned) (:translate sb!bignum:%lognot)) @@ -1622,7 +1664,7 @@ (inst sar digit 3))) (define-vop (bignum-floor) - (:translate sb!bignum:%floor) + (:translate sb!bignum:%bigfloor) (:policy :fast-safe) (:args (div-high :scs (unsigned-reg) :target edx) (div-low :scs (unsigned-reg) :target eax)