X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcompiler%2Fx86%2Fpred.lisp;h=e83f65f12c3e50f31dd55e22f2dad4a03e41fe5f;hb=6822034325136cde4e14773c83c3769b42721306;hp=fcfe65f0878dddbc7a3bad3ae8e1454f07063504;hpb=cea4896b2482b7b2b429c1631d774b4cfbc0efba;p=sbcl.git diff --git a/src/compiler/x86/pred.lisp b/src/compiler/x86/pred.lisp index fcfe65f..e83f65f 100644 --- a/src/compiler/x86/pred.lisp +++ b/src/compiler/x86/pred.lisp @@ -27,44 +27,27 @@ ;;; not immediate data. (define-vop (if-eq) (:args (x :scs (any-reg descriptor-reg control-stack constant) - :load-if (not (and (sc-is x immediate) - (sc-is y any-reg descriptor-reg - control-stack constant)))) - (y :scs (any-reg descriptor-reg immediate) - :load-if (not (and (sc-is x any-reg descriptor-reg immediate) - (sc-is y control-stack constant))))) + :load-if (not (and (sc-is x immediate) + (sc-is y any-reg descriptor-reg + control-stack constant)))) + (y :scs (any-reg descriptor-reg immediate) + :load-if (not (and (sc-is x any-reg descriptor-reg immediate) + (sc-is y control-stack constant))))) (:conditional) (:info target not-p) (:policy :fast-safe) (:translate eq) (:generator 3 - (cond - ((sc-is y immediate) - (let ((val (tn-value y))) - (etypecase val - (integer - (if (and (zerop val) (sc-is x any-reg descriptor-reg)) - (inst test x x) ; smaller - (inst cmp x (fixnumize val)))) - (symbol - (inst cmp x (+ nil-value (static-symbol-offset val)))) - (character - (inst cmp x (logior (ash (char-code val) type-bits) - base-char-type)))))) - ((sc-is x immediate) ; and y not immediate - ;; Swap the order to fit the compare instruction. - (let ((val (tn-value x))) - (etypecase val - (integer - (if (and (zerop val) (sc-is y any-reg descriptor-reg)) - (inst test y y) ; smaller - (inst cmp y (fixnumize val)))) - (symbol - (inst cmp y (+ nil-value (static-symbol-offset val)))) - (character - (inst cmp y (logior (ash (char-code val) type-bits) - base-char-type)))))) - (t - (inst cmp x y))) + (let ((x-val (encode-value-if-immediate x)) + (y-val (encode-value-if-immediate y))) + (cond + ;; Shorter instruction sequences for these two cases. + ((and (eql 0 y-val) (sc-is x any-reg descriptor-reg)) (inst test x x)) + ((and (eql 0 x-val) (sc-is y any-reg descriptor-reg)) (inst test y y)) + + ;; An encoded value (literal integer) has to be the second argument. + ((sc-is x immediate) (inst cmp y x-val)) + + (t (inst cmp x y-val)))) (inst jmp (if not-p :ne :e) target)))