]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Add init pattern for V4QI vectors [PR100637]
authorUros Bizjak <ubizjak@gmail.com>
Mon, 7 Jun 2021 20:58:15 +0000 (22:58 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Mon, 7 Jun 2021 21:00:14 +0000 (23:00 +0200)
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.

gcc/config/i386/i386-expand.c
gcc/config/i386/mmx.md
gcc/testsuite/gcc.target/i386/pr100637-5b.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr100637-5w.c [new file with mode: 0644]

index fb0676f11589e6787493a0cc7438c283f9da6d3d..c3ce21b43878b7477cc44ec9d810e2f1c84ff122 100644 (file)
@@ -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:
index c3fd2805f252b4447a5c407c5a85d342617c4332..0a17a54fad5ea3f4bfe753ad56b99244b53d8ac3 100644 (file)
    (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 (file)
index 0000000..3e6cc8f
--- /dev/null
@@ -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 (file)
index 0000000..3f67738
--- /dev/null
@@ -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 };
+}