Changeset 12839


Ignore:
Timestamp:
Sep 16, 2009, 2:14:21 AM (10 years ago)
Author:
rme
Message:

Try to multiply bignums 64-bits at a time on x8664.

Location:
trunk/source/level-0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/X86/X8664/x8664-bignum.lisp

    r11111 r12839  
    7171    (single-value-return 4)))
    7272
     73(defx86lapfunction %multiply-and-add-loop64
     74    ((xs 16) (ys 8) #|(ra 0)|# (r arg_x) (i arg_y) (ylen arg_z))
     75  (let ((y temp2)
     76        (j temp0)
     77        (c imm2))
     78    (movq (@ xs (% rsp)) (% temp0))
     79    (movq (@ x8664::misc-data-offset (% temp0) (% i)) (% mm0)) ;x[i]
     80    (movq (@ ys (% rsp)) (% y))
     81    (xorl (%l j) (%l j))
     82    (xorl (%l c) (%l c))
     83    @loop
     84    ;; It's a pity to have to reload this every time, but there's no
     85    ;; imm3.  (Give him 16 registers, and he still complains...)
     86    (movd (% mm0) (% rax))
     87    (mulq (@ x8664::misc-data-offset (% y) (% j))) ;128-bit x * y[j] in rdx:rax
     88    (addq (@ x8664::misc-data-offset (% r) (% i)) (% rax)) ;add in r[i]
     89    (adcq ($ 0) (% rdx))
     90    ;; add in carry digit
     91    (addq (% c) (% rax))
     92    (movl ($ 0) (%l c))
     93    (adcq (% rdx) (% c))                                   ;new carry digit
     94    (movq (% rax) (@ x8664::misc-data-offset (% r) (% i))) ;update r[i]
     95    (addq ($ '1) (% i))
     96    (addq ($ '1) (% j))
     97    (subq ($ '1) (% ylen))
     98    (ja @loop)
     99    (movq (% c) (@ x8664::misc-data-offset (% r) (% i)))
     100    (single-value-return 4)))
    73101
    74102;;; Multiply the (32-bit) digits X and Y, producing a 64-bit result.
  • trunk/source/level-0/l0-bignum64.lisp

    r11958 r12839  
    804804                    (len-b (%bignum-length b))
    805805                    (len-res (+ len-a len-b))
    806                     (res (%allocate-bignum len-res)) )
     806                    (res (%allocate-bignum len-res)))
    807807               (declare (bignum-index len-a len-b len-res))
    808808               (dotimes (i len-a)
    809809                 (declare (type bignum-index i))
    810810                 (%multiply-and-add-loop a b res i len-b))
     811               res))
     812           (multiply-unsigned-bignums64 (a b)
     813             (let* ((len-a (ceiling (%bignum-length a) 2))
     814                    (len-b (ceiling (%bignum-length b) 2))
     815                    (len-res (+ len-a len-b))
     816                    (res (%allocate-bignum (+ len-res len-res))))
     817               (declare (bignum-index len-a len-b len-res))
     818               (dotimes (i len-a)
     819                 (declare (type bignum-index i))
     820                 (%multiply-and-add-loop64 a b res i len-b))
    811821               res)))
    812       (let* ((res (with-negated-bignum-buffers a b multiply-unsigned-bignums)))
     822      (let* ((res (with-negated-bignum-buffers a b
     823                                               #-x86-target
     824                                               multiply-unsigned-bignums
     825                                               #+x86-target
     826                                               multiply-unsigned-bignums64)))
    813827        (if signs-differ (negate-bignum-in-place res))
    814828        (%normalize-bignum-macro res)))))
Note: See TracChangeset for help on using the changeset viewer.