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>, bergner@linux.ibm.com
Subject: Re: [PATCH] rs6000: fmr gets used instead of faster xxlor [PR93571]
Date: Tue, 21 Feb 2023 05:04:48 -0600	[thread overview]
Message-ID: <20230221110448.GP25951@gate.crashing.org> (raw)
In-Reply-To: <5f800afe-f162-0d56-3c78-6ee93610e201@linux.ibm.com>

Hi!

On Tue, Feb 21, 2023 at 02:18:25PM +0530, Ajit Agarwal wrote:
> This patch replaces fmr instruction 6 cycles with 2 cycles xxlor instruction
> for p7 and p8 architecture.
> 
> I have implemented with switch and cases otherwise it is difficult to accommodate
> xxlor with p7 and p8 and fmr for other architectures.

Please domn't use a switch, it isn't needed.  Instead use the "isa"
attribute (with p7v here), and put the preferred alternative first.

> 	rs6000: fmr gets used instead of faster xxlor [PR93571]

rs6000: Use xxlor instead of fmr where possible

> 	This patch replaces 6 cycles fmr instruction with xxlor
> 	2 cycles in p8 and p7 architecture.

No, it also does it on all later architectures.

Do you have any actual timings (i.e. from hardware, not documentation)?

> 	* config/rs6000/rs6000.md (*movdf_hardfloat64): Replace fmr with xxlor instruction.

Line too long.  And, that is not what the patch does.  Changelog should
be totally boring just saying what the patch changes.  If the patch
changes things other than what thechangelog says your reviewer will
think something went missin somewhere :-)

> -  "@
> -   stfd%U0%X0 %1,%0
> -   lfd%U1%X1 %0,%1
> -   xxlor %0,%1,%1

That is not what is currently in trunk, so your patch cannot apply.

> +  switch (which_alternative) {
> +    case 0 :  return "stfd%U0%X0 %1,%0";
> +    case 1 :  return "lfd%U1%X1 %0,%1";

Formatting is all incorrect.  We dom't need or want a switch at all, but
correct would be:
  switch (which_alternative)
    {
      case 0:
	return "stfd%U0%X0 %1,%0";
      case 1:
	return "lfd%U1%X1 %0,%1";

etc.

> +    case 2 : if ((TARGET_VSX || TARGET_P8_VECTOR)
> +                  && !TARGET_P9_VECTOR
> +                  && !TARGET_POWER10)
> +               return "xxlor %0,%1,%1";
> +              else
> +                return "fmr %0,%1";

Ah, so you are excluding p9 and p10 here.  Hrm.  That should be written
TARGET_VSX && !TARGET_P9_VECTOR, none of the rest is needed; but is that
a good idea at all?

Please use %xN for VSX arguments whenever possible.  If this alternative
allows only the low numbered vector registers, that is a hint that you
probably should write this differently (and %xN is harmless then).

> +   return "unreachable";

No, never do that.  There is "gcc_unreachable ()" if you need it.

So, let's first do actual timings, and see if it is better on p9 and
p10 as well (or at least not worse).


Segher

  reply	other threads:[~2023-02-21 11:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 16:58 Ajit Agarwal
2023-02-17 17:09 ` Andrew Pinski
2023-02-17 17:23 ` Segher Boessenkool
2023-02-21  8:48   ` Ajit Agarwal
2023-02-21 11:04     ` Segher Boessenkool [this message]
2023-02-21 12:30       ` Ajit Agarwal
2023-02-21 14:09         ` Segher Boessenkool
2023-02-22 10:28           ` Ajit Agarwal
2023-02-24  8:11             ` Ajit Agarwal
2023-02-24 15:11               ` Segher Boessenkool
2023-02-25  7:42                 ` Ajit Agarwal

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=20230221110448.GP25951@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=aagarwa1@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).