Changeset 12839
- Timestamp:
- 09/15/09 21:14:21 (3 years ago)
- Location:
- trunk/source/level-0
- Files:
-
- 2 modified
-
X86/X8664/x8664-bignum.lisp (modified) (1 diff)
-
l0-bignum64.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/level-0/X86/X8664/x8664-bignum.lisp
r11111 r12839 71 71 (single-value-return 4))) 72 72 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))) 73 101 74 102 ;;; Multiply the (32-bit) digits X and Y, producing a 64-bit result. -
trunk/source/level-0/l0-bignum64.lisp
r11958 r12839 801 801 (len-b (%bignum-length b)) 802 802 (len-res (+ len-a len-b)) 803 (res (%allocate-bignum len-res)) )803 (res (%allocate-bignum len-res))) 804 804 (declare (bignum-index len-a len-b len-res)) 805 805 (dotimes (i len-a) 806 806 (declare (type bignum-index i)) 807 807 (%multiply-and-add-loop a b res i len-b)) 808 res)) 809 (multiply-unsigned-bignums64 (a b) 810 (let* ((len-a (ceiling (%bignum-length a) 2)) 811 (len-b (ceiling (%bignum-length b) 2)) 812 (len-res (+ len-a len-b)) 813 (res (%allocate-bignum (+ len-res len-res)))) 814 (declare (bignum-index len-a len-b len-res)) 815 (dotimes (i len-a) 816 (declare (type bignum-index i)) 817 (%multiply-and-add-loop64 a b res i len-b)) 808 818 res))) 809 (let* ((res (with-negated-bignum-buffers a b multiply-unsigned-bignums))) 819 (let* ((res (with-negated-bignum-buffers a b 820 #-x86-target 821 multiply-unsigned-bignums 822 #+x86-target 823 multiply-unsigned-bignums64))) 810 824 (if signs-differ (negate-bignum-in-place res)) 811 825 (%normalize-bignum-macro res)))))
