60 lines
2.0 KiB
Diff
60 lines
2.0 KiB
Diff
|
|
This backport contains 1 patch from gcc main stream tree.
|
||
|
|
The commit id of these patchs list as following in the order of time.
|
||
|
|
|
||
|
|
0001-tree-vect-slp.c-vect_analyze_slp-When-reduction-grou.patch
|
||
|
|
0214d31a48f867b9b00134cea7223d35ed7865aa
|
||
|
|
|
||
|
|
diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-9.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-9.c
|
||
|
|
new file mode 100644
|
||
|
|
index 00000000000..bee642ee999
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-9.c
|
||
|
|
@@ -0,0 +1,25 @@
|
||
|
|
+/* { dg-do compile } */
|
||
|
|
+/* { dg-require-effective-target vect_int_mult } */
|
||
|
|
+
|
||
|
|
+int
|
||
|
|
+bar (int *x, int a, int b, int n)
|
||
|
|
+{
|
||
|
|
+ x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__);
|
||
|
|
+ int sum1 = 0;
|
||
|
|
+ int sum2 = 0;
|
||
|
|
+ for (int i = 0; i < n; ++i)
|
||
|
|
+ {
|
||
|
|
+ /* Reduction chain vectorization fails here because of the
|
||
|
|
+ different operations but we can still vectorize both
|
||
|
|
+ reductions as SLP reductions, saving IVs. */
|
||
|
|
+ sum1 += x[2*i] - a;
|
||
|
|
+ sum1 += x[2*i+1] * b;
|
||
|
|
+ sum2 += x[2*i] - b;
|
||
|
|
+ sum2 += x[2*i+1] * a;
|
||
|
|
+ }
|
||
|
|
+ return sum1 + sum2;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */
|
||
|
|
+/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */
|
||
|
|
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
|
||
|
|
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
|
||
|
|
index e1061ede061..0af51197a84 100644
|
||
|
|
--- a/gcc/tree-vect-slp.c
|
||
|
|
+++ b/gcc/tree-vect-slp.c
|
||
|
|
@@ -2271,14 +2271,18 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
|
||
|
|
{
|
||
|
|
/* Dissolve reduction chain group. */
|
||
|
|
stmt_vec_info vinfo = first_element;
|
||
|
|
+ stmt_vec_info last = NULL;
|
||
|
|
while (vinfo)
|
||
|
|
{
|
||
|
|
stmt_vec_info next = REDUC_GROUP_NEXT_ELEMENT (vinfo);
|
||
|
|
REDUC_GROUP_FIRST_ELEMENT (vinfo) = NULL;
|
||
|
|
REDUC_GROUP_NEXT_ELEMENT (vinfo) = NULL;
|
||
|
|
+ last = vinfo;
|
||
|
|
vinfo = next;
|
||
|
|
}
|
||
|
|
STMT_VINFO_DEF_TYPE (first_element) = vect_internal_def;
|
||
|
|
+ /* It can be still vectorized as part of an SLP reduction. */
|
||
|
|
+ loop_vinfo->reductions.safe_push (last);
|
||
|
|
}
|
||
|
|
}
|