Changeset 9932


Ignore:
Timestamp:
Jul 10, 2008, 2:00:38 AM (11 years ago)
Author:
gb
Message:

One FAST-MOD implementation; conditionalize for word size inside it.

Add a FAST-MOD-3 for PPC, based on gz's implementation. (Integer
divide on PPC is slow as a dog, multiply's not that bad.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/PPC/ppc-hash.lisp

    r1957 r9932  
    2828;;; This should stay in LAP so that it's fast
    2929;;; Equivalent to cl:mod when both args are positive fixnums
    30 #+ppc32-target
    3130(defppclapfunction fast-mod ((number arg_y) (divisor arg_z))
    32   (divwu imm0 number divisor)
    33   (mullw arg_z imm0 divisor)
     31  #+ppc32-target
     32  (progn
     33    (divwu imm0 number divisor)
     34    (mullw arg_z imm0 divisor))
     35  #+ppc64-target
     36  (progn
     37    (divdu imm0 number divisor)
     38    (mulld arg_z imm0 divisor))
    3439  (subf arg_z arg_z number)
    3540  (blr))
    3641
    37 #+ppc64-target
    38 (defppclapfunction fast-mod ((number arg_y) (divisor arg_z))
    39   (divdu imm0 number divisor)
    40   (mulld arg_z imm0 divisor)
    41   (subf arg_z arg_z number)
     42
     43(defppclapfunction fast-mod-3 ((number arg_x) (divisor arg_y) (recip arg_z))
     44  (unbox-fixnum imm0 number)
     45  #+ppc32-target
     46  (progn
     47    (mulhw imm1 imm0 recip)
     48    (mullw imm0 imm1 divisor))
     49  #+ppc64-target
     50  (progn
     51    (mulhd imm1 imm0 recip)
     52    (mulld imm0 imm1 divisor))
     53  (sub number number imm0)
     54  (sub number number divisor)
     55  (srari imm0 number (1- target::nbits-in-word))
     56  (and divisor divisor imm0)
     57  (add arg_z number divisor)
    4258  (blr))
    4359
Note: See TracChangeset for help on using the changeset viewer.