From de01f09401517c1a96de3faeac585e46895940ec Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Thu, 1 Dec 2005 04:16:00 +0000 Subject: [PATCH] 0.9.7.8: X86-64 floating point changes: * Create FP zeroes with XORPS/XORPD on instead of MOVQ XMM15. * Don't zero XMM15 after every foreign call (not needed anymore thanks to previous change) * Add SQRTSS/SQRTSD instructions * Use SQRTSD for implementing %SQRT, instead of calling to C * Replace &REST in SC-CASE lambda list with &BODY (for better Slime indentation) --- NEWS | 1 + src/code/irrat.lisp | 7 ++++++- src/compiler/meta-vmdef.lisp | 2 +- src/compiler/x86-64/c-call.lisp | 7 +------ src/compiler/x86-64/float.lisp | 20 +++++++++++++++++--- src/compiler/x86-64/insts.lisp | 2 ++ version.lisp-expr | 2 +- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index c68199c..e82ef7f 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ changes in sbcl-0.9.8 relative to sbcl-0.9.7: file-stream. (thanks to Robert J. Macomber) * optimization: improved type inference for arithmetic-for index variables in LOOP + * optimization: faster floating-point SQRT on x86-64 * fixed some bugs revealed by Paul Dietz' test suite: ** DOCUMENTATION returns NIL instead of "" for method combinations that don't have a docstring diff --git a/src/code/irrat.lisp b/src/code/irrat.lisp index 9b901e8..07faa5c 100644 --- a/src/code/irrat.lisp +++ b/src/code/irrat.lisp @@ -53,6 +53,11 @@ (def %log (x)) (def %exp (x))) +#!+x86-64 ;; for constant folding +(macrolet ((def (name ll) + `(defun ,name ,ll (,name ,@ll)))) + (def %sqrt (x))) + ;;;; stubs for the Unix math library ;;;; ;;;; Many of these are unnecessary on the X86 because they're built @@ -78,7 +83,7 @@ #!-x86 (def-math-rtn "log" 1) #!-x86 (def-math-rtn "log10" 1) (def-math-rtn "pow" 2) -#!-x86 (def-math-rtn "sqrt" 1) +#!-(or x86 x86-64) (def-math-rtn "sqrt" 1) (def-math-rtn "hypot" 2) #!-(or hpux x86) (def-math-rtn "log1p" 1) diff --git a/src/compiler/meta-vmdef.lisp b/src/compiler/meta-vmdef.lisp index 5515de7..41270d2 100644 --- a/src/compiler/meta-vmdef.lisp +++ b/src/compiler/meta-vmdef.lisp @@ -1879,7 +1879,7 @@ ;;; beginning with T specifies a default. If it appears, it must be ;;; last. If no default is specified, and no clause matches, then an ;;; error is signalled. -(def!macro sc-case (tn &rest forms) +(def!macro sc-case (tn &body forms) (let ((n-sc (gensym)) (n-tn (gensym))) (collect ((clauses)) diff --git a/src/compiler/x86-64/c-call.lisp b/src/compiler/x86-64/c-call.lisp index a45217f..b2e4fc3 100644 --- a/src/compiler/x86-64/c-call.lisp +++ b/src/compiler/x86-64/c-call.lisp @@ -252,12 +252,7 @@ 'float-registers))) (inst call function) ;; To give the debugger a clue. XX not really internal-error? - (note-this-location vop :internal-error) - ;; FLOAT15 needs to contain FP zero in Lispland - (let ((float15 (make-random-tn :kind :normal - :sc (sc-or-lose 'double-reg) - :offset float15-offset))) - (inst xorpd float15 float15)))) + (note-this-location vop :internal-error))) (define-vop (alloc-number-stack-space) (:info amount) diff --git a/src/compiler/x86-64/float.lisp b/src/compiler/x86-64/float.lisp index 9f97d65..63ae040 100644 --- a/src/compiler/x86-64/float.lisp +++ b/src/compiler/x86-64/float.lisp @@ -64,8 +64,10 @@ (define-move-fun (load-fp-zero 1) (vop x y) ((fp-single-zero) (single-reg) (fp-double-zero) (double-reg)) - (identity x) ; KLUDGE: IDENTITY as IGNORABLE... - (inst movq y fp-double-zero-tn)) + (identity x) + (sc-case y + (single-reg (inst xorps y y)) + (double-reg (inst xorpd y y)))) (define-move-fun (load-single 2) (vop x y) ((single-stack) (single-reg)) @@ -436,7 +438,19 @@ (frob * mulss */single-float 4 mulsd */double-float 5 t) (frob / divss //single-float 12 divsd //double-float 19 nil)) - +(define-vop (fsqrt) + (:args (x :scs (double-reg))) + (:results (y :scs (double-reg))) + (:translate %sqrt) + (:policy :fast-safe) + (:arg-types double-float) + (:result-types double-float) + (:note "inline float arithmetic") + (:vop-var vop) + (:save-p :compute-only) + (:generator 1 + (note-this-location vop :internal-error) + (inst sqrtsd y x))) (macrolet ((frob ((name translate sc type) &body body) `(define-vop (,name) diff --git a/src/compiler/x86-64/insts.lisp b/src/compiler/x86-64/insts.lisp index 68dbf7f..aeb857e 100644 --- a/src/compiler/x86-64/insts.lisp +++ b/src/compiler/x86-64/insts.lisp @@ -3566,6 +3566,8 @@ (define-regular-sse-inst mulss #xf3 #x59) (define-regular-sse-inst subsd #xf2 #x5c) (define-regular-sse-inst subss #xf3 #x5c) + (define-regular-sse-inst sqrtsd #xf2 #x51) + (define-regular-sse-inst sqrtss #xf3 #x51) ;; conversion (define-regular-sse-inst cvtsd2ss #xf2 #x5a) (define-regular-sse-inst cvtss2sd #xf3 #x5a) diff --git a/version.lisp-expr b/version.lisp-expr index a7034fb..6de96c8 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.9.7.7" +"0.9.7.8" -- 1.7.10.4