Changeset 5584


Ignore:
Timestamp:
Dec 4, 2006, 8:24:26 AM (18 years ago)
Author:
Gary Byers
Message:

BIGNUM-SHIFT-RIGHT-1: handle shift by 0 bits.
BIGNUM-BIGNUM-GCD (whatever it's called): don't bother to shift by 0 bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-0/l0-bignum64.lisp

    r5431 r5584  
    18501850             (v-trailing-0-digits (ash v-trailing-0-bits -5)))
    18511851        (declare (fixnum u-trailing-0-bits v-trailing-0-bits))
    1852         (unless (zerop u-trailing-0-digits)
     1852        (unless (zerop u-trailing-0-bits)
    18531853          (bignum-shift-right-loop-1
    18541854           (logand u-trailing-0-bits 31)
     
    19041904                         u-trailing-0-digits
    19051905                         (ash u-trailing-0-bits -5))
    1906                    (%init-misc 0 u2)
    1907                    (bignum-shift-right-loop-1
    1908                     (logand u-trailing-0-bits 31)
    1909                     u2
    1910                     u
    1911                     (the fixnum (1- (the fixnum (- u-len
    1912                                                    u-trailing-0-digits))))
    1913                     u-trailing-0-digits)
    1914                    (rotatef u u2)
    1915                    (%mostly-normalize-bignum-macro u)
    1916                    (setq u-len (%bignum-length u)))
     1906                   (unless (zerop u-trailing-0-bits)
     1907                     (%init-misc 0 u2)
     1908                     (bignum-shift-right-loop-1
     1909                      (logand u-trailing-0-bits 31)
     1910                      u2
     1911                      u
     1912                      (the fixnum (1- (the fixnum (- u-len
     1913                                                     u-trailing-0-digits))))
     1914                      u-trailing-0-digits)
     1915                     (rotatef u u2)
     1916                     (%mostly-normalize-bignum-macro u)
     1917                     (setq u-len (%bignum-length u))))
    19171918                  (t                    ; (> v u)
    19181919                   (bignum-subtract-loop v v-len u u-len v)
     
    19231924                         v-trailing-0-digits
    19241925                         (ash v-trailing-0-bits -5))
    1925                    (%init-misc 0 v2)
    1926                    (bignum-shift-right-loop-1
    1927                     (logand v-trailing-0-bits 31)
    1928                     v2
    1929                     v
    1930                     (the fixnum (1- (the fixnum (- v-len v-trailing-0-digits))))
    1931                     v-trailing-0-digits)
    1932                    (rotatef v v2)
    1933                    (%mostly-normalize-bignum-macro v)
    1934                    (setq v-len (%bignum-length v)))))))))))
     1926                   (unless (zerop v-trailing-0-bits)
     1927                     (%init-misc 0 v2)
     1928                     (bignum-shift-right-loop-1
     1929                      (logand v-trailing-0-bits 31)
     1930                      v2
     1931                      v
     1932                      (the fixnum (1- (the fixnum (- v-len v-trailing-0-digits))))
     1933                      v-trailing-0-digits)
     1934                     (rotatef v v2)
     1935                     (%mostly-normalize-bignum-macro v)
     1936                     (setq v-len (%bignum-length v))))))))))))
    19351937
    19361938(defun %bignum-bignum-gcd (u v)
     
    19391941
    19401942
    1941 ;;; nbits can't be zero here.
    19421943(defun bignum-shift-right-loop-1 (nbits result source len idx)
    19431944  (declare (type bignum-type result source)
    19441945           (type (mod 32) nbits)
    19451946           (type bignum-index idx len))
    1946   (let* ((rbits (logand 31 (the (mod 32) (- 32 nbits)))))
    1947     (declare (type (mod 32) rbits))
     1947  (let* ((rbits (- 32 nbits)))
     1948    (declare (type (mod 33) rbits))
    19481949    (dotimes (j len)
    19491950      (let* ((x (bignum-ref source idx)))
Note: See TracChangeset for help on using the changeset viewer.