public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Marc Glisse <marc.glisse@inria.fr>
Cc: Joern Wolfgang Rennecke <gnu@amylaar.uk>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Simplify X * C1 == C2 with undefined overflow
Date: Fri, 7 Aug 2020 23:02:53 +0200	[thread overview]
Message-ID: <20200807210253.GE2363@tucnak> (raw)
In-Reply-To: <alpine.DEB.2.23.453.2008072241090.6903@stedding.saclay.inria.fr>

On Fri, Aug 07, 2020 at 10:57:54PM +0200, Marc Glisse wrote:
> On Fri, 7 Aug 2020, Joern Wolfgang Rennecke wrote:
> 
> > 
> > On 07/08/20 19:21, Marc Glisse wrote:
> > > 
> > > If we are going to handle the wrapping case, we shouldn't limit to
> > > the non-wrapping meaning of multiplicity. 3*X==5 should become
> > > X==1431655767 (for a 32 bit type), etc.
> > > 
> > > Do we have an extended gcd somewhere in gcc, to help compute 1431655767?
> > I don't quite see yet how this relates to gcd,
> 
> https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm is the most
> common way to compute the modular multiplicative inverse of a number. For 3
> and 2^32, it could tell us that 2863311531*3-2*2^32=1, so modulo 2^32
> 2863311531*3==1, and 3*X==5 is the same as 2863311531*3*X==2863311531*5,
> i.e. X==1431655767.

wi::gcd ?

	Jakub


  reply	other threads:[~2020-08-07 21:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 13:05 Joern Wolfgang Rennecke
2020-08-07 18:21 ` Marc Glisse
2020-08-07 20:30   ` Joern Wolfgang Rennecke
2020-08-07 20:57     ` Marc Glisse
2020-08-07 21:02       ` Jakub Jelinek [this message]
2020-08-07 21:36         ` Marc Glisse
2020-08-08  6:55           ` Jakub Jelinek
2020-08-07 21:58       ` Joern Wolfgang Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2020-08-01  7:28 Marc Glisse
2020-08-03  8:51 ` Richard Biener
2020-08-04 15:38   ` Marc Glisse

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=20200807210253.GE2363@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gnu@amylaar.uk \
    --cc=marc.glisse@inria.fr \
    /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).