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: Kirill Yukhin <kirill.yukhin@gmail.com>,
		"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix -march=knl wrong-code (PR target/84786)
Date: Tue, 13 Mar 2018 07:54:00 -0000	[thread overview]
Message-ID: <CAFULd4bw+GRFu7QK2sJWkJvbKgUmxfgQs_jUUSwQ0oTp3+FKFw@mail.gmail.com> (raw)
In-Reply-To: <20180312205207.GR8577@tucnak>

On Mon, Mar 12, 2018 at 9:52 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> For TARGET_AVX512F && !TARGET_AVX512VL, the RA ensures that
> 128-bit and 256-bit vectors aren't allocated in %xmm16+ registers,
> but not so for scalar modes.  In that case we use avx512vl isa attribute,
> or TARGET_AVX512VL guards, or Yv constraint.
>
> The following patch does the last one for sse2_loadhpd pattern where the
> last argument has DFmode and thus using v constraint for it is unsafe
> and on the testcase we emit
>         vunpcklpd       %xmm18, %xmm0, %xmm0
> instruction which needs avx512vl.  Bootstrapped/regtested on x86_64-linux
> and i686-linux, ok for trunk?
>
> 2018-03-12  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/84786
>         * config/i386/sse.md (sse2_loadhpd): Use Yv constraint rather than v
>         on the last operand.
>
>         * gcc.target/i386/avx512f-pr84786-1.c: New test.
>         * gcc.target/i386/avx512f-pr84786-2.c: New test.

OK for trunk and backports.

Thanks,
Uros.

> --- gcc/config/i386/sse.md.jj   2018-03-05 17:00:24.568655800 +0100
> +++ gcc/config/i386/sse.md      2018-03-12 11:05:48.917401886 +0100
> @@ -9022,14 +9022,14 @@ (define_expand "sse2_loadhpd_exp"
>  ;; see comment above inline_secondary_memory_needed function in i386.c
>  (define_insn "sse2_loadhpd"
>    [(set (match_operand:V2DF 0 "nonimmediate_operand"
> -         "=x,v,x,v,o,o ,o")
> +         "=x,v,x,v ,o,o ,o")
>         (vec_concat:V2DF
>           (vec_select:DF
>             (match_operand:V2DF 1 "nonimmediate_operand"
> -         " 0,v,0,v,0,0 ,0")
> +         " 0,v,0,v ,0,0 ,0")
>             (parallel [(const_int 0)]))
>           (match_operand:DF 2 "nonimmediate_operand"
> -         " m,m,x,v,x,*f,r")))]
> +         " m,m,x,Yv,x,*f,r")))]
>    "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
>    "@
>     movhpd\t{%2, %0|%0, %2}
> --- gcc/testsuite/gcc.target/i386/avx512f-pr84786-1.c.jj        2018-03-12 11:32:33.563665173 +0100
> +++ gcc/testsuite/gcc.target/i386/avx512f-pr84786-1.c   2018-03-12 11:35:33.964695384 +0100
> @@ -0,0 +1,25 @@
> +/* PR target/84786 */
> +/* { dg-do run { target { ! ia32 } } } */
> +/* { dg-options "-mavx512f -mno-avx512vl -O2" } */
> +/* { dg-require-effective-target avx512f } */
> +
> +#include "avx512f-check.h"
> +
> +typedef double V __attribute__((vector_size (16)));
> +
> +__attribute__((noipa)) V
> +foo (V x, double y)
> +{
> +  register double z __asm ("xmm18");
> +  asm volatile ("" : "=v" (z) : "0" (y));
> +  x[1] = z;
> +  return x;
> +}
> +
> +static void
> +avx512f_test (void)
> +{
> +  V a = foo ((V) { 1.0, 2.0 }, 3.0);
> +  if (a[0] != 1.0 || a[1] != 3.0)
> +    abort ();
> +}
> --- gcc/testsuite/gcc.target/i386/avx512f-pr84786-2.c.jj        2018-03-12 11:32:43.445666826 +0100
> +++ gcc/testsuite/gcc.target/i386/avx512f-pr84786-2.c   2018-03-12 11:35:45.260697279 +0100
> @@ -0,0 +1,16 @@
> +/* PR target/84786 */
> +/* { dg-do compile { target { ! ia32 } } } */
> +/* { dg-options "-mavx512f -mno-avx512vl -O2" } */
> +
> +typedef double V __attribute__((vector_size (16)));
> +
> +__attribute__((noipa)) V
> +foo (V x, double y)
> +{
> +  register double z __asm ("xmm18");
> +  asm volatile ("" : "=v" (z) : "0" (y));
> +  x[1] = z;
> +  return x;
> +}
> +
> +/* { dg-final { scan-assembler-not "vunpcklpd\[\^\n\r]*xmm(1\[6-9]|\[23]\[0-9])" } } */
>
>         Jakub

      reply	other threads:[~2018-03-13  7:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 21:35 Jakub Jelinek
2018-03-13  7:54 ` 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=CAFULd4bw+GRFu7QK2sJWkJvbKgUmxfgQs_jUUSwQ0oTp3+FKFw@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=kirill.yukhin@gmail.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).