Re: udiv_qr_3by2 vs divappr

2018-04-29 Thread Niels Möller
paul zimmermann writes: > you might be interested by Algorithms DivApprox1 and DivApprox2 > from https://hal.inria.fr/hal-01502326. Thanks. I'm looking for something in between, single limb quotient based on double limb inputs. Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred

Re: mini-gmp and mpq

2018-04-29 Thread Marco Bodrato
Ciao, Il Dom, 29 Aprile 2018 8:24 pm, Bradley Lucier ha scritto: > On 04/28/2018 04:16 AM, Marco Bodrato wrote: >> Finally, the mini-mpq code is in the development library. >> https://gmplib.org/repo/gmp/file/tip/mini-gmp > I haven't tested the code, but I have examined it. Thank you! > I would

Re: mini-gmp and mpq

2018-04-29 Thread Bradley Lucier
On 04/28/2018 04:16 AM, Marco Bodrato wrote: Finally, the mini-mpq code is in the development library. https://gmplib.org/repo/gmp/file/tip/mini-gmp I'll be happy if you want to test it or write any comment about it. I haven't tested the code, but I have examined it. I would suggest testing

Re: udiv_qr_3by2 vs divappr

2018-04-29 Thread paul zimmermann
Niels, > static inline mp_limb_t > divappr_2 (mp_limb_t n2, mp_limb_t n1, >mp_limb_t d1, mp_limb_t d0, mp_limb_t dinv) > This needs more analysis. [...] you might be interested by Algorithms DivApprox1 and DivApprox2 from https://hal.inria.fr/hal-01502326. Best regards, Paul _

Re: udiv_qr_3by2 vs divappr

2018-04-29 Thread Marco Bodrato
Ciao Niels, Il Dom, 29 Aprile 2018 10:52 am, Niels Möller ha scritto: > #if 0 > q1 += (r1 >= d1); > #else > /* FIXME: Take care of this case more efficiently, > need analysis of the case n1 == d1. */ > if (r1 >= d1 && q1 != GMP_NUMB_MAX) > q1++; > #endif On some CPU saturating arit

Re: udiv_qr_3by2 vs divappr

2018-04-29 Thread Torbjörn Granlund
ni...@lysator.liu.se (Niels Möller) writes: The first failure was for an input with n2 == d1, n1 == d1-1. static void test_divappr_2(void) { mp_limb_t q = divappr_2(0x8001ULL, 0xbfffULL, 0x8001ULL, 0xc000ULL,

Re: udiv_qr_3by2 vs divappr

2018-04-29 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes: > ni...@lysator.liu.se (Niels Möller) writes: > >> If we can get away with that, it gets a lot >> simpler, >> >> if (r >= q_0) /* Needs to be branch free */ >> { >> q--; >> r += d_1; >> } >> return q + (r >= d_1); > > I've given it a try.