public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
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>,
	Richard Biener <richard.guenther@gmail.com>,
	Jeff Law <jeffreyalaw@gmail.com>,
	Raphael Zinsly <rzinsly@ventanamicro.com>
Subject: Re: [PATCH v2] rtl-optimization: ppc backend generates unnecessary extension.
Date: Thu, 30 Mar 2023 08:41:13 -0500	[thread overview]
Message-ID: <20230330134113.GO25951@gate.crashing.org> (raw)
In-Reply-To: <a22c34d6-07c5-80a5-f6d5-8aa49869a03d@linux.ibm.com>

Hi!

On Tue, Mar 28, 2023 at 10:19:27PM +0530, Ajit Agarwal wrote:
> This patch makes REE pass as a default pass in rs6000 target. And
> add necessary subroutines to eliminate extensions across basic blocks.

Please wait with this until stage 1?

Some comments:

> 	rtl-optimization: ppc backend generates unnecessary
>  	extension.

Subject can start with "ree: ", but not "rtl-optimization: ".  Subject
should start with a capital (the part after the colon, that is).  There
should not be a full stop in the subject.

Subjects should be in the mail subject, not elsewhere in the patch.

> 	Eliminate unnecessary redundant zero extension across basic
> 	blocks.

Not sure where you want this?  It doesn't belong in the changelog.

> 	* ree.cc(insn_s_zext_p): New function.

Space before (.

> 	* ree.cc(is_feasible_elim_across_basic_blocks):
> 	New function.

This is the same file as the one before this.  You write that as
	(is_feasible_elim_across_basic_blocks): New function.

(and no early line breaks please, certainly not after a colon).

> 	* common/config/rs6000/rs6000-common.cc: Add free pass
> 	as default pass in rs6000 target.

Changelog lines are 80 positions.  The leading tab is 8 positions.

> @@ -30,6 +30,8 @@
>  /* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
>  static const struct default_options rs6000_option_optimization_table[] =
>    {
> +    /* Enable -free for zero extension and sign extension elimination.*/
> +    { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 },

>      /* Split multi-word types early.  */
>      { OPT_LEVELS_ALL, OPT_fsplit_wide_types_early, NULL, 1 },
>      /* Enable -fsched-pressure for first pass instruction scheduling.  */
> @@ -42,7 +44,6 @@ static const struct default_options rs6000_option_optimization_table[] =
>      /* -frename-registers leads to non-optimal codegen and performance
>         on rs6000, turn it off by default.  */
>      { OPT_LEVELS_ALL, OPT_frename_registers, NULL, 0 },
> -

Don't remove random lines please.  Never do this as part of unrelated
patches, too.

> +/* Identify instruction AND with identical zero extension.  */

What does that mean?

> +
> +static unsigned int
> +insn_is_zext_p(rtx insn)

Space before (.  If it is an insn, you probably want rtx_insn?

> +{
> +  if (GET_CODE (insn) == AND)
> +   {

Wrong indentation.

> +     rtx set = XEXP (insn, 0);
> +     if (REG_P(set))
> +       {
> +	 if (CONST_INT_P (XEXP (insn, 1))

You can see that here: all indentations are a multiple of two, so a
single space indent is always wrong.

> +	     && INTVAL (XEXP (insn, 1)) == 1)

This easily fits on the previous line.

> +	   return 1;
> +       }
> +     else
> +       return 0;
> +   }
> +
> +  return 0;
> +}

Don't "else return 0" if you have a catch-all anyway?

> +/* Identify instruction AND with identical zero extension.  */
> +
> +static unsigned int
> +insn_is_zext_p(rtx_insn * insn)

No space after * for a pointer.

> +{
> +  rtx body = PATTERN (insn);
> +
> +  if (GET_CODE (body) == PARALLEL) return 0;

Always a new line before an "if" body.

> +  if (GET_CODE(body) == SET && GET_CODE (SET_SRC (body)) == AND)
> +   {
> +     rtx set = XEXP (SET_SRC(body), 0);
> +
> +     if (REG_P(set) && GET_MODE(SET_DEST(body))
> +			 == GET_MODE(set))

What is this for?

> +       {
> +	 if (CONST_INT_P (XEXP (SET_SRC (body), 1))
> +	      && INTVAL (XEXP (SET_SRC (body), 1)) == 1)

The && should align with the previous "C".

You could just say
  if (XEXP (SET_SRC (body), 1) == const1_rtx)
.

> +  if (insn_is_zext_p(cand->insn)
> +       && CONST_INT_P (orig_src) && INTVAL (orig_src) != 0)
> +    return false;

  if (insn_is_zext_p (cand->insn) && orig_src != const0_rtx)
    return false;


So what is this patch doing?  At least two things, right?  It aims to
improve what REE does, and also enables it by default for rs6000?  So
make it two patches, please.

Can you talk a bit about what improvements to generated code you see?


Segher

      parent reply	other threads:[~2023-03-30 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 16:49 Ajit Agarwal
2023-03-30 12:00 ` Ajit Agarwal
2023-03-30 14:28   ` Bernhard Reutner-Fischer
2023-03-30 15:28     ` Segher Boessenkool
2023-03-30 13:41 ` Segher Boessenkool [this message]

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=20230330134113.GO25951@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 \
    --cc=rzinsly@ventanamicro.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).