X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Farith.lisp;h=ade76894452a3f916a0ae8dd25f7fc6d008b2467;hb=bffa99d35c7d50ac46b9eb7dbe25d1ab1a0e6145;hp=565a2e920e6fcdfd7f6b4e6617fe26bd6cfd6304;hpb=201e598b805d3b8f3a1206bc487cbb25180cef30;p=sbcl.git diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index 565a2e9..ade7689 100644 --- a/src/compiler/x86/arith.lisp +++ b/src/compiler/x86/arith.lisp @@ -176,9 +176,16 @@ (:translate ,translate) (:generator ,untagged-penalty (move r x) - (inst ,op r y)))))) - - ;;(define-binop + 4 add) + ,(if (eq translate 'logand) + ;; for the -C/UNSIGNED=>UNSIGNED VOP, this case + ;; is optimized away as an identity somewhere + ;; along the lines. However, this VOP is used in + ;; -C/SIGNED=>UNSIGNED, below, when the + ;; higher-level lisp code can't optimize away the + ;; non-trivial identity. + `(unless (= y #.(1- (ash 1 n-word-bits))) + (inst ,op r y)) + `(inst ,op r y))))))) (define-binop - 4 sub) (define-binop logand 2 and) (define-binop logior 2 or) @@ -249,7 +256,6 @@ (move r x) (inst add r y))))) - ;;;; Special logand cases: (logand signed unsigned) => unsigned (define-vop (fast-logand/signed-unsigned=>unsigned @@ -1158,39 +1164,6 @@ (move result prev) (inst shrd result next :cl))) -(define-source-transform 32bit-logical-not (x) - `(logand (lognot (the (unsigned-byte 32) ,x)) #.(1- (ash 1 32)))) - -(deftransform 32bit-logical-and ((x y)) - '(logand x y)) - -(define-source-transform 32bit-logical-nand (x y) - `(32bit-logical-not (32bit-logical-and ,x ,y))) - -(deftransform 32bit-logical-or ((x y)) - '(logior x y)) - -(define-source-transform 32bit-logical-nor (x y) - `(32bit-logical-not (32bit-logical-or ,x ,y))) - -(deftransform 32bit-logical-xor ((x y)) - '(logxor x y)) - -(define-source-transform 32bit-logical-eqv (x y) - `(32bit-logical-not (32bit-logical-xor ,x ,y))) - -(define-source-transform 32bit-logical-orc1 (x y) - `(32bit-logical-or (32bit-logical-not ,x) ,y)) - -(define-source-transform 32bit-logical-orc2 (x y) - `(32bit-logical-or ,x (32bit-logical-not ,y))) - -(define-source-transform 32bit-logical-andc1 (x y) - `(32bit-logical-and (32bit-logical-not ,x) ,y)) - -(define-source-transform 32bit-logical-andc2 (x y) - `(32bit-logical-and ,x (32bit-logical-not ,y))) - ;;; Only the lower 5 bits of the shift amount are significant. (define-vop (shift-towards-someplace) (:policy :fast-safe) @@ -1239,6 +1212,14 @@ fast-ash-c/unsigned=>unsigned) (:translate ash-left-mod32)) +(define-vop (fast-ash-left-mod32/unsigned=>unsigned + fast-ash-left/unsigned=>unsigned)) +(deftransform ash-left-mod32 ((integer count) + ((unsigned-byte 32) (unsigned-byte 5))) + (when (sb!c::constant-lvar-p count) + (sb!c::give-up-ir1-transform)) + '(%primitive fast-ash-left-mod32/unsigned=>unsigned integer count)) + (in-package "SB!C") (defknown sb!vm::%lea-mod32 (integer integer (member 1 2 4 8) (signed-byte 32))