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

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous | Thread Next
Nicholas Clark
November 11, 2000 16:34
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About