public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org
Subject: Re: Reorgnanization of profile count maintenance code, part 1
Date: Wed, 07 Jun 2017 21:11:00 -0000	[thread overview]
Message-ID: <20170607211108.GB30427@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <20170607184437.GG19687@gate.crashing.org>

> On Tue, Jun 06, 2017 at 10:25:29PM +0200, Jan Hubicka wrote:
> > > On Thu, Jun 01, 2017 at 01:35:56PM +0200, Jan Hubicka wrote:
> > > > +      /* FIXME: shrink wrapping violates this sanity check.  */
> > > > +      gcc_checking_assert ((num >= 0
> > > > +			    && (num <= REG_BR_PROB_BASE
> > > > +			        || den <= REG_BR_PROB_BASE)
> > > > +			    && den > 0) || 1);
> > > > +      ret.m_val = RDIV (m_val * num, den);
> > > > +      return ret;
> > > 
> > > Sorry if I missed this...  But where/how does it violate this?
> > 
> > It sums multiple probabilties together and overflows the limit.
> 
> Ah.  Yes, the scale it uses (num/den in shrink-wrap.c:924) isn't a
> probability: it's a just a fraction, but also <= 1.  The calculation cannot
> overflow, not while there are at most 4G incoming edges to a BB.

Problem is that when you multiply count by it, the buffer is considerably
smaller, because count itself can be quite large number...

It is not too bad - I added the sanity check mostly to see if there
is a safe cap on num so I do not need to worry about overflows at all.

Honza
> 
> 
> Segher

  reply	other threads:[~2017-06-07 21:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 11:36 Jan Hubicka
2017-06-03 18:51 ` Bernhard Reutner-Fischer
2017-06-04 17:21   ` Jan Hubicka
2017-06-05 15:13     ` Joseph Myers
2017-06-05 15:16       ` Jan Hubicka
2017-06-05 15:37       ` Jan Hubicka
2017-06-05 18:38         ` Andrew Pinski
2017-06-06  5:57 ` Jason Merrill
2017-06-06  8:00   ` Jan Hubicka
2017-06-08 16:57     ` Jason Merrill
2017-06-09  7:52       ` Jan Hubicka
2017-06-06 16:31 ` Segher Boessenkool
2017-06-06 20:25   ` Jan Hubicka
2017-06-07 18:44     ` Segher Boessenkool
2017-06-07 21:11       ` Jan Hubicka [this message]
2017-06-07 21:41         ` Segher Boessenkool
2017-06-05 18:52 Dominique d'Humières
2017-06-05 19:14 ` Jan Hubicka

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=20170607211108.GB30427@atrey.karlin.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.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 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).