gmp_pi1_t

Niels Möller nisse at lysator.liu.se
Sun Dec 13 08:53:15 CET 2009


Torbjorn Granlund <tg at gmplib.org> writes:

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

>   If I do that, should I eliminate the gmp_pi1_t type as well, and pass a
>   single limb (the remaining inv32 member) instead of a gmp_pi1_t *?
>   
> I supoose there is no harm with keeping gmp_pi1_t, since it will be
> easier to modify it.  Or do you see some harm?

Estetic considerations aside, the only obvious drawback is that the
function call overhead will be a cycle or two less for passing the limb
directly in a register, than for storing it in memory and passing a
poiter to it. But I don't know if that difference is going to be
measurable.

(In recent years I've been under some influence of "extreme programming"
thinking, so I'm suspicious to adding abstractings that do nothing
useful today but are supposed to be useful in some future version).

> I expect more gmp_piX_t structures in the future, BTW.

Anyway, I think structures like these should be const declared in the
prototypes, for both clarity and performance. So that code like

  gmp_pi1_t inv;

  ... inv->inv32 ...;
  foo (..., &inv);
  ... inv->inv32 ...;

can keep the value of inv32 in a register over the function call. Are
gcc or other compilers clever enough to do that optimization?

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list