[Gmp-commit] /var/hg/gmp: mpn/generic/invertappr.c: remove a risky (and not n...
mercurial at gmplib.org
mercurial at gmplib.org
Sun May 10 06:49:56 UTC 2015
details: /var/hg/gmp/rev/c35b6149498b
changeset: 16617:c35b6149498b
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sun May 10 08:44:04 2015 +0200
description:
mpn/generic/invertappr.c: remove a risky (and not needed) branch
diffstat:
mpn/generic/invertappr.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diffs (47 lines):
diff -r e1c1784afed3 -r c35b6149498b mpn/generic/invertappr.c
--- a/mpn/generic/invertappr.c Sat May 09 09:59:38 2015 +0200
+++ b/mpn/generic/invertappr.c Sun May 10 08:44:04 2015 +0200
@@ -203,7 +203,7 @@
/* Maximum scratch needed by this branch <= 2*n + 4 - USE_MUL_N */
rp = xp + n + 1 - USE_MUL_N; /* n + 3 limbs */
while (1) {
- int method;
+ mp_limb_t method;
n = *--sizp;
/*
@@ -218,7 +218,7 @@
/* FIXME: We do only need {xp,n+1}*/
mpn_mul (xp, dp - n, n, ip - rn, rn);
mpn_add_n (xp + rn, xp + rn, dp - n, n - rn + 1);
- method = 1; /* Remember we truncated, Mod B^(n+1) */
+ method = CNST_LIMB(1); /* Remember we truncated, Mod B^(n+1) */
/* We computed (truncated) {xp,n+1} <- 1.{ip,rn} * 0.{dp,n} */
} else { /* Use B^mn-1 wraparound */
mpn_mulmod_bnm1 (xp, mn, dp - n, n, ip - rn, rn, tp);
@@ -232,7 +232,7 @@
xp[mn] = CNST_LIMB (1); /* set a limit for DECR_U */
MPN_DECR_U (xp + rn + n - mn, 2 * mn + 1 - rn - n, CNST_LIMB (1) - cy);
MPN_DECR_U (xp, mn, CNST_LIMB (1) - xp[mn]); /* if DECR_U eroded xp[mn] */
- method = 0; /* Remember we are working Mod B^mn-1 */
+ method = CNST_LIMB(0); /* Remember we are working Mod B^mn-1 */
}
if (xp[n] < CNST_LIMB (2)) { /* "positive" residue class */
@@ -259,6 +259,7 @@
#endif
MPN_DECR_U(ip - rn, rn, cy); /* 1 <= cy <= 3 here. */
} else { /* "negative" residue class */
+ MPN_DECR_U(xp, n + 1, method);
#if USE_MUL_N
if (xp[n] != GMP_NUMB_MAX) {
MPN_INCR_U(ip - rn, rn, CNST_LIMB (1));
@@ -266,8 +267,6 @@
}
#endif
mpn_com (xp + n - rn, xp + n - rn, rn + 1 - USE_MUL_N);
- if (UNLIKELY (method))
- MPN_INCR_U(xp + n - rn, rn + 1 - USE_MUL_N, mpn_zero_p (xp, n - rn));
ASSERT (USE_MUL_N || xp[n] <= CNST_LIMB (1));
}
More information about the gmp-commit
mailing list