public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Jiufu Guo <guojiufu@linux.ibm.com>
Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH V4 2/2] rs6000: use li;x?oris to build constant
Date: Mon, 15 May 2023 14:53:49 +0800	[thread overview]
Message-ID: <2230a42c-98cc-bad4-7c3e-98d42a9281b9@linux.ibm.com> (raw)
In-Reply-To: <20221212013829.111739-2-guojiufu@linux.ibm.com>

Hi Jeff,

on 2022/12/12 09:38, Jiufu Guo wrote:
> Hi,
> 
> For constant C:
> If '(c & 0xFFFFFFFF0000FFFFULL) == 0xFFFFFFFF00000000' or say:
> 32(1) || 1(0) || 15(x) || 16(0), we could use "lis; xoris" to build.
> 
> Here N(M) means N continuous bit M, x for M means it is ok for either
> 1 or 0; '||' means concatenation.
> 
> This patch update rs6000_emit_set_long_const to support those constants.
> 
> Compare with previous version:
> https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607618.htm
> This patch fix conflicts with trunk.
> 
> Bootstrap and regtest pass on ppc64{,le}.
> 
> Is this ok for trunk?

OK for trunk, thanks for improving this.

btw, the test case needs to be updated a bit as the function names in the
context changed upstream, please ensure it's tested well before committing,
thanks!

> 
> BR,
> Jeff (Jiufu)
> 
> 
> 	PR target/106708
> 
> gcc/ChangeLog:
> 
> 	* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add to build
> 	constants through "lis; xoris".

Maybe s/Add to build/Support building/

BR,
Kewen

> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/powerpc/pr106708.c: Add test function.
> 
> ---
>  gcc/config/rs6000/rs6000.cc                 |  7 +++++++
>  gcc/testsuite/gcc.target/powerpc/pr106708.c | 10 +++++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index 8c1192a10c8..1138d5e8cd4 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -10251,6 +10251,13 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c)
>        if (ud1 != 0)
>  	emit_move_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
>      }
> +  else if (ud4 == 0xffff && ud3 == 0xffff && !(ud2 & 0x8000) && ud1 == 0)
> +    {
> +      /* lis; xoris */
> +      temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
> +      emit_move_insn (temp, GEN_INT (sext_hwi ((ud2 | 0x8000) << 16, 32)));
> +      emit_move_insn (dest, gen_rtx_XOR (DImode, temp, GEN_INT (0x80000000)));
> +    }
>    else if (ud4 == 0xffff && ud3 == 0xffff && (ud1 & 0x8000))
>      {
>        /* li; xoris */
> diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c b/gcc/testsuite/gcc.target/powerpc/pr106708.c
> index dc9ceda8367..a015c71e630 100644
> --- a/gcc/testsuite/gcc.target/powerpc/pr106708.c
> +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c
> @@ -4,7 +4,7 @@
>  /* { dg-require-effective-target has_arch_ppc64 } */
> 
>  long long arr[]
> -  = {0xffffffff7cdeab55LL, 0x98765432LL, 0xabcd0000LL};
> += {0xffffffff7cdeab55LL, 0x98765432LL, 0xabcd0000LL, 0xffffffff65430000LL};
> 
>  void __attribute__ ((__noipa__)) lixoris (long long *arg)
>  {
> @@ -27,6 +27,13 @@ void __attribute__ ((__noipa__)) lisrldicl (long long *arg)
>  /* { dg-final { scan-assembler-times {\mlis .*,0xabcd\M} 1 } } */
>  /* { dg-final { scan-assembler-times {\mrldicl .*,0,32\M} 1 } } */
> 
> +void __attribute__ ((__noipa__)) lisxoris (long long *arg)
> +{
> +  *arg = 0xffffffff65430000LL;
> +}
> +/* { dg-final { scan-assembler-times {\mlis .*,0xe543\M} 1 } } */
> +/* { dg-final { scan-assembler-times {\mxoris .*0x8000\M} 1 } } */
> +
>  int
>  main ()
>  {
> @@ -35,6 +42,7 @@ main ()
>    lixoris (a);
>    lioris (a + 1);
>    lisrldicl (a + 2);
> +  lisxoris (a + 3);
>    if (__builtin_memcmp (a, arr, sizeof (arr)) != 0)
>      __builtin_abort ();
>    return 0;


  parent reply	other threads:[~2023-05-15  6:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12  1:38 [PATCH V4 1/2] " Jiufu Guo
2022-12-12  1:38 ` [PATCH V4 2/2] " Jiufu Guo
2023-01-04  6:11   ` Jiufu Guo
2023-02-20  4:41     ` Ping^^ " Jiufu Guo
2023-04-26  2:35       ` Ping^^^ " Jiufu Guo
2023-05-15  6:53   ` Kewen.Lin [this message]
2023-05-17  2:17     ` guojiufu
2022-12-14 10:27 ` [PATCH V4 1/2] " Kewen.Lin
2022-12-15  3:29   ` Jiufu Guo
2022-12-16 21:12   ` Segher Boessenkool
2022-12-16 21:16 ` Segher Boessenkool
2022-12-19  9:16   ` Jiufu Guo

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=2230a42c-98cc-bad4-7c3e-98d42a9281b9@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guojiufu@linux.ibm.com \
    --cc=linkw@gcc.gnu.org \
    --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).