From: Segher Boessenkool <segher@kernel.crashing.org>
To: Ajit Agarwal <aagarwa1@linux.ibm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
Peter Bergner <bergner@linux.ibm.com>,
Jeff Law <jeffreyalaw@gmail.com>,
Richard Biener <richard.guenther@gmail.com>
Subject: Re: [PATCH v1] tree-ssa-sink: Improve code sinking pass.
Date: Thu, 18 May 2023 11:57:10 -0500 [thread overview]
Message-ID: <20230518165710.GI19790@gate.crashing.org> (raw)
In-Reply-To: <acdb8e2b-7c95-0fd2-2189-51f661f15bc5@linux.ibm.com>
Hi!
On Thu, May 18, 2023 at 12:44:28PM +0530, Ajit Agarwal wrote:
> This patch improves code sinking pass to sink statements before call to reduce
> register pressure.
An example would be useful :-)
> * tree-ssa-sink.cc (statement_sink_location): Modifed to
> move statements before calls.
Spello ("modified"). But, you should write in the imperative mood
anyway, so "modify". But, every change is a modification, so do without
the fluff altogether? "Move statements before calls."
> (block_call_p): New function.
> (def_use_same_block): New function.
> (select_best_block): Add heuristics to select the best
> blocks in the immediate post dominator.
Please don't break lines
early
it makes things
harder to
read.
:-)
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-20.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
This is the default, you can just leave it out.
> +/* { dg-options "-O2 -fdump-tree-sink -fdump-tree-optimized -fdump-tree-sink-stats" } */
You don't need -fdump-tree-sink without options since you have
-fdump-tree-sink-stats as well.
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-21.c
> @@ -0,0 +1,20 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-sink-stats -fdump-tree-sink-stats" } */
You don't need to say it twice either :-)
> +/* Return TRUE if immediate uses of the defs in
> + USE occur in the same block as USE, FALSE otherwise. */
> +
> +bool
> +def_use_same_block (gimple *stmt)
> +{
There is no function parameter "use" here? STMT instead?
> + use_operand_p use_p;
> + def_operand_p def_p;
Neither of these is a predicate. Lose the _p please?
> + if (use_p
> + && (gimple_bb (USE_STMT (use_p)) == gimple_bb (stmt)))
Please fit this on one line. And no parens around random things please.
> +/* Return TRUE if the block has only calls, FALSE otherwise. */
> +
> +bool
> +block_call_p (basic_block bb)
> + /* We have already seen a call. */
> + if (is_call)
> + return false;
> +
> + if (is_gimple_call (stmt))
> + is_call = true;
> + else
> + return false;
> + if (is_call && i == 1)
> + return true;
> +
> + return false;
This doesn't do what the function comment says? It is very important
that function comments say exactly what a function does. It can perhaps
leave out some details, but it should be correct by and large.
> + /* Update sinking point as stmt before call if the sinking block
> + has only calls. Otherwise update sinking point as the use
> + stmt. */
(two spaces after full stop, twice)
> + if (gsi_stmt (gsi) == use
> + && !is_gimple_call (last_stmt)
> + && (gimple_code (last_stmt) != GIMPLE_SWITCH)
> + && (gimple_code (last_stmt) != GIMPLE_COND)
> + && (gimple_code (last_stmt) != GIMPLE_GOTO)
> + && (!gimple_vdef (use) || !def_use_same_block (def_stmt)))
Please no unnecessary parens. At first I didn't notice the last line
here *does* need it!
Segher
next prev parent reply other threads:[~2023-05-18 16:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-18 7:14 Ajit Agarwal
2023-05-18 16:57 ` Segher Boessenkool [this message]
2023-05-22 12:56 ` Richard Biener
2023-05-30 5:06 ` Ajit Agarwal
2023-05-30 7:04 ` Richard Biener
2023-05-30 7:32 ` Ajit Agarwal
2023-05-30 11:24 ` 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=20230518165710.GI19790@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=aagarwa1@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=richard.guenther@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).