All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Luis Fernando Fujita Pires <luis.pires@eldorado.org.br>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>
Cc: "groug@kaod.org" <groug@kaod.org>,
	"david@gibson.dropbear.id.au" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2 04/19] host-utils: add 128-bit quotient support to divu128/divs128
Date: Fri, 3 Sep 2021 23:09:22 +0200	[thread overview]
Message-ID: <3bcc33e9-7076-e3ba-df86-1950cd1caa36@linaro.org> (raw)
In-Reply-To: <CP2PR80MB36682CDF56098C1E9DE99437DACE9@CP2PR80MB3668.lamprd80.prod.outlook.com>

On 9/2/21 11:07 PM, Luis Fernando Fujita Pires wrote:
> 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?

Yeah, that should be fine.

Note that udiv_qrnnd requires that the divisor be normalization, i.e. the msb of the 
denominator must be set.  So:

     int sh = clz64(den);
     uint64_t q, r;

     q = udiv_qrnnd(&r, num_hi, num_lo, den << sh);
     q <<= sh;
     r >>= sh;

IIRC.  You'll probably want to have a look at gmp source, from which this comes for best 
practice in implementing a larger division.


r~


  reply	other threads:[~2021-09-03 21:13 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-31 16:39 [PATCH v2 00/19] target/ppc: DFP instructions using decodetree Luis Pires
2021-08-31 16:39 ` [PATCH v2 01/19] host-utils: Fix overflow detection in divu128() Luis Pires
2021-08-31 17:08   ` Richard Henderson
2021-08-31 16:39 ` [PATCH v2 02/19] host-utils: move abs64() to host-utils as uabs64() Luis Pires
2021-08-31 17:11   ` Richard Henderson
2021-08-31 18:20   ` Eduardo Habkost
2021-08-31 16:39 ` [PATCH v2 03/19] host-utils: move checks out of divu128/divs128 Luis Pires
2021-08-31 17:21   ` Richard Henderson
2021-09-02 21:07     ` Luis Fernando Fujita Pires
2021-08-31 16:39 ` [PATCH v2 04/19] host-utils: add 128-bit quotient support to divu128/divs128 Luis Pires
2021-08-31 17:59   ` Richard Henderson
2021-09-02 21:07     ` Luis Fernando Fujita Pires
2021-09-03 21:09       ` Richard Henderson [this message]
2021-08-31 16:39 ` [PATCH v2 05/19] host-utils: add unit tests for divu128/divs128 Luis Pires
2021-08-31 16:39 ` [PATCH v2 06/19] libdecnumber: introduce decNumberFrom[U]Int128 Luis Pires
2021-08-31 18:10   ` Richard Henderson
2021-08-31 16:39 ` [PATCH v2 07/19] target/ppc: Move REQUIRE_ALTIVEC/VECTOR to translate.c Luis Pires
2021-08-31 18:12   ` Richard Henderson
2021-09-02  3:23   ` David Gibson
2021-08-31 16:39 ` [PATCH v2 08/19] target/ppc: Introduce REQUIRE_FPU Luis Pires
2021-08-31 18:15   ` Richard Henderson
2021-08-31 16:39 ` [PATCH v2 09/19] target/ppc: Implement DCFFIXQQ Luis Pires
2021-08-31 18:18   ` Richard Henderson
2021-09-01 12:38     ` Matheus K. Ferst
2021-09-01 12:50       ` Luis Fernando Fujita Pires
2021-08-31 16:39 ` [PATCH v2 10/19] host-utils: Introduce mulu128 Luis Pires
2021-09-03 21:12   ` Richard Henderson
2021-08-31 16:39 ` [PATCH v2 11/19] libdecnumber: Introduce decNumberIntegralToInt128 Luis Pires
2021-09-03 21:14   ` Richard Henderson
2021-08-31 16:40 ` [PATCH v2 12/19] target/ppc: Implement DCTFIXQQ Luis Pires
2021-08-31 16:40 ` [PATCH v2 13/19] target/ppc: Move dtstdc[q]/dtstdg[q] to decodetree Luis Pires
2021-08-31 16:40 ` [PATCH v2 14/19] target/ppc: Move d{add, sub, mul, div, iex}[q] " Luis Pires
2021-08-31 16:40 ` [PATCH v2 15/19] target/ppc: Move dcmp{u, o}[q], dts{tex, tsf, tsfi}[q] " Luis Pires
2021-08-31 16:40 ` [PATCH v2 16/19] target/ppc: Move dquai[q], drint{x, n}[q] " Luis Pires
2021-08-31 16:40 ` [PATCH v2 17/19] target/ppc: Move dqua[q], drrnd[q] " Luis Pires
2021-08-31 16:40 ` [PATCH v2 18/19] target/ppc: Move dct{dp, qpq}, dr{sp, dpq}, dc{f, t}fix[q], dxex[q] " Luis Pires
2021-08-31 16:40 ` [PATCH v2 19/19] target/ppc: Move ddedpd[q], denbcd[q], dscli[q], dscri[q] " Luis Pires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3bcc33e9-7076-e3ba-df86-1950cd1caa36@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=luis.pires@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.