From: Jan Hubicka <hubicka@kam.mff.cuni.cz>
To: Xionghu Luo <luoxhu@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org, segher@kernel.crashing.org,
wschmidt@linux.ibm.com, linkw@gcc.gnu.org, dje.gcc@gmail.com
Subject: Re: [PATCH 1/3] loop-invariant: Don't move cold bb instructions to preheader in RTL
Date: Thu, 16 Dec 2021 12:20:09 +0100 [thread overview]
Message-ID: <20211216112009.GF4516@kam.mff.cuni.cz> (raw)
In-Reply-To: <ec1898fa-59e2-8dba-c063-307016b762e2@linux.ibm.com>
>
> OK. Comments like?
>
> /* Don't move insn of cold BB out of loop to preheader to reduce calculations
> and register live range in hot loop with cold BB. */
Looks good.
>
>
> And maybe some dump log will help tracking in xxx.c.271r.loop2_invariant.
>
> --- a/gcc/loop-invariant.c
> +++ b/gcc/loop-invariant.c
> @@ -1190,7 +1190,12 @@ find_invariants_bb (class loop *loop, basic_block bb, bool always_reached,
> basic_block preheader = loop_preheader_edge (loop)->src;
>
> if (preheader->count > bb->count)
> - return;
> + {
> + if (dump_file)
> + fprintf (dump_file, "Don't move invariant from bb: %d in loop %d\n",
> + bb->index, loop->num);
> + return;
> + }
This is also a good idea - testcases are quite important for this typo
of stuff.
> >
> > Thinking about this more, you want to test:
> > if (!always_executed && preheader->count > bb->count)
> > return;
> > This will rule out some profile misupates.
> >
> > Also the code updating always_reached is worng:
> > if (always_reached
> > && CALL_P (insn)
> > && (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
> > || ! RTL_CONST_OR_PURE_CALL_P (insn)))
> > always_reached = false;
> > It misses the case where statement can trhow external exception or
> > volatile asms that can also terminate execution.
> >
> > I bit worry on how often the test will have false positives with guessed
> > profile where earlier loop optimizations reduced trip count below
> > realistic estimate.
>
> Sorry I don't understand why always_executed and always_reached matters here?
> the test is based on BB before the FOR_BB_INSNS loop...
always_executed is useful here to avoid the situation where bb->count or
preheader->count is wrong and it would disable wanted transformation.
always_executed is just a bug I noticed while looking at the code. I
will produce testcase for bugzilla.
Honza
next prev parent reply other threads:[~2021-12-16 11:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 5:54 [PATCH 0/3] Dependency patches for hoist LIM code to cold loop Xionghu Luo
2021-12-08 5:54 ` [PATCH 1/3] loop-invariant: Don't move cold bb instructions to preheader in RTL Xionghu Luo
2021-12-08 23:26 ` Jeff Law
2021-12-13 9:14 ` Jan Hubicka
2021-12-13 10:24 ` Jan Hubicka
2021-12-14 9:21 ` Xionghu Luo
2021-12-16 11:20 ` Jan Hubicka [this message]
2021-12-17 1:30 ` Xionghu Luo
2021-12-29 1:43 ` Xionghu Luo
2021-12-29 12:55 ` Jan Hubicka
2021-12-30 6:08 ` Xionghu Luo
2021-12-08 5:54 ` [PATCH 2/3] Fix incorrect loop exit edge probability [PR103270] Xionghu Luo
2021-12-08 23:28 ` Jeff Law
2021-12-13 9:25 ` Jan Hubicka
2021-12-14 9:27 ` Xionghu Luo
2021-12-15 6:40 ` Xionghu Luo
2021-12-16 11:18 ` Jan Hubicka
2021-12-21 3:56 ` Xionghu Luo
2021-12-08 5:54 ` [PATCH 3/3] Fix loop split incorrect count and probability Xionghu Luo
2021-12-08 23:47 ` Jeff Law
2021-12-13 8:57 ` Xionghu Luo
2021-12-21 3:57 ` Xionghu Luo
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=20211216112009.GF4516@kam.mff.cuni.cz \
--to=hubicka@kam.mff.cuni.cz \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@gcc.gnu.org \
--cc=luoxhu@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=wschmidt@linux.ibm.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).