From 796bd467fd9b9b60eaafbc6b837466034305b504 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 6 Sep 2017 12:31:52 +0000 Subject: [PATCH] re PR target/82108 (Wrong vectorized code generated for x86_64) 2017-09-06 Richard Biener 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 | 6 ++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/vect/pr82108.c | 47 +++++++++++++++++++++++++++++ gcc/tree-vect-stmts.c | 4 +-- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr82108.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 50c61063083..97ed8d33348 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-06 Richard Biener + + 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 PR tree-optimization/82078 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75f6f89f567..c7119a8edfd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-06 Richard Biener + + PR tree-optimization/82108 + * gcc.dg/vect/pr82108.c: New testcase. + 2017-09-06 Martin Jambor 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 index 00000000000..5b8faf1aefb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr82108.c @@ -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" } } */ diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 6b12f7a63aa..df93022f7cc 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -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 -- 2.30.2