This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible


Hi,

This patch allows usage of scalar masks for ymm and xmm registers when target supports it.  Bootstrapped and regtested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-11-26  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* config/i386/i386.c (ix86_get_mask_mode): Use scalar
	modes for 32 and 16 byte vectors when possible.

gcc/testsuite/

2015-11-26  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* gcc.dg/vect/vect-32-chars.c: New test.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 83749d5..d7c359f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -53443,7 +53443,8 @@ ix86_get_mask_mode (unsigned nunits, unsigned vector_size)
   unsigned elem_size = vector_size / nunits;
 
   /* Scalar mask case.  */
-  if (TARGET_AVX512F && vector_size == 64)
+  if ((TARGET_AVX512F && vector_size == 64)
+      || (TARGET_AVX512VL && (vector_size == 32 || vector_size == 16)))
     {
       if (elem_size == 4 || elem_size == 8 || TARGET_AVX512BW)
 	return smallest_mode_for_size (nunits, MODE_INT);
diff --git a/gcc/testsuite/gcc.dg/vect/vect-32-chars.c b/gcc/testsuite/gcc.dg/vect/vect-32-chars.c
new file mode 100644
index 0000000..0af5d2d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-32-chars.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx512bw -mavx512vl" { target { i?86-*-* x86_64-*-* } } } */
+
+char a[32];
+char b[32];
+char c[32];
+
+void test()
+{
+  int i = 0;
+  for (i = 0; i < 32; i++)
+    if (b[i] > 0)
+      a[i] = c[i];
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]