X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Farith.lisp;h=76d39af7929be9c3442f02ee96592c55b4c79ebc;hb=e0697854ef9f4999c8585b64be1b282ce4725176;hp=565a2e920e6fcdfd7f6b4e6617fe26bd6cfd6304;hpb=201e598b805d3b8f3a1206bc487cbb25180cef30;p=sbcl.git diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index 565a2e9..76d39af 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,38 +1164,38 @@ (move result prev) (inst shrd result next :cl))) -(define-source-transform 32bit-logical-not (x) +(define-source-transform word-logical-not (x) `(logand (lognot (the (unsigned-byte 32) ,x)) #.(1- (ash 1 32)))) -(deftransform 32bit-logical-and ((x y)) +(deftransform word-logical-and ((x y)) '(logand x y)) -(define-source-transform 32bit-logical-nand (x y) - `(32bit-logical-not (32bit-logical-and ,x ,y))) +(define-source-transform word-logical-nand (x y) + `(word-logical-not (word-logical-and ,x ,y))) -(deftransform 32bit-logical-or ((x y)) +(deftransform word-logical-or ((x y)) '(logior x y)) -(define-source-transform 32bit-logical-nor (x y) - `(32bit-logical-not (32bit-logical-or ,x ,y))) +(define-source-transform word-logical-nor (x y) + `(word-logical-not (word-logical-or ,x ,y))) -(deftransform 32bit-logical-xor ((x y)) +(deftransform word-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 word-logical-eqv (x y) + `(word-logical-not (word-logical-xor ,x ,y))) -(define-source-transform 32bit-logical-orc1 (x y) - `(32bit-logical-or (32bit-logical-not ,x) ,y)) +(define-source-transform word-logical-orc1 (x y) + `(word-logical-or (word-logical-not ,x) ,y)) -(define-source-transform 32bit-logical-orc2 (x y) - `(32bit-logical-or ,x (32bit-logical-not ,y))) +(define-source-transform word-logical-orc2 (x y) + `(word-logical-or ,x (word-logical-not ,y))) -(define-source-transform 32bit-logical-andc1 (x y) - `(32bit-logical-and (32bit-logical-not ,x) ,y)) +(define-source-transform word-logical-andc1 (x y) + `(word-logical-and (word-logical-not ,x) ,y)) -(define-source-transform 32bit-logical-andc2 (x y) - `(32bit-logical-and ,x (32bit-logical-not ,y))) +(define-source-transform word-logical-andc2 (x y) + `(word-logical-and ,x (word-logical-not ,y))) ;;; Only the lower 5 bits of the shift amount are significant. (define-vop (shift-towards-someplace)