public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible
@ 2015-11-26 10:48 Ilya Enkovich
  2015-12-10 11:25 ` Ilya Enkovich
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Enkovich @ 2015-11-26 10:48 UTC (permalink / raw)
  To: gcc-patches

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-*-* } } } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible
  2015-11-26 10:48 [PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible Ilya Enkovich
@ 2015-12-10 11:25 ` Ilya Enkovich
  2015-12-11  7:15   ` Kirill Yukhin
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Enkovich @ 2015-12-10 11:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Kirill Yukhin

Ping

2015-11-26 13:33 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> 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-*-* } } } } */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible
  2015-12-10 11:25 ` Ilya Enkovich
@ 2015-12-11  7:15   ` Kirill Yukhin
  0 siblings, 0 replies; 3+ messages in thread
From: Kirill Yukhin @ 2015-12-11  7:15 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

Hi,
On 10 Dec 14:25, Ilya Enkovich wrote:
> Ping
> 
> 2015-11-26 13:33 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> > 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?
Impact is not high. Your patch is OK for trunk.

> >
> > Thanks,
> > Ilya

--
Thanks, K

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-11  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 10:48 [PATCH, i386] Use scalar mask for 16-byte and 32-byte vectors when possible Ilya Enkovich
2015-12-10 11:25 ` Ilya Enkovich
2015-12-11  7:15   ` Kirill Yukhin

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