From: Richard Henderson <richard.hender...@linaro.org> > Hmm. I'll note that we have a better divmod primitive in tree, but we aren't > using it > here: udiv_qrnnd in include/fpu/softfloat-macros.h.
Good to know! I'll change to a (much simpler) implementation using udiv_qrnnd. Any pointers on what would be a good place to put udiv_qrnnd, so it can be used by softloat.c and host-utils.c? Would host-utils.h be ok? > Given that none of the existing uses require the high part, should we be > creating > a new interface? The bug you highlight wrt truncation could be fixed > separately. Although it does fix the bug, the motivation for the new interface is not really that bug. I wanted a 128-bit division that could return quotients larger than 64-bit, so I could use it in decNumberFrom[U]Int128, introduced in the next commit. > > -void divs128(int64_t *plow, int64_t *phigh, int64_t divisor) > > +void divs128(uint64_t *plow, int64_t *phigh, int64_t *prem, int64_t > > +divisor) > > { > > - int sgn_dvdnd = *phigh < 0; > > - int sgn_divsr = divisor < 0; > > + int neg_quotient = 0, neg_remainder = 0; > > You might as well use bool. Sure, will do. -- Luis Pires Instituto de Pesquisas ELDORADO Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>