qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v2 04/19] host-utils: add 128-bit quotient support to divu128


From: Luis Fernando Fujita Pires
Subject: RE: [PATCH v2 04/19] host-utils: add 128-bit quotient support to divu128/divs128
Date: Thu, 2 Sep 2021 21:07:51 +0000

From: Richard Henderson <richard.henderson@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>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]