public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/98308 - set vector type for mask of masked load
@ 2021-01-04 13:39 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-01-04 13:39 UTC (permalink / raw)
  To: gcc-patches

This makes sure to set the vector type on an invariant mask argument
for a masked load and SLP.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98308
	* tree-vect-stmts.c (vectorizable_load): Set invariant mask
	SLP vectype.

	* gcc.dg/vect/pr98308.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/pr98308.c | 16 ++++++++++++++++
 gcc/tree-vect-stmts.c               | 11 +++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/vect/pr98308.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr98308.c b/gcc/testsuite/gcc.dg/vect/pr98308.c
new file mode 100644
index 00000000000..7d717b1ee51
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr98308.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+/* { dg-additional-options "-march=skylake-avx512" { target avx512f } } */
+
+extern unsigned long long int arr_86[];
+extern unsigned long long int arr_87[][15];
+
+void test(_Bool a, unsigned short c[][15], unsigned char d[])
+{
+  for (short h = 0; h < 10; h++)
+    for (char i = 0; i < 15; i += 2)
+      {
+	arr_86[0] = d[0];
+	arr_87[h][0] = a ? c[h][i] : 0;
+      }
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9e9467531a3..54fb68b216f 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -8563,6 +8563,17 @@ vectorizable_load (vec_info *vinfo,
 
   if (!vec_stmt) /* transformation not required.  */
     {
+      if (slp_node
+	  && mask
+	  && !vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+						mask_vectype))
+	{
+	  if (dump_enabled_p ())
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "incompatible vector types for invariants\n");
+	  return false;
+	}
+
       if (!slp)
 	STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) = memory_access_type;
 
-- 
2.26.2

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

only message in thread, other threads:[~2021-01-04 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 13:39 [PATCH] tree-optimization/98308 - set vector type for mask of masked load Richard Biener

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