Re: arithmetic issues William D Clinger (18 Jan 2006 05:54 UTC)
Re: arithmetic issues Alan Watson (18 Jan 2006 17:08 UTC)
Re: arithmetic issues Michael Sperber (18 Jan 2006 20:43 UTC)
Re: arithmetic issues Alan Watson (18 Jan 2006 22:15 UTC)
Re: arithmetic issues bear (18 Jan 2006 18:21 UTC)
Re: straw-man [was Re: arithmetic issues] Aubrey Jaffer (20 Jan 2006 16:13 UTC)
Re: straw-man [was Re: arithmetic issues] Alan Watson (20 Jan 2006 17:43 UTC)
Re: arithmetic issues Alan Watson (20 Jan 2006 17:48 UTC)

Re: straw-man [was Re: arithmetic issues] Alan Watson 20 Jan 2006 17:43 UTC

Aubrey Jaffer wrote:
>   Moreover, the R5RS generic arithmetic is difficult to implement as
>   efficiently as purely fixnum or purely flonum arithmetic.
>
> "Interpreter-branch" disproves this asserertion as far as interpreters
> with immediate fixnums and boxed numbers are concerned.

No it does not. It shows that one can make generic arithmetic for ONE
representation as fast as type-specific arithmetic.

For example, suppose we want to optimize for fixnums first and flonums
second. We write the generic arithmetic code as follows and arrange to
predicting that the conditions are true:

   if (all arguments are fixnums)
     deal with fixnums
   else if (all arguments are flonums)
     deal with flonums
   else
     deal with the general case

When you use this code with fixnums, the first branch is correctly
predicted and there is very little cost. However, when you use this code
with flonums, the first branch is incorrectly predicted and there can be
a significant cost.

Regards,

Alan
--
Dr Alan Watson
Centro de Radioastronomía y Astrofísica
Universidad Astronómico Nacional de México