public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hongtao Liu <crazylht@gmail.com>
To: "Kong, Lingling" <lingling.kong@intel.com>
Cc: "Liu, Hongtao" <hongtao.liu@intel.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] x86: Handle V8BF in expand_vec_perm_broadcast_1
Date: Wed, 31 Aug 2022 17:55:28 +0800	[thread overview]
Message-ID: <CAMZc-bxk95e+vL_BCV_caEv3y2Xf48BzCqnrnb53ery1QxByag@mail.gmail.com> (raw)
In-Reply-To: <DM4PR11MB5487442537677F3B911B02C8EC789@DM4PR11MB5487.namprd11.prod.outlook.com>

On Wed, Aug 31, 2022 at 2:52 PM Kong, Lingling via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> Handle E_V8BFmode in expand_vec_perm_broadcast_1 and ix86_expand_vector_init_duplicate.
> Ok for trunk?
>
> gcc/ChangeLog:
>
>         PR target/106742
>         * config/i386/i386-expand.cc (ix86_expand_vector_init_duplicate):
>         Handle V8BF mode.
>         (expand_vec_perm_broadcast_1): Ditto.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/pr106742.c: New test.
> ---
>  gcc/config/i386/i386-expand.cc           | 17 ++++++++++++-----
>  gcc/testsuite/gcc.target/i386/pr106742.c | 10 ++++++++++
>  2 files changed, 22 insertions(+), 5 deletions(-)  create mode 100644 gcc/testsuite/gcc.target/i386/pr106742.c
>
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 4b216308a18..a08222fe1b6 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -15030,11 +15030,15 @@ ix86_expand_vector_init_duplicate (bool mmx_ok, machine_mode mode,
>           dperm.op0 = dperm.op1 = gen_reg_rtx (mode);
>           dperm.one_operand_p = true;
>
> -         if (mode == V8HFmode)
> +         if (mode == V8HFmode || mode == V8BFmode)
>             {
> -             tmp1 = force_reg (HFmode, val);
> +             rtx (*gen_vec_set_0) (rtx, rtx, rtx) = NULL;
> +             tmp1 = mode == V8HFmode ? force_reg (HFmode, val)
> +                                     : force_reg (BFmode, val);
tmp1 = force_reg (GET_MODE_INNER (mode), val);
>               tmp2 = gen_reg_rtx (mode);
> -             emit_insn (gen_vec_setv8hf_0 (tmp2, CONST0_RTX (mode), tmp1));
> +             gen_vec_set_0 = mode == V8HFmode ? gen_vec_setv8hf_0
> +                                              : gen_vec_setv8bf_0;
add @ to vec_set<mode>_0 as (define_insn "@vec_set<mode>_0" and pass
mode to vec_set_0 as
emit_insn (gen_vec_set_0 (mode, tmp2, CONST0_RTX (mode), tmp1));
> +             emit_insn (gen_vec_set_0 (tmp2, CONST0_RTX (mode), tmp1));

>               tmp1 = gen_lowpart (mode, tmp2);
>             }
>           else
> @@ -21822,17 +21826,20 @@ expand_vec_perm_broadcast_1 (struct expand_vec_perm_d *d)
>        return true;
>
>      case E_V8HFmode:
> +    case E_V8BFmode:
>        /* This can be implemented via interleave and pshufd.  */
>        if (d->testing_p)
>         return true;
>
>        if (elt >= nelt2)
>         {
> -         gen = gen_vec_interleave_highv8hf;
> +         gen = vmode == V8HFmode ? gen_vec_interleave_highv8hf
> +                                 : gen_vec_interleave_highv8bf;
Similar, add @ to define_insn and pass gen_vec_interleave.
>           elt -= nelt2;
>         }
>        else
> -       gen = gen_vec_interleave_lowv8hf;
> +       gen = vmode == V8HFmode ? gen_vec_interleave_lowv8hf
> +                               : gen_vec_interleave_lowv8bf;
>        nelt2 /= 2;
>
>        dest = gen_reg_rtx (vmode);
> diff --git a/gcc/testsuite/gcc.target/i386/pr106742.c b/gcc/testsuite/gcc.target/i386/pr106742.c
> new file mode 100644
> index 00000000000..4a53cd49902
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr106742.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options " -msse2 -mno-avx2 -O1" } */
> +typedef __bf16 v8bf __attribute__ ((__vector_size__ (16)));
> +
> +v8bf
> +vec_init_dup_v8bf (__bf16 a1)
> +{
> +  return __extension__ (v8bf) { a1, a1, a1, a1, a1, a1, a1, a1 }; }
> +/* { dg-final { scan-assembler-times "punpcklwd" 1} } */
> --
> 2.18.2
>


-- 
BR,
Hongtao

  parent reply	other threads:[~2022-08-31  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220831064846.1305576-1-lingling.kong@intel.com>
2022-08-31  6:52 ` Kong, Lingling
2022-08-31  6:52   ` Kong, Lingling
2022-08-31  9:55   ` Hongtao Liu [this message]
2022-09-02  8:08     ` Kong, Lingling
2022-09-05  0:59       ` Hongtao Liu

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=CAMZc-bxk95e+vL_BCV_caEv3y2Xf48BzCqnrnb53ery1QxByag@mail.gmail.com \
    --to=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    --cc=lingling.kong@intel.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).