udiv_qrnnd_preinv and udiv_rnnd_preinv macros

Torbjorn Granlund tg at gmplib.org
Mon Feb 28 15:36:54 CET 2011


nisse at lysator.liu.se (Niels Möller) writes:

  > I think it is easy enough to pass a 0 there.
  
  Do you want me to convert uses of udiv_rnd_preinv (r, nh, d, di) to
  
    udiv_rnnd_preinv (r, nh, CNST_LIMB(0), d, di)
  
  and delete udiv_rnd_preinv? And would it work without the somewhat ugly
  CNST_LIMB?
  
Please convert, now as it should give the same code.

You can tell better than I if CNST_LIMB is needed.  ~0 might not b the
same thing as ~CNST_LIMB(0), since the former is an int, not a limb.
(Not even ~0ul is safe, since mp_limb_t might b a long long.)

So, remove CNST_LIMB if is uses safely.  Consider using a cast inside
the function if needed.

  With a compiler supporting __builtin_constant_p, it ought to generate
  the same code, but without __builtin_constant_p, using udiv_rnnd_preinv
  with nl == 0 is going to be slightly less efficient.
  
One cannot please them all.  :-)

-- 
Torbjörn


More information about the gmp-devel mailing list