diff mbox

Improve <avx512>_fmadd_<mode>_mask3<round_name>

Message ID 20160504193142.GJ26501@tucnak.zalov.cz
State New
Headers show

Commit Message

Jakub Jelinek May 4, 2016, 7:31 p.m. UTC
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  <jakub@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.


	Jakub

Comments

Kirill Yukhin May 5, 2016, 10:01 a.m. UTC | #1
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  <jakub@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?

--
Thanks, K

> 
> --- gcc/config/i386/sse.md.jj	2016-05-04 14:36:08.000000000 +0200
> +++ gcc/config/i386/sse.md	2016-05-04 15:16:44.180894303 +0200
> @@ -3327,10 +3327,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-04 15:35:54.919506742 +0200
> +++ gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c	2016-05-04 15:36:08.648326113 +0200
> @@ -0,0 +1,24 @@
> +/* { dg-do assemble { target { avx512f && { ! 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));
> +}
> 
> 	Jakub
diff mbox

Patch

--- gcc/config/i386/sse.md.jj	2016-05-04 14:36:08.000000000 +0200
+++ gcc/config/i386/sse.md	2016-05-04 15:16:44.180894303 +0200
@@ -3327,10 +3327,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-04 15:35:54.919506742 +0200
+++ gcc/testsuite/gcc.target/i386/avx512f-vfmadd-1.c	2016-05-04 15:36:08.648326113 +0200
@@ -0,0 +1,24 @@ 
+/* { dg-do assemble { target { avx512f && { ! 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));
+}