public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: HAO CHEN GUI <guihaoc@linux.ibm.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	David <dje.gcc@gmail.com>, Peter Bergner <bergner@linux.ibm.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH-1, rs6000] Generate permute index directly for little endian target [PR100866]
Date: Fri, 25 Nov 2022 15:50:40 +0800	[thread overview]
Message-ID: <ef515222-ac88-f687-2d4b-c6129fa95d2d@linux.ibm.com> (raw)
In-Reply-To: <c1acd025-c91f-58b7-3b34-40635bb38cac@linux.ibm.com>

Hi Haochen,

Sorry for the late review.

on 2022/10/11 15:38, HAO CHEN GUI wrote:
> Hi,
>   This patch modifies the help function which generates permute index for
> vector byte reversion and generates permute index directly for little endian
> targets. It saves one "xxlnor" instructions on P8 little endian targets as
> the original process needs an "xxlnor" to calculate complement for the index.
> 

Nice.

>     Bootstrapped and tested on ppc64 Linux BE and LE with no regressions.
> Is this okay for trunk? Any recommendations? Thanks a lot.
> 
> ChangeLog
> 2022-10-11  Haochen Gui <guihaoc@linux.ibm.com>
> 
> gcc/
> 	PR target/100866
> 	* config/rs6000/rs6000-call.cc (swap_endian_selector_for_mode):
> 	Generate permute index directly for little endian targets.
> 	* config/rs6000/vsx.md (revb_<mode>): Call vprem directly with
> 	corresponding permute indexes.
> 
> gcc/testsuite/
> 	PR target/100866
> 	* gcc.target/powerpc/pr100866.c: New.
> 
> patch.diff
> diff --git a/gcc/config/rs6000/rs6000-call.cc b/gcc/config/rs6000/rs6000-call.cc
> index 551968b0995..bad8e9e0e52 100644
> --- a/gcc/config/rs6000/rs6000-call.cc
> +++ b/gcc/config/rs6000/rs6000-call.cc
> @@ -2839,7 +2839,10 @@ swap_endian_selector_for_mode (machine_mode mode)
>      }
> 
>    for (i = 0; i < 16; ++i)
> -    perm[i] = GEN_INT (swaparray[i]);
> +    if (BYTES_BIG_ENDIAN)
> +      perm[i] = GEN_INT (swaparray[i]);
> +    else
> +      perm[i] = GEN_INT (~swaparray[i] & 0x0000001f);

IMHO, it would be good to add a function comment for this function,
it's sad that we didn't have it before.  With this patch, the selector (perm) is
expected to be used with vperm direct as shown below, it would be good to note it
explicitly for other potential callers too.

> 
>    return force_reg (V16QImode, gen_rtx_CONST_VECTOR (V16QImode,
>  						     gen_rtvec_v (16, perm)));
> diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
> index e226a93bbe5..b68eba48d2c 100644
> --- a/gcc/config/rs6000/vsx.md
> +++ b/gcc/config/rs6000/vsx.md
> @@ -6096,8 +6096,8 @@ (define_expand "revb_<mode>"
>  	 to the endian mode in use, i.e. in LE mode, put elements
>  	 in BE order.  */
>        rtx sel = swap_endian_selector_for_mode(<MODE>mode);
> -      emit_insn (gen_altivec_vperm_<mode> (operands[0], operands[1],
> -					   operands[1], sel));
> +      emit_insn (gen_altivec_vperm_<mode>_direct (operands[0], operands[1],
> +						  operands[1], sel));>      }
> 
>    DONE;
> diff --git a/gcc/testsuite/gcc.target/powerpc/pr100866.c b/gcc/testsuite/gcc.target/powerpc/pr100866.c
> new file mode 100644
> index 00000000000..c708dfd502e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/pr100866.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target powerpc_p8vector_ok } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */
> +/* { dg-final { scan-assembler-not "xxlnor" } } */

Nit: may be better with {\mxxlnor\M}?

The others look good to me.  Thanks!

BR,
Kewen

> +
> +#include <altivec.h>
> +
> +vector unsigned short revb(vector unsigned short a)
> +{
> +   return vec_revb(a);
> +}
> 



      reply	other threads:[~2022-11-25  7:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  7:38 HAO CHEN GUI
2022-11-25  7:50 ` Kewen.Lin [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=ef515222-ac88-f687-2d4b-c6129fa95d2d@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guihaoc@linux.ibm.com \
    --cc=segher@kernel.crashing.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).