public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
	richard.sandiford@arm.com,
	 Roger Sayle <roger@nextmovesoftware.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] i386: Save/restore recog_data in ix86_vector_duplicate_value [PR106577]
Date: Fri, 2 Dec 2022 10:51:00 +0100	[thread overview]
Message-ID: <CAFULd4Y-vN2YoLtBC0kSBv6RV-jvgZ+BR3Ntw+-e3E3HtaKG=A@mail.gmail.com> (raw)
In-Reply-To: <Y4nH2qqDl0WFBiYS@tucnak>

On Fri, Dec 2, 2022 at 10:39 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> On Tue, Aug 16, 2022 at 09:14:06AM +0100, Richard Sandiford via Gcc-patches wrote:
> > IMO the correct low-effort fix is to save and restore recog_data
> > in ix86_vector_duplicate_value.  It's a relatively big copy,
> > but the current code is pretty wasteful anyway (allocating at
> > least a new SET and INSN for every query).  Compared to the
> > overhead of doing that, a copy to and from the stack shouldn't
> > be too bad.
>
> The following patch does that.
> It isn't the first spot in the compiler that does that, not even the first
> spot in the i386 backend.
> In i386-expand.cc beyond these 2 recog_memoized calls there is one in
> expand_vselect, but I think it is unlikely we'd run into these issues trying
> to expand new permutations from splitters.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2022-12-02  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/106577
>         * config/i386/i386-expand.cc (ix86_vector_duplicate_value): Save/restore
>         recog_data around recog_memoized calls.
>
>         * gcc.target/i386/pr106577.c: New test.

OK.

Thanks,
Uros.

>
> --- gcc/config/i386/i386-expand.cc.jj   2022-12-01 09:29:15.233466321 +0100
> +++ gcc/config/i386/i386-expand.cc      2022-12-01 14:05:55.901157211 +0100
> @@ -15187,6 +15187,10 @@ ix86_vector_duplicate_value (machine_mod
>    bool ok;
>    rtx_insn *insn;
>    rtx dup;
> +  /* Save/restore recog_data in case this is called from splitters
> +     or other routines where recog_data needs to stay valid across
> +     force_reg.  See PR106577.  */
> +  recog_data_d recog_data_save = recog_data;
>
>    /* First attempt to recognize VAL as-is.  */
>    dup = gen_vec_duplicate (mode, val);
> @@ -15212,6 +15216,7 @@ ix86_vector_duplicate_value (machine_mod
>        ok = recog_memoized (insn) >= 0;
>        gcc_assert (ok);
>      }
> +  recog_data = recog_data_save;
>    return true;
>  }
>
> --- gcc/testsuite/gcc.target/i386/pr106577.c.jj 2022-12-01 14:13:03.973872383 +0100
> +++ gcc/testsuite/gcc.target/i386/pr106577.c    2022-12-01 14:13:03.973872383 +0100
> @@ -0,0 +1,10 @@
> +/* PR target/106577 */
> +/* { dg-do compile { target int128 } } */
> +/* { dg-options "-O2 -mavx" } */
> +
> +int i;
> +void
> +foo (void)
> +{
> +  i ^= !(((unsigned __int128)0xf0f0f0f0f0f0f0f0 << 64 | 0xf0f0f0f0f0f0f0f0) & i);
> +}
>
>
>         Jakub
>

      reply	other threads:[~2022-12-02  9:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 20:40 [x86 PATCH] PR target/106577: force_reg may clobber operands during split Roger Sayle
2022-08-15  7:45 ` Richard Biener
2022-08-16  8:14   ` Richard Sandiford
2022-08-16  8:26     ` Richard Biener
2022-08-16  9:02       ` Richard Sandiford
2022-12-02  9:39     ` [PATCH] i386: Save/restore recog_data in ix86_vector_duplicate_value [PR106577] Jakub Jelinek
2022-12-02  9:51       ` Uros Bizjak [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='CAFULd4Y-vN2YoLtBC0kSBv6RV-jvgZ+BR3Ntw+-e3E3HtaKG=A@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    --cc=roger@nextmovesoftware.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).