dead code in div_q.c?
paul zimmermann
Paul.Zimmermann at inria.fr
Fri Apr 20 13:36:47 UTC 2018
Hi,
together with Raphaël Rieu-Hleft (in cc), we believe we have found some dead code in
mpn/generic/div_q.c around lines 173-182:
else if (UNLIKELY (qh != 0))
{
/* This happens only when the quotient is close to B^n and
mpn_*_divappr_q returned B^n. */
mp_size_t i, n;
n = new_nn - dn;
for (i = 0; i < n; i++)
qp[i] = GMP_NUMB_MAX;
qh = 0; /* currently ignored */
}
Indeed, in the case cy <> 0, since cnt < GMP_NUMB_BITS, the most significant limb
new_np[nn] of the dividend has at least one 0 leading bit, and thus is smaller
than new_dp[dn-1] (which is normalized). Therefore qh is always 0 (no approximate
division is performed here).
Raphaël and Paul
More information about the gmp-devel
mailing list