aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-16 15:13:32 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-16 15:13:32 +0000
commitfb2f98bb6c5e016514bc3b93f8f1550e39e7d28f (patch)
tree202d41236e118c3135fd0ed5979c117e2ca2e0dd /gcc
parente57d9a82996838e73cc5470a1f3367e9c616b947 (diff)
downloadgcc-fb2f98bb6c5e016514bc3b93f8f1550e39e7d28f.zip
gcc-fb2f98bb6c5e016514bc3b93f8f1550e39e7d28f.tar.gz
gcc-fb2f98bb6c5e016514bc3b93f8f1550e39e7d28f.tar.bz2
Two fixes for live-out SLP inductions (PR 83857)
vect_analyze_loop_operations was calling vectorizable_live_operation for all live-out phis, which led to a bogus ncopies calculation in the pure SLP case. I think v_a_l_o should only be passing phis that are vectorised using normal loop vectorisation, since vect_slp_analyze_node_operations handles the SLP side (and knows the correct slp_index and slp_node arguments to pass in, via vect_analyze_stmt). With that fixed we hit an older bug that vectorizable_live_operation didn't handle live-out SLP inductions. Fixed by using gimple_phi_result rather than gimple_get_lhs for phis. 2018-01-16 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/83857 * tree-vect-loop.c (vect_analyze_loop_operations): Don't call vectorizable_live_operation for pure SLP statements. (vectorizable_live_operation): Handle PHIs. gcc/testsuite/ PR tree-optimization/83857 * gcc.dg/vect/pr83857.c: New test. From-SVN: r256747
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr83857.c30
-rw-r--r--gcc/tree-vect-loop.c11
4 files changed, 51 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 055e924..979f5ae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-16 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/83857
+ * tree-vect-loop.c (vect_analyze_loop_operations): Don't call
+ vectorizable_live_operation for pure SLP statements.
+ (vectorizable_live_operation): Handle PHIs.
+
2018-01-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/83867
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ae57828..0e24ae4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-16 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/83857
+ * gcc.dg/vect/pr83857.c: New test.
+
2018-01-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/83867
diff --git a/gcc/testsuite/gcc.dg/vect/pr83857.c b/gcc/testsuite/gcc.dg/vect/pr83857.c
new file mode 100644
index 0000000..92e648b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr83857.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ffast-math" } */
+
+#define N 100
+
+double __attribute__ ((noinline, noclone))
+f (double *x, double y)
+{
+ double a = 0;
+ for (int i = 0; i < N; ++i)
+ {
+ a += y;
+ x[i * 2] += a;
+ x[i * 2 + 1] += a;
+ }
+ return a - y;
+}
+
+double x[N * 2];
+
+int
+main (void)
+{
+ if (f (x, 5) != (N - 1) * 5)
+ __builtin_abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target vect_double } } } */
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_double } } } */
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 64b9ce3..79b8186 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -1851,7 +1851,10 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
ok = vectorizable_reduction (phi, NULL, NULL, NULL, NULL);
}
- if (ok && STMT_VINFO_LIVE_P (stmt_info))
+ /* SLP PHIs are tested by vect_slp_analyze_node_operations. */
+ if (ok
+ && STMT_VINFO_LIVE_P (stmt_info)
+ && !PURE_SLP_STMT (stmt_info))
ok = vectorizable_live_operation (phi, NULL, NULL, -1, NULL);
if (!ok)
@@ -8217,7 +8220,11 @@ vectorizable_live_operation (gimple *stmt,
gcc_assert (!LOOP_VINFO_FULLY_MASKED_P (loop_vinfo));
/* Get the correct slp vectorized stmt. */
- vec_lhs = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[vec_entry]);
+ gimple *vec_stmt = SLP_TREE_VEC_STMTS (slp_node)[vec_entry];
+ if (gphi *phi = dyn_cast <gphi *> (vec_stmt))
+ vec_lhs = gimple_phi_result (phi);
+ else
+ vec_lhs = gimple_get_lhs (vec_stmt);
/* Get entry to use. */
bitstart = bitsize_int (vec_index);