[PPL-devel] mpz_addmul_ui with ui = 1

Torbjorn Granlund tg at swox.com
Wed Jan 28 16:10:42 CET 2009


Roberto Bagnara <bagnara at cs.unipr.it> writes:

  We thought (but we are not sure) that this is indeed
  a feature, and not a limitation: since only the client
  code can know about the frequence of special cases,
  let the client code take the decision.  The alternative
  would be that GMP does a lot of checks that are possibly
  useless, perhaps duplicating work that has already been
  done by the client code.
  
It is indeed very hard for GMP to know, and mpz_addmul_ui could perhaps
also check for the arguments 16, 1023, and whatnot.  Countless special
values could give speedup when actually used, but testing for such
values would slow most GMP usages down.  And probably introduce
hard-to-test-for bugs.
  
Adding test for special cases to application code is also not a perfect
solution, since what values to test for varies from GMP version to GMP
version and from hardware to hardware.

Vincent Lefevre <vincent at vinc17.org> writes:

  Is GMP's policy documented somewhere? If not, I think this should
  be documented, so that the user does not have to do useless checks
  if they are done by GMP.

I have meant to write a "GMP cookbook" with advice like this.

-- 
Torbjörn




More information about the PPL-devel mailing list