public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: "Kewen.Lin" <linkw@linux.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	David Edelsohn <dje.gcc@gmail.com>,
	Peter Bergner <bergner@linux.ibm.com>,
	Michael Meissner <meissner@linux.ibm.com>
Subject: Re: [PATCH] rs6000: Fix vector parity support [PR108699]
Date: Thu, 16 Feb 2023 05:14:35 -0600	[thread overview]
Message-ID: <20230216111435.GH25951@gate.crashing.org> (raw)
In-Reply-To: <e561b827-6f23-07f9-f968-83f485f18cca@linux.ibm.com>

Hi!

On Thu, Feb 16, 2023 at 05:23:40PM +0800, Kewen.Lin wrote:
> This patch is to fix the handling with one more pre-insn
> vpopcntb.  It also fixes an oversight having V8HI in VEC_IP,
> replaces VParity with VEC_IP, and adjusts the existing
> UNSPEC_PARITY to a more meaningful name UNSPEC_PARITYB.

Please don't do that.  UNSPEC_PARITYB is worse than UNSPEC_PARITY,
even more so for the prtyw etc. instructions.

You might want to express the vector parity insns separately, but then
*do that*, don't rename the normal stuff as well, and use a more obvious
name like UNSPEC_VPARITY please.

>    const vsll __builtin_altivec_vprtybd (vsll);
> -    VPRTYBD parityv2di2 {}
> +    VPRTYBD p9v_paritybv2di2 {}

Why this?  Please keep the simpler names if at all possible.

>  	{
>  	  emit_insn (gen_popcntbsi2 (tmp, src));
> -	  emit_insn (gen_paritysi2_cmpb (dst, tmp));
> +	  emit_insn (gen_paritybsi2 (dst, tmp));
>  	}

It is completely non-obvious what a "paritybsi2" is.  There is no such
thing as a "parityb", not for normal people anyway.  It is very
important that names give a hint of what they stand for.

The _cmpb of the existing name indicates that a cmpb insn is generated
here as well.  Has that changed>

> -(define_insn "parity<mode>2_cmpb"
> +(define_insn "parityb<mode>2"
>    [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
> -	(unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
> +	(unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
> +		    UNSPEC_PARITYB))]
>    "TARGET_CMPB && TARGET_POPCNTB"
>    "prty<wd> %0,%1"
>    [(set_attr "type" "popcnt")])

Hrm, the original name was not so good apparently.  Still, please don't
change multiple independent things in one patch, it makes the patch hard
to read and understand and very hard to spot mistakes in.

> @@ -1226,7 +1225,16 @@ (define_expand "popcount<mode>2"
>  (define_expand "parity<mode>2"
>    [(set (match_operand:VEC_IP 0 "register_operand")
>  	(parity:VEC_IP (match_operand:VEC_IP 1 "register_operand")))]
> -  "TARGET_P9_VECTOR")
> +  "TARGET_P9_VECTOR"
> +{
> +  rtx op1 = gen_lowpart (V16QImode, operands[1]);
> +  rtx res = gen_reg_rtx (V16QImode);
> +  emit_insn (gen_popcountv16qi2 (res, op1));
> +  emit_insn (gen_p9v_parityb<mode>2 (operands[0],
> +				    gen_lowpart (<MODE>mode, res)));
> +
> +  DONE;
> +})

So first do a patch that is essentially just this?

Later patches can do all other things (also, not do this expand for
TImode at all, ho hum).


Segher

  reply	other threads:[~2023-02-16 11:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16  9:23 Kewen.Lin
2023-02-16 11:14 ` Segher Boessenkool [this message]
2023-02-16 12:06   ` Kewen.Lin
2023-02-16 15:10     ` Segher Boessenkool
2023-02-17  3:33       ` Kewen.Lin
2023-02-19 12:12         ` Segher Boessenkool
2023-02-20  2:01           ` Kewen.Lin

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=20230216111435.GH25951@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linkw@linux.ibm.com \
    --cc=meissner@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).