Pointless microoptimizations 'R' us:
... in (defun foo (x)
(declare (optimize speed) (type (signed-byte 32) x))
(logand x #xffffffff))
on the x86, there is no need to perform the hardware AND, as
we are not interested in the flags. Make it so. (The system
already automatically handles the representation such that X
and the result can live in the same register -- to see this,
wrap the LOGAND above as (ASH (LOGAND ...) -3) and disassemble.
(:translate ,translate)
(:generator ,untagged-penalty
(move r x)
(: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)
(define-binop - 4 sub)
(define-binop logand 2 and)
(define-binop logior 2 or)
(move r x)
(inst add r y)))))
(move r x)
(inst add r y)))))
;;;; Special logand cases: (logand signed unsigned) => unsigned
(define-vop (fast-logand/signed-unsigned=>unsigned
;;;; Special logand cases: (logand signed unsigned) => unsigned
(define-vop (fast-logand/signed-unsigned=>unsigned
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)