From: Richard Biener <rguenther@suse.de>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
"MacLeod, Andrew" <amacleod@redhat.com>,
Jeff Law <jeffreyalaw@gmail.com>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] Properly honor param_max_fsm_thread_path_insns in backwards threader
Date: Tue, 2 Aug 2022 13:29:43 +0000 (UTC) [thread overview]
Message-ID: <nycvar.YFH.7.77.849.2208021324300.4208@jbgna.fhfr.qr> (raw)
In-Reply-To: <CAGm3qMV-LTuPfvS=mkGvVr4k-TSZydb15hzFaspVDGKKshti_g@mail.gmail.com>
On Tue, 2 Aug 2022, Aldy Hernandez wrote:
> On Tue, Aug 2, 2022 at 1:59 PM Richard Biener <rguenther@suse.de> wrote:
> >
> > On Tue, 2 Aug 2022, Aldy Hernandez wrote:
> >
> > > On Tue, Aug 2, 2022 at 1:45 PM Richard Biener <rguenther@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,
>
> Sorry for the pain.
So - actually the change was probably done on purpose (even if
reverting - which I've now already one - caused no testsuite regressions).
That's because the whole function is invoked N + 1 times for a path
of length N and we definitely want to avoid using the size optimization
heuristics when the path is not complete yet. I think the proper
way is to do
diff --git a/gcc/tree-ssa-threadbackward.cc
b/gcc/tree-ssa-threadbackward.cc
index ba114e98a41..6979398ef76 100644
--- a/gcc/tree-ssa-threadbackward.cc
+++ b/gcc/tree-ssa-threadbackward.cc
@@ -767,7 +767,11 @@ back_threader_profitability::profitable_path_p (const
vec<basic_block> &m_path,
as in PR 78407 this leads to noticeable improvements. */
if (m_speed_p
&& ((taken_edge && optimize_edge_for_speed_p (taken_edge))
- || contains_hot_bb))
+ || contains_hot_bb
+ /* Avoid using the size heuristics when not doing the final
+ thread evaluation, we get called for each added BB
+ to the path. */
+ || !taken_edge))
{
if (n_insns >= param_max_fsm_thread_path_insns)
{
thus assume there'll be a hot BB in the future.
That said, the very best fix would be to not call this function
N + 1 times (I have a patch to call it only N times - yay), but
instead factor out parts to be called per BB plus keeping enough
state so we can incrementally collect info.
There's more "odd" things in the backward threader, of course :/
I'm looking for things applicable to the GCC 12 branch right now
so will try the above.
Richard.
next prev parent reply other threads:[~2022-08-02 13:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <04261.122080204410800126@us-mta-529.us.mimecast.lan>
2022-08-02 10:21 ` Aldy Hernandez
2022-08-02 11:45 ` Richard Biener
2022-08-02 11:54 ` Aldy Hernandez
2022-08-02 11:59 ` Richard Biener
2022-08-02 12:03 ` Aldy Hernandez
2022-08-02 13:29 ` Richard Biener [this message]
2022-08-02 14:25 ` Aldy Hernandez
2022-08-02 16:31 ` Jan Hubicka
2022-08-03 9:58 ` Richard Biener
[not found] <20220802130109.AD89F385381B@sourceware.org>
2022-08-05 16:35 ` Jeff Law
2022-08-02 13:00 Richard Biener
-- strict thread matches above, loose matches on Subject: below --
2022-08-02 13:00 Richard Biener
2022-08-02 13:00 Richard Biener
2022-08-02 8:41 Richard Biener
2022-08-02 8:41 Richard Biener
2022-08-02 8:41 Richard Biener
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=nycvar.YFH.7.77.849.2208021324300.4208@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=jeffreyalaw@gmail.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).