Skip to content
Snippets Groups Projects
Commit e723773c authored by dtc's avatar dtc
Browse files

From Raymond Toy:

o  Enable the v9 version of emit-multiply.  This is slightly slower
   than the v8 version, but doesn't use the deprecated instructions
   and registers.  This approximately doubles the speed of bignum
   multiplies.

o  Add a v9 version of bignum::%floor.  This approximately doubles the
   speed of bignum floors.  No v8 version because the divide
   instruction might overflow.
parent a35709b5
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/arith.lisp,v 1.12 1999/06/19 16:01:02 dtc Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/arith.lisp,v 1.13 1999/06/22 14:53:16 dtc Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -646,27 +646,22 @@ ...@@ -646,27 +646,22 @@
Note: the lifetimes of MULTIPLICAND and RESULT-HIGH overlap." Note: the lifetimes of MULTIPLICAND and RESULT-HIGH overlap."
(declare (type tn multiplier result-high result-low) (declare (type tn multiplier result-high result-low)
(type (or tn (signed-byte 13)) multiplicand)) (type (or tn (signed-byte 13)) multiplicand))
(cond #+nil ;; It seems that emit-multiply is only used to do an unsigned
((backend-featurep :sparc-v9) ;; multiply, so the code only does an unsigned multiply.
;; Take advantage of V9's 64-bit multiplier. It seems that (cond ((backend-featurep :sparc-v9)
;; emit-multiply is only used to do an unsigned multiply, so ;; Take advantage of V9's 64-bit multiplier.
;; the code only does an unsigned multiply.
;; ;;
;; Clear out the high bits of the multiplier and ;; Multiply the two numbers and put the result in
;; multiplicand. Multiply the two numbers and put the result ;; result-high. Copy the low 32-bits to result-low. Then
;; in result-high. Copy the low 32-bits to result-low. Then
;; shift result-high so the high 32-bits end up in the low ;; shift result-high so the high 32-bits end up in the low
;; 32-bits. ;; 32-bits.
(inst srl multiplier multiplier 0)
(unless (numberp multiplicand)
(inst srl multiplicand multiplicand 0))
(inst mulx result-high multiplier multiplicand) (inst mulx result-high multiplier multiplicand)
(inst move result-low result-high) (inst move result-low result-high)
(inst srax result-high 32)) (inst srax result-high 32))
((backend-featurep :sparc-v8) ((backend-featurep :sparc-v8)
;; V8 has a multiply instruction. Same restrictions as ;; V8 has a multiply instruction. This should also work for
;; :sparc-v9. This should also work for the V9, but umul and ;; the V9, but umul and the Y register is deprecated on the
;; the Y register is deprecated on the V9. ;; V9.
(inst umul result-low multiplier multiplicand) (inst umul result-low multiplier multiplicand)
(inst rdy result-high)) (inst rdy result-high))
(t (t
...@@ -762,6 +757,7 @@ ...@@ -762,6 +757,7 @@
(:results (quo :scs (unsigned-reg) :from (:argument 1)) (:results (quo :scs (unsigned-reg) :from (:argument 1))
(rem :scs (unsigned-reg) :from (:argument 0))) (rem :scs (unsigned-reg) :from (:argument 0)))
(:result-types unsigned-num unsigned-num) (:result-types unsigned-num unsigned-num)
(:guard (not (backend-featurep :sparc-v9)))
(:generator 300 (:generator 300
(move rem div-high) (move rem div-high)
(move quo div-low) (move quo div-low)
...@@ -776,6 +772,28 @@ ...@@ -776,6 +772,28 @@
(inst addx rem rem)))) (inst addx rem rem))))
(inst not quo))) (inst not quo)))
(define-vop (bignum-floor)
(:translate bignum::%floor)
(:policy :fast-safe)
(:args (div-high :scs (unsigned-reg))
(div-low :scs (unsigned-reg))
(divisor :scs (unsigned-reg) :to (:result 1)))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:temporary (:sc unsigned-reg :from (:argument 0)) dividend)
(:results (quo :scs (unsigned-reg))
(rem :scs (unsigned-reg)))
(:result-types unsigned-num unsigned-num)
(:guard (backend-featurep :sparc-v9))
(:generator 5
;; Set dividend to be div-high and div-low
(inst sllx dividend div-high 32)
(inst add dividend div-low)
;; Compute quotient
(inst udivx quo dividend divisor)
;; Compute the remainder
(inst mulx rem quo divisor)
(inst sub rem dividend rem)))
(define-vop (signify-digit) (define-vop (signify-digit)
(:translate bignum::%fixnum-digit-with-correct-sign) (:translate bignum::%fixnum-digit-with-correct-sign)
(:policy :fast-safe) (:policy :fast-safe)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment