re PR target/82108 (Wrong vectorized code generated for x86_64)
authorRichard Biener <rguenther@suse.de>
Wed, 6 Sep 2017 12:31:52 +0000 (12:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 6 Sep 2017 12:31:52 +0000 (12:31 +0000)
2017-09-06  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82108
* tree-vect-stmts.c (vectorizable_load): Fix pointer adjustment
for gap in the non-permutation SLP case.

* gcc.dg/vect/pr82108.c: New testcase.

From-SVN: r251790

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr82108.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 50c61063083e61aff4fb604e75bc61053478f872..97ed8d3334888261889ee9eaca033624f8bebc88 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82108
+       * tree-vect-stmts.c (vectorizable_load): Fix pointer adjustment
+       for gap in the non-permutation SLP case.
+
 2017-09-06  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/82078
index 75f6f89f567d20de52a008293f069ff095dd8247..c7119a8edfd212bbf41f9e42d108a1a2281510a7 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82108
+       * gcc.dg/vect/pr82108.c: New testcase.
+
 2017-09-06  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/82078
diff --git a/gcc/testsuite/gcc.dg/vect/pr82108.c b/gcc/testsuite/gcc.dg/vect/pr82108.c
new file mode 100644 (file)
index 0000000..5b8faf1
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target vect_float } */
+
+#include "tree-vect.h"
+
+void __attribute__((noinline,noclone))
+downscale_2 (const float* src, int src_n, float* dst)
+{
+  int i;
+
+  for (i = 0; i < src_n; i += 2) {
+      const float* a = src;
+      const float* b = src + 4;
+
+      dst[0] = (a[0] + b[0]) / 2;
+      dst[1] = (a[1] + b[1]) / 2;
+      dst[2] = (a[2] + b[2]) / 2;
+      dst[3] = (a[3] + b[3]) / 2;
+
+      src += 2 * 4;
+      dst +=     4;
+  }
+}
+
+int main ()
+{
+  const float in[4 * 4] = {
+      1, 2, 3, 4,
+      5, 6, 7, 8,
+
+      1, 2, 3, 4,
+      5, 6, 7, 8
+  };
+  float out[2 * 4];
+
+  check_vect ();
+
+  downscale_2 (in, 4, out);
+
+  if (out[0] != 3 || out[1] != 4 || out[2] != 5 || out[3] != 6
+      || out[4] != 3 || out[5] != 4 || out[6] != 5 || out[7] != 6)
+    __builtin_abort ();
+  
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
index 6b12f7a63aa3e2212bec45dfc08726d48798e4f4..df93022f7cc83ebfcbcb2060d58e0217cbaa084e 100644 (file)
@@ -7213,7 +7213,6 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     {
       first_stmt = GROUP_FIRST_ELEMENT (stmt_info);
       group_size = GROUP_SIZE (vinfo_for_stmt (first_stmt));
-      int group_gap = GROUP_GAP (vinfo_for_stmt (first_stmt));
       /* For SLP vectorization we directly vectorize a subchain
          without permutation.  */
       if (slp && ! SLP_TREE_LOAD_PERMUTATION (slp_node).exists ())
@@ -7256,7 +7255,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
          else
            {
              vec_num = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
-             group_gap_adj = group_gap;
+             group_gap_adj
+               = group_size - SLP_INSTANCE_GROUP_SIZE (slp_node_instance);
            }
        }
       else