[Gmp-commit] /var/hg/gmp: mini-gmp/mini-gmp.c (mpn_invert_3by2): Use xor inst...
mercurial at gmplib.org
mercurial at gmplib.org
Wed Nov 20 15:45:06 UTC 2019
details: /var/hg/gmp/rev/3cc19de86f76
changeset: 17978:3cc19de86f76
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Nov 20 16:44:46 2019 +0100
description:
mini-gmp/mini-gmp.c (mpn_invert_3by2): Use xor instead of negation, it does not depend on sizes...
diffstat:
mini-gmp/mini-gmp.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diffs (22 lines):
diff -r 28c6c7492b01 -r 3cc19de86f76 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Tue Nov 19 16:25:20 2019 +0100
+++ b/mini-gmp/mini-gmp.c Wed Nov 20 16:44:46 2019 +0100
@@ -789,7 +789,8 @@
if (GMP_ULONG_BITS >= GMP_LIMB_BITS * 2)
{
/* Set m to the 2/1 inverse of u1. */
- m = ~((unsigned long) u1 << GMP_LIMB_BITS_MUL_3 / 3) / u1;
+ m = (((unsigned long) (u1 ^ GMP_LIMB_MAX) << GMP_LIMB_BITS_MUL_3 / 3)
+ | GMP_LIMB_MAX ) / u1;
r = ~(m * u1);
}
else
@@ -805,7 +806,7 @@
/* Approximation of the high half of quotient. Differs from the 2/1
inverse of the half limb uh, since we have already subtracted
u0. */
- qh = ~u1 / uh;
+ qh = (u1 ^ GMP_LIMB_MAX) / uh;
/* Adjust to get a half-limb 3/2 inverse, i.e., we want
More information about the gmp-commit
mailing list