From 0e5a40455a1a3cc16cc71ad0f0b063eb4f1f2c3f Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Thu, 25 Mar 2004 21:51:53 +0000 Subject: [PATCH] 0.8.9.5: 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. --- src/compiler/x86/arith.lisp | 14 ++++++++++---- version.lisp-expr | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index 565a2e9..25d7091 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 diff --git a/version.lisp-expr b/version.lisp-expr index df7e8d7..2b9a0a8 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; 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".) -"0.8.9.4" +"0.8.9.5" -- 1.7.10.4