Changeset 15578


Ignore:
Timestamp:
Jan 13, 2013, 11:52:02 AM (6 years ago)
Author:
gb
Message:

Faster bignum x fixnum multiplication for 32-bit architectures.

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

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/ARM/arm-bignum.lisp

    r15555 r15578  
    261261  (str imm1 (:@ arg_z  (:$ arm::misc-data-offset)))
    262262  (bx lr))
    263  
     263
     264(defarmlapfunction %multiply-and-add-fixnum-loop ((len 0) (x arg_x) (y arg_y) (result arg_z))
     265  (let ((rlen temp0)
     266        (idx rcontext)
     267        (carry imm2)
     268        (lo imm0)
     269        (hi imm1))
     270    (ldr rlen (:@ vsp (:$ len)))
     271    (str rcontext (:@ vsp (:$ 0)))
     272    (mov idx (:$ arm::misc-data-offset))
     273    (mov carry (:$ 0))
     274    (b @test)
     275    @loop
     276    (unbox-fixnum imm0 y)
     277    (ldr imm1 (:@ x idx))
     278    (umull lo hi imm0 imm1)
     279    (adds lo lo carry)
     280    (adc carry hi (:$ 0))
     281    (str lo (:@ result idx))
     282    (add idx idx (:$ 4))
     283    @test
     284    (subs rlen rlen '1)
     285    (bge @loop)
     286    (str carry (:@ result idx))
     287    (vpop1 rcontext)
     288    (bx lr)))
     289
     290
     291   
     292   
    264293
    265294
  • trunk/source/level-0/PPC/PPC32/ppc32-bignum.lisp

    r13067 r15578  
    299299  (stw imm1 ppc32::misc-data-offset arg_z)
    300300  (blr))
     301
     302(defppclapfunction %multiply-and-add-fixnum-loop ((len64 0) (x arg_x) (y arg_y) (result arg_z))
     303  (let ((carry imm4)
     304        (iidx imm3)
     305        (unboxed-y imm0)
     306        (i temp0)
     307        (hi imm2)
     308        (rlen temp1))
     309    (vpop rlen)
     310    (li carry 0)
     311    (li iidx ppc32::misc-data-offset)
     312    (li i 0)
     313    (b @test)
     314    @loop
     315    (unbox-fixnum unboxed-y y)
     316    (lwzx imm1 x iidx)
     317    (mulhwu hi imm1 unboxed-y)
     318    (mullw imm0 imm1 unboxed-y)
     319    (addc imm0 imm0 carry)
     320    (addze carry hi)
     321    (stwx imm0 result iidx)
     322    (la iidx 4 iidx)
     323    (la i '1 i)
     324    @test
     325    (cmpw i rlen)
     326    (blt @loop)
     327    (stwx carry result iidx)
     328    (blr)))
    301329 
    302330(defppclapfunction %floor ((q 4) (r 0) (num-high arg_x) (num-low arg_y) (denom-arg arg_z))
  • trunk/source/level-0/X86/X8632/x8632-bignum.lisp

    r15454 r15578  
    387387    (single-value-return 5)))
    388388
     389
     390(defx8632lapfunction %multiply-and-add-fixnum-loop ((len 8) (x 4) #||(ra 0)||# (y arg_y) (result arg_z))
     391  (let ((savey mm0)
     392        (savei mm1)
     393        (carry temp0)
     394        (i temp1)
     395        (rx arg_y))
     396    (unbox-fixnum y imm0)
     397    (movd (% imm0) (% savey))
     398    (mark-as-imm edx)
     399    (mark-as-imm ebx)
     400    (mov (@ x (% esp)) (% rx))
     401    (xorl (% carry) (% carry))
     402    (xorl (% i) (% i))
     403    @loop
     404    (movd (% i) (% savei))
     405    (movd (% savey) (% eax))
     406    (mull (@ x8632::misc-data-offset (% rx) (% i)))
     407    (addl (% carry) (% eax))
     408    (adcl ($ 0) (% edx))
     409    (movl (% edx) (% carry))
     410    (movd (% savei) (% i))
     411    (movl (% eax) (@ x8632::misc-data-offset (% result) (% i)))
     412    (addl ($ 4) (% i))
     413    (cmpl (% i) (@ len (% esp)))
     414    (jne @loop)
     415    (movl (% carry) (@ x8632::misc-data-offset (% result) (% i)))
     416    (mark-as-node temp1)
     417    (mark-as-node temp0)
     418    (single-value-return 4)))
     419   
     420       
    389421;; multiply x[i] by y and add to result starting at digit i
    390422(defx8632lapfunction %multiply-and-add-harder-loop-2
  • trunk/source/level-0/l0-bignum32.lisp

    r14119 r15578  
    734734               (declare (type bignum-type bignum)
    735735                        (type bignum-index bignum-len))
    736                (with-small-bignum-buffers ((carry-digit)
    737                                            (result-digit))
    738                  (dotimes (i bignum-len (%set-digit result bignum-len carry-digit))
    739                    (%set-digit result i
    740                                (%multiply-and-add result-digit carry-digit bignum i fixnum))))
     736               (%multiply-and-add-fixnum-loop bignum-len bignum fixnum result)
    741737               (when negate-res
    742738                 (negate-bignum-in-place result))
Note: See TracChangeset for help on using the changeset viewer.