On Thu, May 05, 2016 at 01:01:39PM +0300, Kirill Yukhin wrote:
> Hello Jakub,
> On 04 May 21:31, Jakub Jelinek wrote:
> > Hi!
> > 
> > As the testcase can show, we should be using v constraint and generate
> > better code that way.
> > 
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > 
> > 2016-05-04  Jakub Jelinek  <ja...@redhat.com>
> > 
> >     * config/i386/sse.md (<avx512>_fmadd_<mode>_mask3<round_name>): Use
> >     v constraint instead of x.
> > 
> >     * gcc.target/i386/avx512f-vfmadd-1.c: New test.
> Didn't get what the test checks?
> It works fine w/o patch (generating extra moves though)
> Maybe scan-asm that xmm{16,17,18} actually hit FMA?

Like this?

2016-05-05  Jakub Jelinek  <ja...@redhat.com>

        * config/i386/sse.md (<avx512>_fmadd_<mode>_mask3<round_name>): Use
        v constraint instead of x.

        * gcc.target/i386/avx512f-vfmadd-1.c: New test.

--- gcc/config/i386/sse.md.jj   2016-05-05 12:57:58.772804841 +0200
+++ gcc/config/i386/sse.md      2016-05-05 12:58:06.875697073 +0200
@@ -3409,10 +3409,10 @@ (define_insn "<avx512>_fmadd_<mode>_mask
    (set_attr "mode" "<MODE>")])
 
 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
-  [(set (match_operand:VF_AVX512VL 0 "register_operand" "=x")
+  [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
        (vec_merge:VF_AVX512VL
          (fma:VF_AVX512VL
-           (match_operand:VF_AVX512VL 1 "register_operand" "x")
+           (match_operand:VF_AVX512VL 1 "register_operand" "v")
            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" 
"<round_constraint>")
            (match_operand:VF_AVX512VL 3 "register_operand" "0"))
          (match_dup 3)
--- gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c.jj 2016-05-05 
12:58:06.876697060 +0200
+++ gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c    2016-05-05 
13:31:03.123435963 +0200
@@ -0,0 +1,27 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -mavx512f" } */
+
+#include <x86intrin.h>
+
+void
+f1 (__m512d x, __m512d y, __m512d z, __mmask8 m)
+{
+  register __m512d a __asm ("xmm16"), b __asm ("xmm17"), c __asm ("xmm18");
+  a = x; b = y; c = z;
+  asm volatile ("" : "+v" (a), "+v" (b), "+v" (c));
+  a = _mm512_mask3_fmadd_round_pd (c, b, a, m, _MM_FROUND_TO_NEG_INF | 
_MM_FROUND_NO_EXC);
+  asm volatile ("" : "+v" (a));
+}
+
+void
+f2 (__m512 x, __m512 y, __m512 z, __mmask8 m)
+{
+  register __m512 a __asm ("xmm16"), b __asm ("xmm17"), c __asm ("xmm18");
+  a = x; b = y; c = z;
+  asm volatile ("" : "+v" (a), "+v" (b), "+v" (c));
+  a = _mm512_mask3_fmadd_round_ps (c, b, a, m, _MM_FROUND_TO_NEG_INF | 
_MM_FROUND_NO_EXC);
+  asm volatile ("" : "+v" (a));
+}
+
+/* { dg-final { scan-assembler "vfmadd231pd\[^\n\r\]*zmm16" } } */
+/* { dg-final { scan-assembler "vfmadd231ps\[^\n\r\]*zmm16" } } */


        Jakub

Reply via email to