From 6d99452f2fa662cdc9ca7cae9c9d4ca9751fd27d Mon Sep 17 00:00:00 2001 From: Lutz Euler Date: Tue, 30 Aug 2011 18:41:38 -0400 Subject: [PATCH] Microoptimization for code size in floating point comparisons on x86-64 This affects EQL on real and complex floats and "=" on floats when at least one of the two arguments is complex. Use a 32-bit register as the destination of the MOVMSKP[SD] and the source of the integer comparison instead of a 64-bit one. This doesn't change the semantics but makes both instruction's encodings shorter. If the register is EAX do the comparison on AL as this additionally shortens the encoding. Before: 660F76C1 PCMPEQD XMM0, XMM1 480F50C0 MOVMSKPS RAX, XMM0 4883F80F CMP RAX, 15 After: 660F76C1 PCMPEQD XMM0, XMM1 0F50C0 MOVMSKPS EAX, XMM0 3C0F CMP AL, 15 --- src/compiler/x86-64/float.lisp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/x86-64/float.lisp b/src/compiler/x86-64/float.lisp index c74c8c7..0a03d50 100644 --- a/src/compiler/x86-64/float.lisp +++ b/src/compiler/x86-64/float.lisp @@ -856,7 +856,7 @@ :load-if (not (sc-is y ,constant-sc)))) (:arg-types ,type ,type) (:temporary (:sc ,sc :from :eval) mask) - (:temporary (:sc any-reg) bits) + (:temporary (:sc dword-reg) bits) (:conditional :e) (:generator ,cost (when (or (location= y mask) @@ -868,7 +868,8 @@ (setf y (register-inline-constant :aligned (tn-value y)))) (inst pcmpeqd mask y) (inst movmskps bits mask) - (inst cmp bits #b1111))))) + (inst cmp (if (location= bits eax-tn) al-tn bits) + #b1111))))) (define-float-eql eql/single-float 4 single-reg fp-single-immediate single-float) (define-float-eql eql/double-float 4 @@ -980,7 +981,7 @@ :load-if (not (sc-is y ,complex-constant-sc)))) (:arg-types ,complex-type ,complex-type) (:temporary (:sc ,complex-sc :from :eval) cmp) - (:temporary (:sc unsigned-reg) bits) + (:temporary (:sc dword-reg) bits) (:info) (:conditional :e) (:generator 3 @@ -1000,7 +1001,8 @@ (note-this-location vop :internal-error) (inst ,cmp-inst :eq cmp y) (inst ,mask-inst bits cmp) - (inst cmp bits ,mask))) + (inst cmp (if (location= bits eax-tn) al-tn bits) + ,mask))) (define-vop (,complex-real-name ,complex-complex-name) (:args (x :scs (,complex-sc ,complex-constant-sc) :target cmp -- 1.7.10.4