re PR tree-optimization/91201 (SIMD not generated for horizontal sum of bytes in...
authorJakub Jelinek <jakub@redhat.com>
Fri, 2 Aug 2019 08:28:31 +0000 (10:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 2 Aug 2019 08:28:31 +0000 (10:28 +0200)
PR tree-optimization/91201
* config/i386/i386-expand.c (ix86_expand_vector_extract): For elt == 0
V16QImode extraction without sse4.1 try to use V4SImode lowpart
extraction.

* gcc.target/i386/sse2-pr91201-3.c: New test.
* gcc.target/i386/sse2-pr91201-4.c: New test.
* gcc.target/i386/sse2-pr91201-5.c: New test.
* gcc.target/i386/sse2-pr91201-6.c: New test.

From-SVN: r273998

gcc/ChangeLog
gcc/config/i386/i386-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/sse2-pr91201-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/sse2-pr91201-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/sse2-pr91201-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/sse2-pr91201-6.c [new file with mode: 0644]

index e5c3a59cbb5820ea0785559f5971531a11dfe751..1909d87a330e73db8b5524fc4ea3ad1defaa986c 100644 (file)
@@ -1,3 +1,10 @@
+2019-08-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/91201
+       * config/i386/i386-expand.c (ix86_expand_vector_extract): For elt == 0
+       V16QImode extraction without sse4.1 try to use V4SImode lowpart
+       extraction.
+
 2019-08-01  Martin Sebor  <msebor@redhat.com>
 
        PR c++/90947
index 7e12a86a75fb49e6feff8c1aeea7421c3f9b319a..6e4ae5077f56918c3b02a173d67dbb653795e2fd 100644 (file)
@@ -14706,6 +14706,17 @@ ix86_expand_vector_extract (bool mmx_ok, rtx target, rtx vec, int elt)
 
     case E_V16QImode:
       use_vec_extr = TARGET_SSE4_1;
+      if (!use_vec_extr
+         && TARGET_SSE2
+         && elt == 0
+         && (optimize_insn_for_size_p () || TARGET_INTER_UNIT_MOVES_FROM_VEC))
+       {
+         tmp = gen_reg_rtx (SImode);
+         ix86_expand_vector_extract (false, tmp, gen_lowpart (V4SImode, vec),
+                                     0);
+         emit_insn (gen_rtx_SET (target, gen_lowpart (QImode, tmp)));
+         return;
+       }
       break;
 
     case E_V8SFmode:
index 72e258b3506735d0c14f335df9dcc27b54bf3e13..fdc8f0848d081d715a7f97b11ebcd044fb715c07 100644 (file)
@@ -1,3 +1,11 @@
+2019-08-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/91201
+       * gcc.target/i386/sse2-pr91201-3.c: New test.
+       * gcc.target/i386/sse2-pr91201-4.c: New test.
+       * gcc.target/i386/sse2-pr91201-5.c: New test.
+       * gcc.target/i386/sse2-pr91201-6.c: New test.
+
 2019-08-02  Martin Liska  <mliska@suse.cz>
 
        * g++.dg/cpp1y/new2.C: New test.
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr91201-3.c b/gcc/testsuite/gcc.target/i386/sse2-pr91201-3.c
new file mode 100644 (file)
index 0000000..1fc5834
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR tree-optimization/91201 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2 -mno-sse3 -mtune=generic -masm=att" } */
+/* { dg-final { scan-assembler "\tmovd\t%xmm0, %eax" } } */
+/* { dg-final { scan-assembler-not "\\(%" } } */
+
+typedef unsigned char V __attribute__((vector_size (16)));
+
+unsigned char
+foo (V x)
+{
+  return x[0];
+}
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr91201-4.c b/gcc/testsuite/gcc.target/i386/sse2-pr91201-4.c
new file mode 100644 (file)
index 0000000..48044c6
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR tree-optimization/91201 */
+/* { dg-do compile } */
+/* { dg-options "-Os -msse2 -mno-sse3 -mtune=generic -masm=att" } */
+/* { dg-final { scan-assembler "\tmovd\t%xmm0, %eax" } } */
+/* { dg-final { scan-assembler-not "\\(%" } } */
+
+typedef unsigned char V __attribute__((vector_size (16)));
+
+unsigned char
+foo (V x)
+{
+  return x[0];
+}
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr91201-5.c b/gcc/testsuite/gcc.target/i386/sse2-pr91201-5.c
new file mode 100644 (file)
index 0000000..13c1954
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR tree-optimization/91201 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2 -mno-sse3 -mtune=k8 -masm=att" } */
+/* { dg-final { scan-assembler-not "\tmovd\t%xmm0, %eax" } } */
+/* { dg-final { scan-assembler "\tmov(zbl|b)\t\[^\n\r]*\\(%" } } */
+
+typedef unsigned char V __attribute__((vector_size (16)));
+
+unsigned char
+foo (V x)
+{
+  return x[0];
+}
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr91201-6.c b/gcc/testsuite/gcc.target/i386/sse2-pr91201-6.c
new file mode 100644 (file)
index 0000000..2997bfd
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR tree-optimization/91201 */
+/* { dg-do compile } */
+/* { dg-options "-Os -msse2 -mno-sse3 -mtune=k8 -masm=att" } */
+/* { dg-final { scan-assembler "\tmovd\t%xmm0, %eax" } } */
+/* { dg-final { scan-assembler-not "\\(%" } } */
+
+typedef unsigned char V __attribute__((vector_size (16)));
+
+unsigned char
+foo (V x)
+{
+  return x[0];
+}