"Marco Bodrato" <bodr...@mail.dm.unipi.it> writes:

> 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...

Depends on whether or not we want to recognize the integer case also for
mpq_cmp. I think it would make some sense to do that. And if so, passing
a static "1" for mpq_cmp_z seems right, because then no additional
branch is needed for that case.

As I understand tail call machinery, to really get a tail call, the
calling functions (mpq_cmp and mpq_cmp_z) mustn't pass any
stack-allocated pointers to mpq_cmp_helper.

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

Is there a lot shared logic? For the integer case, we compare A/B to C,
by first checking signs and sizes, and for close sizes, compare B*C to A
(or ideally, only one or two of the high limbs of the product).

While for the non-integer case, A/B vs C/D, it seems to me that sign
logic would be the same, but size comparisons are different (limb size
of A known exactly, while limb size of A*D has one unit of uncertainty).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to