X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Finsts.lisp;h=a7873edbe49d12a7338db4ea018af691908d494a;hb=fd63d6aad4a5a3b171eafb56b1b6bd502e501281;hp=ea56bf591c290e66e5951505d5604690106aa448;hpb=9e02121865a6d59a49021dcbe3e5ba6afbca8b58;p=sbcl.git diff --git a/src/compiler/x86/insts.lisp b/src/compiler/x86/insts.lisp index ea56bf5..a7873ed 100644 --- a/src/compiler/x86/insts.lisp +++ b/src/compiler/x86/insts.lisp @@ -729,7 +729,7 @@ (stack ;; Convert stack tns into an index off of EBP. (let ((disp (- (* (1+ (tn-offset thing)) n-word-bytes)))) - (cond ((< -128 disp 127) + (cond ((<= -128 disp 127) (emit-mod-reg-r/m-byte segment #b01 reg #b101) (emit-byte segment disp)) (t @@ -1533,6 +1533,30 @@ (t (error "bogus operands for TEST: ~S and ~S" this that))))))) +;;; Emit the most compact form of the test immediate instruction, +;;; using an 8 bit test when the immediate is only 8 bits and the +;;; value is one of the four low registers (eax, ebx, ecx, edx) or the +;;; control stack. +(defun emit-optimized-test-inst (x y) + (typecase y + ((unsigned-byte 7) + (let ((offset (tn-offset x))) + (cond ((and (sc-is x any-reg descriptor-reg) + (or (= offset eax-offset) (= offset ebx-offset) + (= offset ecx-offset) (= offset edx-offset))) + (inst test (make-random-tn :kind :normal + :sc (sc-or-lose 'byte-reg) + :offset offset) + y)) + ((sc-is x control-stack) + (inst test (make-ea :byte :base ebp-tn + :disp (- (* (1+ offset) n-word-bytes))) + y)) + (t + (inst test x y))))) + (t + (inst test x y)))) + (define-instruction or (segment dst src) (:printer-list (arith-inst-printer-list #b001))