udiv_qr_3by2 vs divappr

Marco Bodrato bodrato at mail.dm.unipi.it
Sun Apr 29 14:05:13 UTC 2018


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 arithmetic is available, I think.
Anyway, subtracting the possible carry should do the trick.

{
  mp_limb_t cc = r1 >= d1;
  q1 += cc;
#if 1
  q1 -= cc > q1;
#endif
}


Ĝis,
m

-- 
http://bodrato.it/



More information about the gmp-devel mailing list