From 7a961398d8faa8f25725405c882245f498ff5117 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Sun, 6 Nov 2005 04:00:38 +0000 Subject: [PATCH] 0.9.6.24: Faster bignum subtraction and division. (Patch from sbcl-devel "A microoptimisation of bignum subtraction on x86/x86-64" by Lutz Euler on 2005-10-16) --- NEWS | 2 ++ src/compiler/x86-64/arith.lisp | 13 ++++++------- src/compiler/x86/arith.lisp | 11 +++++------ version.lisp-expr | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index ca8d410..aa9d6b8 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,8 @@ changes in sbcl-0.9.7 relative to sbcl-0.9.6: * optimization: much faster memory allocation on x86-64 * optimization: faster garbage collections (latency and throughput) on gencgc + * optimization: faster bignum subtraction and division on x86 and x86-64 + (thanks to Lutz Euler) changes in sbcl-0.9.6 relative to sbcl-0.9.5: * bug fix: add a workaround to SBCL looping infinitely at startup on diff --git a/src/compiler/x86-64/arith.lisp b/src/compiler/x86-64/arith.lisp index 3045903..d509aac 100644 --- a/src/compiler/x86-64/arith.lisp +++ b/src/compiler/x86-64/arith.lisp @@ -1415,8 +1415,8 @@ ;;; For add and sub with carry the sc of carry argument is any-reg so -;;; the it may be passed as a fixnum or word and thus may be 0, 1, or -;;; 4. This is easy to deal with and may save a fixnum-word +;;; that it may be passed as a fixnum or word and thus may be 0, 1, or +;;; 8. This is easy to deal with and may save a fixnum-word ;;; conversion. (define-vop (add-w/carry) (:translate sb!bignum:%add-with-carry) @@ -1437,8 +1437,8 @@ (inst mov carry 0) (inst adc carry carry))) -;;; Note: the borrow is the oppostite of the x86 convention - 1 for no -;;; borrow and 0 for a borrow. +;;; Note: the borrow is 1 for no borrow and 0 for a borrow, the opposite +;;; of the x86-64 convention. (define-vop (sub-w/borrow) (:translate sb!bignum:%subtract-with-borrow) (:policy :fast-safe) @@ -1453,9 +1453,8 @@ (inst cmp c 1) ; Set the carry flag to 1 if c=0 else to 0 (move result a) (inst sbb result b) - (inst mov borrow 0) - (inst adc borrow borrow) - (inst xor borrow 1))) + (inst mov borrow 1) + (inst sbb borrow 0))) (define-vop (bignum-mult-and-add-3-arg) diff --git a/src/compiler/x86/arith.lisp b/src/compiler/x86/arith.lisp index 46f5326..7c6b433 100644 --- a/src/compiler/x86/arith.lisp +++ b/src/compiler/x86/arith.lisp @@ -1421,7 +1421,7 @@ ;;; For add and sub with carry the sc of carry argument is any-reg so -;;; the it may be passed as a fixnum or word and thus may be 0, 1, or +;;; that it may be passed as a fixnum or word and thus may be 0, 1, or ;;; 4. This is easy to deal with and may save a fixnum-word ;;; conversion. (define-vop (add-w/carry) @@ -1443,8 +1443,8 @@ (inst mov carry 0) (inst adc carry carry))) -;;; Note: the borrow is the oppostite of the x86 convention - 1 for no -;;; borrow and 0 for a borrow. +;;; Note: the borrow is 1 for no borrow and 0 for a borrow, the opposite +;;; of the x86 convention. (define-vop (sub-w/borrow) (:translate sb!bignum:%subtract-with-borrow) (:policy :fast-safe) @@ -1459,9 +1459,8 @@ (inst cmp c 1) ; Set the carry flag to 1 if c=0 else to 0 (move result a) (inst sbb result b) - (inst mov borrow 0) - (inst adc borrow borrow) - (inst xor borrow 1))) + (inst mov borrow 1) + (inst sbb borrow 0))) (define-vop (bignum-mult-and-add-3-arg) diff --git a/version.lisp-expr b/version.lisp-expr index a267a31..4337bf5 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.6.23" +"0.9.6.24" -- 1.7.10.4