develooper Front page | perl.perl5.porters | Postings from November 2000

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 11, 2000 16:34
Subject:
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
20001112003435.A80780@plum.flirble.org
On Thu, Nov 09, 2000 at 11:46:58AM -0600, Jarkko Hietaniemi wrote:
> > Was this what you benchmarked, or did you do bit shuffling?
> 
> I did something similar for all the four (IVIV, IVUV, UVIV, UVUV)
> cases, by checking against the arguments and {IV_{MIN,MAX,UV_MAX}
> (I did both add and substract, and a half-hearted attempt with multiply).

Ah. I felt that UVIV and IVUV was not going to be simple, so assumed that
something like

if (IVIV) {
  add IVs
  return result unless overflow;
} elsif (UVUV) {
  add UVs
  return result unless overflow;
}

convert to NVs
return add NVs

might be faster than just doing everything as NVs. (I guess it depends on
relative speed of integer and FP on your CPU)

However, it might be useful to go to the effort on IVUV and UVIV as it
(with UVUV an IVIV) would make 64 bit arithmetic more sane on platforms
where NV can't preserve all bits in IV. (I think.)

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About