summaryrefslogtreecommitdiff
path: root/0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch
diff options
context:
space:
mode:
Diffstat (limited to '0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch')
-rw-r--r--0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch b/0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch
new file mode 100644
index 0000000..ffe5327
--- /dev/null
+++ b/0007-Vect-Enable-skipping-vectorization-on-reduction-chai.patch
@@ -0,0 +1,68 @@
+From 07033bcc5b9e4c03846cd84b4587cd493fcf7d53 Mon Sep 17 00:00:00 2001
+From: zhoukaipeng <zhoukaipeng3@huawei.com>
+Date: Wed, 14 Jul 2021 11:24:06 +0800
+Subject: [PATCH 07/13] [Vect] Enable skipping vectorization on reduction
+ chains
+
+Sometimes either vectorization on reduction chains or reductions is
+possible. But the latter is better. The option "-ftree-vect-analyze
+-slp-group" skips the former.
+
+diff --git a/gcc/common.opt b/gcc/common.opt
+index 8eb05570418..55d4eb5a351 100644
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -2968,6 +2968,10 @@ ftree-slp-vectorize
+ Common Report Var(flag_tree_slp_vectorize) Optimization EnabledBy(ftree-vectorize)
+ Enable basic block vectorization (SLP) on trees.
+
++ftree-vect-analyze-slp-group
++Common Report Var(flag_tree_slp_group) Init(0)
++Disable SLP vectorization for reduction chain on tree.
++
+ fvect-cost-model=
+ Common Joined RejectNegative Enum(vect_cost_model) Var(flag_vect_cost_model) Init(VECT_COST_MODEL_DEFAULT) Optimization
+ -fvect-cost-model=[unlimited|dynamic|cheap] Specifies the cost model for vectorization.
+diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-12.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-12.c
+new file mode 100644
+index 00000000000..913f1ef28df
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-12.c
+@@ -0,0 +1,20 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -funsafe-math-optimizations -fno-tree-reassoc -ftree-vect-analyze-slp-group" } */
++void f(double *a, double *res, double m) {
++ double res1, res0;
++ res1 = 0;
++ res0 = 0;
++ for (int i = 0; i < 1000; i+=8) {
++ res0 += a[i] * m;
++ res1 += a[i+1] * m;
++ res0 += a[i+2] * m;
++ res1 += a[i+3] * m;
++ res0 += a[i+4] * m;
++ res1 += a[i+5] * m;
++ res0 += a[i+6] * m;
++ res1 += a[i+7] * m;
++ }
++ res[0] += res0;
++ res[1] += res1;
++}
++/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
+diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
+index adc579ff544..476b3237054 100644
+--- a/gcc/tree-vect-slp.c
++++ b/gcc/tree-vect-slp.c
+@@ -2480,7 +2480,8 @@ 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, bst_map, first_element,
++ if (flag_tree_slp_group
++ || ! vect_analyze_slp_instance (vinfo, bst_map, first_element,
+ max_tree_size))
+ {
+ /* Dissolve reduction chain group. */
+--
+2.21.0.windows.1
+