div_qr_1 interface
Niels Möller
nisse at lysator.liu.se
Fri Oct 18 17:41:26 CEST 2013
nisse at lysator.liu.se (Niels Möller) writes:
(about using a small struct as return value)
> If the caller is going to store the returned value directly in memory
> anyway, there's little difference. And if the caller is going to operate
> on the return value, and needs it in a register, I think struct return
> should be epsilon more efficient.
Things are different on 32-bit x86; there the struct seems to be
returned via a pointer passed by the caller (on the stack, like all
arguments). So the crude measure of the number of instructions for the
example divrem function grows from 13 to 18 when using a struct return
value.
How much do we care about 32-bit x86 these days? What other ABIs out
there can't return a small (two word-sized elements) struct in
registers?
In principle, since these are internal functions, I guess one could use
struct {mp_limb_t r, mp_limb_t qh } mpn_div_qr_1n_pi1 (...)
on some systems and
mp_limb_t mpn_div_qr_1n_pi1 (..., mp_limb_t *qhp)
on others, depending on which style is most efficient. But that seems
messy.
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