On Tue, 2 Aug 2022, Jan Hubicka wrote:

> > On Tue, 2 Aug 2022, Aldy Hernandez wrote:
> > 
> > > On Tue, Aug 2, 2022 at 1:45 PM Richard Biener <rguent...@suse.de> wrote:
> > > >
> > > > On Tue, 2 Aug 2022, Aldy Hernandez wrote:
> > > >
> > > > > Unfortunately, this was before my time, so I don't know.
> > > > >
> > > > > That being said, thanks for tackling these issues that my work
> > > > > triggered last release.  Much appreciated.
> > > >
> > > > Ah.  But it was your r12-324-g69e5544210e3c0 that did
> > > >
> > > > -  else if (n_insns > 1)
> > > > +  else if (!m_speed_p && n_insns > 1)
> > > >
> > > > causing the breakage on the 12 branch.  That leads to a simpler
> > > > fix I guess.  Will re-test and also backport to GCC 12 if successful.
> > > 
> > > Huh.  It's been a while, but that looks like a typo.  That patch was
> > > supposed to be non-behavior changing.
> > 
> > Exactly my thinking so reverting it shouldn't be a reason for
> > detailed questions.  Now, the contains_hot_bb computation is,
> > that one was introduced by Honza in r7-6476-g0f0c2cc3a17efa
> > together with the comment and a testcase.
> > 
> > So - Honza, what was the reasoning to look at raw BB counts here
> > rather than for example the path entry edge count?
> I think the explanation is in the final comment:
>   /* Threading is profitable if the path duplicated is hot but also
>      in a case we separate cold path from hot path and permit ptimization
>      of the hot path later.  Be on the agressive side here. In some estcases,
>      as in PR 78407 this leads to noticeable improvements.  */
> 
> If you have non-threadable hot path threading out cold paths will make
> it easier to be optimized since you have fewer meets in the dataflow.

I see.  It does seem that it would be better handled by tracing the
hot path but of course threading the cold path might be cheaper.

That said, the cost modeling checks hotness of the threaded path
by looking at its exit edge (the one we can optimize statically)
but shouldn't hotness of the threaded path be determined by
looking at the path entry edge count instead?  With inconsistent
guessed profile (inconsistent now that we can statically compute
the outgoing branch on one of the paths) it's of course all GIGO, but ...

I'll leave this alone for now.  Still we now have the exceptions of
predicted never executed entry/exit to avoid diagnostic fallout.

Richard.

Reply via email to