divexact_1 and bdiv_q_1

Torbjorn Granlund tg at gmplib.org
Wed Jan 19 18:12:06 CET 2011

bodrato at mail.dm.unipi.it writes:

  I spent some time trying to understand the difference between the two
  functions: mpn_divexact_1 and mpn_bdiv_q_1 .
  As far as I can see they should compute the same mpn, but the first one
  does not return anything, while the second one returns an mp_limb_t. What
  is that returned value supposed to be?

It is a value which could be used for computing the function piece-wise,
I think.  I am not sure it is useful, perhaps we should remove it.
Let's hear if Niels has something clever to say about this...

  I took the code from mpn/x86/dive_1.asm and I adapted it to obtain
  mpn/x86/bdiv_q_1.asm, then I committed it[*] to have it tested. It worked.
  But I did not touch in any way the code to return a coherent value... I
  simply assume that the returned value is not used anywhere in the code.
Hmm...  :-|

  [*]The presence of a generic "mpn/x86/bdiv_q_1.asm" file does slow down
  general performance of GMP on x86, because it gets used instead of the
  various mpn/x86/*/dive_1.asm optimised for specific processors... I will
  correct this...
Didn't he presence is the even more gneric code in mpn/generic cause
such slowdowns?


More information about the gmp-devel mailing list