mpq_cmp_z

Marco Bodrato bodrato at mail.dm.unipi.it
Tue Aug 25 06:33:21 UTC 2015


Ciao,

On Mon, August 24, 2015 6:24 pm, Torbjörn Granlund wrote:
> An alternative to messing with void * would be an interface like this:

> static int
> cmp_helper (mpq_srcptr op1, mpz_srcptr op2num, mpz_srcptr op2den)

I tested this one:
cmp_helper (mpq_srcptr o1, mpz_srcptr o2n, mpz_srcptr o2d, mp_size_t o2s)
obtaining a "slow" alternative. I'll try your proposal.

> Then have mpq_cmp simply split its op2 arg before dropping into the
> helper function, and mpz_cmp_z pass its 2nd arg as op2num, and then ether
> pass a global static op2den which is compile-time initialised to 1, or
> perhaps pass NULL.

> That'd allow tail calls for most machines, and should not need many
> pesky branches.

If you pass NULL, you'll not avoid any pesky branch :-D

If you pass a static "1", and do not branch, you will end up allocating
space and loosing time to multiply NUM(op1) by one...

One of the four branches I originally wrote can be avoided by better
coding...

If we want to share code and we don't want to penalise the _z flavour too
much, some branches are needed.

Regards,
m

-- 
http://bodrato.it/papers/



More information about the gmp-devel mailing list