public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Matthias Gehre <matthias.gehre@amd.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: [RFC] Adding division/modulo on arbitrary precision integers to libgcc
Date: Fri, 6 May 2022 16:47:39 +0200	[thread overview]
Message-ID: <YnU1C7ZyywuRJo+7@tucnak> (raw)
In-Reply-To: <SA1PR02MB857379606D84DDC929D69D32A7C59@SA1PR02MB8573.namprd02.prod.outlook.com>

On Fri, May 06, 2022 at 02:09:21PM +0000, Matthias Gehre via Gcc wrote:
> /// \param quo The quotient represented by n words. Must be non-null.
> /// \param rem The remainder represented by n words. Must be non-null.
> /// \param a The dividend represented by n + 1 words. Must be non-null.
> /// \param b The divisor represented by n words. Must be non-null.
> 
> /// \note The word order is in host endianness.
> /// \note Might modify a and b.
> /// \note The storage of 'a' needs to hold n + 1 elements because some
> ///       implementations need extra scratch space in the most significant word.
> ///       The value of that word is ignored.
> void __udivmodei5(uint32_t *quo, uint32_t *rem, uint32_t *a,
>                                   uint32_t *b, unsigned n);
> 
> /// Computes the signed division of a / b.
> /// See __udivmodei5 for details.
> void __divmodei5(uint32_t *quo, uint32_t *rem, uint32_t *a, uint32_t *b,
>                                  unsigned n);

Sizes certainly should be with size_t, not unsigned type.
Rather than uint32_t, wouldn't using the word size (64-bit for lp64, 32-bit
for ilp32) be better?
And I really don't like the N + 1 stuff you're proposing, at least for
_BigInts that would be represented as an array of those word etc. elements
from least to most significant (or vice versa?  That really needs to be
specified too), if they are same precision having to copy one of them just
to get the extra scratch is bad.

	Jakub


  parent reply	other threads:[~2022-05-06 14:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 14:09 Matthias Gehre
2022-05-06 14:36 ` Joseph Myers
2022-05-06 15:57   ` AW: " Matthias Gehre
2022-05-06 16:02     ` Joseph Myers
2022-05-06 14:47 ` Jakub Jelinek [this message]
2022-05-06 15:23   ` Joseph Myers
2022-05-06 15:42   ` AW: " Matthias Gehre
2022-05-06 16:39     ` Jonathan Lennox
2022-05-06 18:05 ` Segher Boessenkool

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=YnU1C7ZyywuRJo+7@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=matthias.gehre@amd.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).