public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Uros Bizjak <uros@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1266] i386: Add init pattern for V4QI vectors [PR100637]
Date: Mon,  7 Jun 2021 21:00:40 +0000 (GMT)	[thread overview]
Message-ID: <20210607210040.B36D5388982E@sourceware.org> (raw)

https://gcc.gnu.org/g:64735dc923e0a1a2e04c5313471d91ca8b954e9a

commit r12-1266-g64735dc923e0a1a2e04c5313471d91ca8b954e9a
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Mon Jun 7 22:58:15 2021 +0200

    i386: Add init pattern for V4QI vectors [PR100637]
    
    2021-06-07  Uroš Bizjak  <ubizjak@gmail.com>
    
    gcc/
            PR target/100637
            * config/i386/i386-expand.c (ix86_expand_vector_init_duplicate):
            Handle V4QI mode.
            (ix86_expand_vector_init_one_nonzero): Ditto.
            (ix86_expand_vector_init_one_var): Ditto.
            (ix86_expand_vector_init_general): Ditto.
            * config/i386/mmx.md (vec_initv4qiqi): New expander.
    
    gcc/testsuite/
    
            PR target/100637
            * gcc.target/i386/pr100637-5b.c: New test.
            * gcc.target/i386/pr100637-5w.c: Ditto.

Diff:
---
 gcc/config/i386/i386-expand.c               |  9 +++++++++
 gcc/config/i386/mmx.md                      | 12 +++++++++++-
 gcc/testsuite/gcc.target/i386/pr100637-5b.c | 25 +++++++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/pr100637-5w.c | 25 +++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index fb0676f1158..c3ce21b4387 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -13733,6 +13733,7 @@ ix86_expand_vector_init_duplicate (bool mmx_ok, machine_mode mode,
       return false;
 
     case E_V8QImode:
+    case E_V4QImode:
       if (!mmx_ok)
 	return false;
       goto widen;
@@ -13878,6 +13879,9 @@ ix86_expand_vector_init_one_nonzero (bool mmx_ok, machine_mode mode,
     case E_V4HImode:
       use_vector_set = TARGET_SSE || TARGET_3DNOW_A;
       break;
+    case E_V4QImode:
+      use_vector_set = TARGET_SSE4_1;
+      break;
     case E_V32QImode:
     case E_V16HImode:
       use_vector_set = TARGET_AVX;
@@ -14086,6 +14090,10 @@ ix86_expand_vector_init_one_var (bool mmx_ok, machine_mode mode,
 	break;
       wmode = V4HImode;
       goto widen;
+    case E_V4QImode:
+      if (TARGET_SSE4_1)
+	break;
+      wmode = V2HImode;
     widen:
       /* There's no way to set one QImode entry easily.  Combine
 	 the variable value with its adjacent constant value, and
@@ -14535,6 +14543,7 @@ quarter:
     case E_V8QImode:
 
     case E_V2HImode:
+    case E_V4QImode:
       break;
 
     default:
diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index c3fd2805f25..0a17a54fad5 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -3369,7 +3369,17 @@
    (match_operand 1)]
   "TARGET_SSE2"
 {
-  ix86_expand_vector_init (false, operands[0],
+  ix86_expand_vector_init (TARGET_MMX_WITH_SSE, operands[0],
+			   operands[1]);
+  DONE;
+})
+
+(define_expand "vec_initv4qiqi"
+  [(match_operand:V2HI 0 "register_operand")
+   (match_operand 1)]
+  "TARGET_SSE2"
+{
+  ix86_expand_vector_init (TARGET_MMX_WITH_SSE, operands[0],
 			   operands[1]);
   DONE;
 })
diff --git a/gcc/testsuite/gcc.target/i386/pr100637-5b.c b/gcc/testsuite/gcc.target/i386/pr100637-5b.c
new file mode 100644
index 00000000000..3e6cc8ff975
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr100637-5b.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+typedef char S;
+typedef S V __attribute__((vector_size(4 * sizeof(S))));
+
+V duplicate (S a)
+{
+  return (V) { a, a, a, a };
+}
+
+V one_nonzero (S a)
+{
+  return (V) { 0, a };
+}
+
+V one_var (S a)
+{
+  return (V) { 1, a };
+}
+
+V general (S a, S b, S c, S d)
+{
+  return (V) { a, b, c, d };
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr100637-5w.c b/gcc/testsuite/gcc.target/i386/pr100637-5w.c
new file mode 100644
index 00000000000..3f677385c16
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr100637-5w.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+typedef short S;
+typedef S V __attribute__((vector_size(2 * sizeof(S))));
+
+V duplicate (S a)
+{
+  return (V) { a, a };
+}
+
+V one_nonzero (S a)
+{
+  return (V) { 0, a };
+}
+
+V one_var (S a)
+{
+  return (V) { 1, a };
+}
+
+V general (S a, S b)
+{
+  return (V) { a, b };
+}


                 reply	other threads:[~2021-06-07 21:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210607210040.B36D5388982E@sourceware.org \
    --to=uros@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).