> On Mon, Nov 06, 2017 at 02:47:52PM +0100, Jan Hubicka wrote:
> > Hi,
> > this patch fixes sanity checking ICE with FDO bootstrap.
> > The problem is when ENTRY_BLOCK_PTR count is zero and function is being
> > inlined we disabled scaling. This is no longer correct because scaling
> > also involves conversion between local and global profiles.
> >
> > Bootstrapped/regtested x86_64-linux, comitted.
> >
> > Honza
> >
> > PR bootstrap/82832
> > * ipa-inline-transform.c (update_noncloned_frequencies): Always
> > scale.
> > (inline_transform): Likewise.
> > * predict.c (counts_to_freqs): Remove useless conditional.
> > * profile-count.h (profile_count::apply_scale): Move sanity check.
> > * tree-inline.c (copy_bb): Always scale.
> > (copy_cfg_body): Likewise.
> > Index: ipa-inline-transform.c
> > ===================================================================
> > --- ipa-inline-transform.c (revision 254411)
> > +++ ipa-inline-transform.c (working copy)
> > @@ -59,7 +59,18 @@ update_noncloned_frequencies (struct cgr
> > profile_count den)
> > {
> > struct cgraph_edge *e;
> > - bool scale = (num == profile_count::zero () || den > 0);
> > +
> > + /* We always must scale to be sure counters end up compatible.
> > + If den is zero, just force it nonzero and hope for reasonable
> > + approximation.
> > + When num is forced nonzero, also update den, so we do not scale
> > profile
> > + to 0. */
> > + if (!(num == den)
> > + && !(den.force_nonzero () == den))
>
> Can't we use != here?
Profile_count comparsions are three state (true/false/unknown) and
conservative. This is becuase we have uninitialized counts for BBs missing
profile and also counts of different types (local guess and global profile
feedback)
I do not define != on profie counts for this reason, but still
this is somewhat counter-intuitive way to write that I really want to consider
pairs like 0,unknown as non-equal. Ideas for better API would be welcome.
Honza