public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9489] x86: Also check mode of memory broadcast in bcst_mem_operand
@ 2022-01-24  0:47 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2022-01-24  0:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:520147ba19db8034b1f911326beee104da606daa

commit r11-9489-g520147ba19db8034b1f911326beee104da606daa
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jan 22 12:04:30 2022 -0800

    x86: Also check mode of memory broadcast in bcst_mem_operand
    
    Return false for invalid mode on memory broadcast in bcst_mem_operand:
    
    (vec_duplicate:V16SF (mem/j:V4SF (reg/v/f:DI 109 [ b ])))
    
    gcc/
    
            PR target/104188
            * config/i386/predicates.md (bcst_mem_operand): Also check mode
            of memory broadcast.
    
    gcc/testsuite/
    
            PR target/104188
            * gcc.target/i386/pr104188.c: New test.
    
    (cherry picked from commit 4d2321314a656dd3e30117e2a5266cbacb1e60eb)

Diff:
---
 gcc/config/i386/predicates.md            |  2 +
 gcc/testsuite/gcc.target/i386/pr104188.c | 70 ++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index b1df8548af6..b815aca0da7 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -1140,6 +1140,8 @@
 	    (ior (match_test "TARGET_AVX512VL")
 		 (match_test "GET_MODE_SIZE (GET_MODE (op)) == 64")))
        (match_test "VALID_BCST_MODE_P (GET_MODE_INNER (GET_MODE (op)))")
+       (match_test "GET_MODE (XEXP (op, 0))
+		    == GET_MODE_INNER (GET_MODE (op))")
        (match_test "memory_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)))")))
 
 ; Return true when OP is bcst_mem_operand or vector_memory_operand.
diff --git a/gcc/testsuite/gcc.target/i386/pr104188.c b/gcc/testsuite/gcc.target/i386/pr104188.c
new file mode 100644
index 00000000000..c6f615b9625
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr104188.c
@@ -0,0 +1,70 @@
+/* { dg-do run { target avx512f } } */
+/* { dg-options "-O2 -mfpmath=sse" } */
+
+#include <x86intrin.h>
+
+union U {
+  float m[4][4];
+  __m128 r[4];
+  __m512 s;
+};
+
+__attribute__((noipa, target("avx512f")))
+void
+foo (union U *x, union U *a, union U *b)
+{
+  __m512 c = _mm512_loadu_ps (&a->s);
+  __m512 d = _mm512_broadcast_f32x4 (b->r[0]);
+  __m512 e = _mm512_broadcast_f32x4 (b->r[1]);
+  __m512 f = _mm512_broadcast_f32x4 (b->r[2]);
+  __m512 g = _mm512_broadcast_f32x4 (b->r[3]);
+  __m512 h = _mm512_mul_ps (_mm512_permute_ps (c, 0x00), d);
+  h = _mm512_fmadd_ps (_mm512_permute_ps (c, 0x55), e, h);
+  h = _mm512_fmadd_ps (_mm512_permute_ps (c, 0xaa), f, h);
+  h = _mm512_fmadd_ps (_mm512_permute_ps (c, 0xff), g, h);
+  _mm512_storeu_ps (&x->s, h);
+}
+
+__attribute__((noipa, target("avx512f")))
+void
+do_test (void)
+{
+  union U a = { .m = { { 1.0f, 2.0f, 3.0f, 4.0f },
+		       { 5.0f, 6.0f, 7.0f, 8.0f },
+		       { 9.0f, 10.0f, 11.0f, 12.0f },
+		       { 13.0f, 14.0f, 15.0f, 16.0f } } };
+  union U b = { .m = { { 17.0f, 18.0f, 19.0f, 20.0f },
+		       { 21.0f, 22.0f, 23.0f, 24.0f },
+		       { 25.0f, 26.0f, 27.0f, 28.0f },
+		       { 29.0f, 30.0f, 31.0f, 32.0f } } };
+  union U c;
+  foo (&c, &a, &b);
+  if (c.m[0][0] != 250.0f
+      || c.m[0][1] != 260.0f
+      || c.m[0][2] != 270.0f
+      || c.m[0][3] != 280.0f)
+    __builtin_abort ();
+  if (c.m[1][0] != 618.0f
+      || c.m[1][1] != 644.0f
+      || c.m[1][2] != 670.0f
+      || c.m[1][3] != 696.0f)
+    __builtin_abort ();
+  if (c.m[2][0] != 986.0f
+      || c.m[2][1] != 1028.0f
+      || c.m[2][2] != 1070.0f
+      || c.m[2][3] != 1112.0f)
+    __builtin_abort ();
+  if (c.m[3][0] != 1354.0f
+      || c.m[3][1] != 1412.0f
+      || c.m[3][2] != 1470.0f
+      || c.m[3][3] != 1528.0f)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  if (__builtin_cpu_supports ("avx512f"))
+    do_test ();
+  return 0;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-24  0:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24  0:47 [gcc r11-9489] x86: Also check mode of memory broadcast in bcst_mem_operand H.J. Lu

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).