diff options
author | Richard Biener <rguenther@suse.de> | 2017-06-29 14:04:02 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-06-29 14:04:02 +0000 |
commit | 0630a4ecda602a90e978c3285cf1028e92ff5e8b (patch) | |
tree | cc5cefd595920573102156822f21d901451a76c1 /gcc | |
parent | f76b422479df586a93a0a2eaac748b59923d6e97 (diff) | |
download | gcc-0630a4ecda602a90e978c3285cf1028e92ff5e8b.zip gcc-0630a4ecda602a90e978c3285cf1028e92ff5e8b.tar.gz gcc-0630a4ecda602a90e978c3285cf1028e92ff5e8b.tar.bz2 |
tree-vect-loop.c (vect_analyze_scalar_cycles_1): Do not add reduction chains to LOOP_VINFO_REDUCTIONS.
2017-06-29 Richard Biener <rguenther@suse.de>
* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Do not add
reduction chains to LOOP_VINFO_REDUCTIONS.
* tree-vect-slp.c (vect_analyze_slp): Continue looking for
SLP reductions after processing reduction chains.
* gcc.dg/vect/slp-reduc-8.c: New testcase.
From-SVN: r249785
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/slp-reduc-8.c | 48 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 6 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 21 |
5 files changed, 69 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f230dad..bc58f15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-06-29 Richard Biener <rguenther@suse.de> + + * tree-vect-loop.c (vect_analyze_scalar_cycles_1): Do not add + reduction chains to LOOP_VINFO_REDUCTIONS. + * tree-vect-slp.c (vect_analyze_slp): Continue looking for + SLP reductions after processing reduction chains. + 2017-06-29 Nathan Sidwell <nathan@acm.org> * builtins.c (fold_builtin_FUNCTION): Use diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70651d5..3dbd4e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-06-29 Richard Biener <rguenther@suse.de> + + * gcc.dg/vect/slp-reduc-8.c: New testcase. + 2017-06-29 Nathan Sidwell <nathan@acm.org> * g++.dg/cpp1y/builtin_FUNCTION.C: New. diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-8.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-8.c new file mode 100644 index 0000000..618c800 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-8.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +static int a[512], b[512]; + +void __attribute__((noinline,noclone)) +foo (int *sum1p, int *sum2p, int *sum3p) +{ + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + /* Check that we vectorize a reduction chain and a SLP reduction + at the same time. */ + for (int i = 0; i < 256; ++i) + { + sum1 += a[2*i]; + sum1 += a[2*i + 1]; + sum2 += b[2*i]; + sum3 += b[2*i + 1]; + } + *sum1p = sum1; + *sum2p = sum2; + *sum3p = sum3; +} + +int main() +{ + check_vect (); + + for (int i = 0; i < 256; ++i) + { + a[2*i] = i; + a[2*i + 1] = i/2; + b[2*i] = i + 1; + b[2*i + 1] = i/2 + 1; + __asm__ volatile ("" : : : "memory"); + } + int sum1, sum2, sum3; + foo (&sum1, &sum2, &sum3); + if (sum1 != 48896 || sum2 != 32896 || sum3 != 16512) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index a055836..32a5caa 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -890,8 +890,10 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop) STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) = vect_reduction_def; /* Store the reduction cycles for possible vectorization in - loop-aware SLP. */ - LOOP_VINFO_REDUCTIONS (loop_vinfo).safe_push (reduc_stmt); + loop-aware SLP if it was not detected as reduction + chain. */ + if (! GROUP_FIRST_ELEMENT (vinfo_for_stmt (reduc_stmt))) + LOOP_VINFO_REDUCTIONS (loop_vinfo).safe_push (reduc_stmt); } } } diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index eb7bc55..9e7a20d 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2102,15 +2102,13 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) { unsigned int i; gimple *first_element; - bool ok = false; if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "=== vect_analyze_slp ===\n"); /* Find SLP sequences starting from groups of grouped stores. */ FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element) - if (vect_analyze_slp_instance (vinfo, first_element, max_tree_size)) - ok = true; + vect_analyze_slp_instance (vinfo, first_element, max_tree_size); if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo)) { @@ -2118,22 +2116,15 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) { /* Find SLP sequences starting from reduction chains. */ FOR_EACH_VEC_ELT (loop_vinfo->reduction_chains, i, first_element) - if (vect_analyze_slp_instance (vinfo, first_element, + if (! vect_analyze_slp_instance (vinfo, first_element, max_tree_size)) - ok = true; - else - return false; - - /* Don't try to vectorize SLP reductions if reduction chain was - detected. */ - return ok; + return false; } /* Find SLP sequences starting from groups of reductions. */ - if (loop_vinfo->reductions.length () > 1 - && vect_analyze_slp_instance (vinfo, loop_vinfo->reductions[0], - max_tree_size)) - ok = true; + if (loop_vinfo->reductions.length () > 1) + vect_analyze_slp_instance (vinfo, loop_vinfo->reductions[0], + max_tree_size); } return true; |