bug in longlong.h for aarch64 sub_ddmmss

Paul Zimmermann Paul.Zimmermann at inria.fr
Wed Jun 17 13:33:02 UTC 2020


       Dear Niels,

> Sorry for being unclear, sub_ddmmss has six arguments, and the case I
> wanted to single out was
> 
>    sub_ddmmss(rh, rl, ah, al, bh, /*compile time constant*/0)
>  
> > in MPFR we have 15 places where we call sub_ddmmss, among which 8 have bl=0:
> 
> Those seem to have al == 0 (in above notation), which is a different
> case.

sorry I mixed al and bl. After looking at the MPFR code that hit the bug:

    if (MPFR_UNLIKELY(_r < MPFR_LIMB_HIGHBIT))                  \
      _r = MPFR_LIMB_HIGHBIT;                                   \
    umul_ppmm (_h, _l, _r, _r);                                 \
    sub_ddmmss (_h, _l, _u, 0, _h, _l);                         \

I guess the compiler did optimize separately the _r < MPFR_LIMB_HIGHBIT
case, in which case it did deduce _r = MPFR_LIMB_HIGHBIT, thus _l=0
after umul_ppmm, and the special code for bl=0 was used in longlong.h.

Paul


More information about the gmp-bugs mailing list