diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2020-03-11 21:03:12 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2020-03-11 21:03:12 +0100 |
commit | 49b08be97a113148123a7f81231092eae30a6a22 (patch) | |
tree | a98b96c6daa45fb8651ebae12ec6aad7354b6f84 /mpn/generic | |
parent | 5a76cbf4393e241d1b6484d00c4d5e8ccc104c13 (diff) | |
download | gmp-49b08be97a113148123a7f81231092eae30a6a22.tar.gz |
mpn/generic/mul_fft.c (mpn_fft_mul_modF_K): Fully handle carry propagation in basecase multiplication
Diffstat (limited to 'mpn/generic')
-rw-r--r-- | mpn/generic/mul_fft.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mpn/generic/mul_fft.c b/mpn/generic/mul_fft.c index df8ee63a5..a33228ad7 100644 --- a/mpn/generic/mul_fft.c +++ b/mpn/generic/mul_fft.c @@ -553,9 +553,12 @@ mpn_fft_mul_modF_K (mp_ptr *ap, mp_ptr *bp, mp_size_t n, mp_size_t K) cc += mpn_add_n (tpn, tpn, a, n) + a[n]; if (cc != 0) { - /* FIXME: use MPN_INCR_U here, since carry is not expected. */ cc = mpn_add_1 (tp, tp, n2, cc); - ASSERT (cc == 0); + /* If mpn_add_1 give a carry (cc != 0), + the result (tp) is at most GMP_NUMB_MAX - 1, + so the following addition can't overflow. + */ + tp[0] += cc; } a[n] = mpn_sub_n (a, tp, tpn, n) && mpn_add_1 (a, a, n, CNST_LIMB(1)); } |