From 09f925d42d072d74c6977cc52e3ebf36135d2e15 Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Tue, 21 May 2013 16:20:40 -0400 Subject: [PATCH] Implement EQ of unboxed characters and small integers on x86oids More important now that we actually weaken EQL of EQ-comparable types into EQ. We just have to re-purpose pre-existing EQL and CHAR= templates (and adjust the generic test's cost to be less attractive), but I can't test on !x86oids. Spotted by Douglas Katzman. --- src/compiler/x86-64/pred.lisp | 20 +++++++++++++++++++- src/compiler/x86/pred.lisp | 12 +++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/compiler/x86-64/pred.lisp b/src/compiler/x86-64/pred.lisp index 428c2c1..e66a11d 100644 --- a/src/compiler/x86-64/pred.lisp +++ b/src/compiler/x86-64/pred.lisp @@ -217,7 +217,7 @@ (:conditional :e) (:policy :fast-safe) (:translate eq) - (:generator 3 + (:generator 8 (cond ((sc-is y immediate) (let ((val (tn-value y))) @@ -258,3 +258,21 @@ character-widetag)))))) (t (inst cmp x y))))) + +;; The template above is a very good fallback for the generic +;; case. However, it is sometimes possible to perform unboxed +;; comparisons. Repurpose char= and eql templates here, instead +;; of forcing values to be boxed and then compared. +;; +;; We only weaken EQL => EQ for characters and fixnums, and detect +;; when types definitely mismatch. No need to import other EQL +;; VOPs (e.g. floats). +(macrolet ((def (eq-name eql-name) + `(define-vop (,eq-name ,eql-name) + (:translate eq)))) + (def fast-if-eq-character fast-char=/character) + (def fast-if-eq-character/c fast-char=/character/c) + (def fast-if-eq/signed fast-if-eql/signed) + (def fast-if-eq-c/signed fast-if-eql-c/signed) + (def fast-if-eq/unsigned fast-if-eql/unsigned) + (def fast-if-eq-c/unsigned fast-if-eql-c/unsigned)) diff --git a/src/compiler/x86/pred.lisp b/src/compiler/x86/pred.lisp index da77d6f..7be691e 100644 --- a/src/compiler/x86/pred.lisp +++ b/src/compiler/x86/pred.lisp @@ -177,7 +177,7 @@ (:info) (:policy :fast-safe) (:translate eq) - (:generator 3 + (:generator 8 (let ((x-val (encode-value-if-immediate x)) (y-val (encode-value-if-immediate y))) (cond @@ -189,3 +189,13 @@ ((sc-is x immediate) (inst cmp y x-val)) (t (inst cmp x y-val)))))) + +(macrolet ((def (eq-name eql-name) + `(define-vop (,eq-name ,eql-name) + (:translate eq)))) + (def fast-if-eq-character fast-char=/character) + (def fast-if-eq-character/c fast-char=/character/c) + (def fast-if-eq/signed fast-if-eql/signed) + (def fast-if-eq-c/signed fast-if-eql-c/signed) + (def fast-if-eq/unsigned fast-if-eql/unsigned) + (def fast-if-eq-c/unsigned fast-if-eql-c/unsigned)) -- 1.7.10.4