summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-12-29 09:28:34 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-12-29 09:28:34 +0000
commitf0657516067909d688dc2424a876c1c894cbc182 (patch)
tree1d475e6edb4ea3d64f91a2f0d8e0a152b4eeaf85
parent4bbd661e9937d46cc66182423f1946761a4f31c9 (diff)
downloadgcc-f0657516067909d688dc2424a876c1c894cbc182.tar.gz
Unshare DR_STEP before gimplifying it
In this testcase we use an unmasked SVE loop with an Advanced SIMD epilogue (because we don't yet support fully-masked downward loops). The main loop uses a gather load for the strided access while the epilogue loop builds the access from scalars instead. In both cases we gimplify expressions based on the DR_STEP and insert them in the loop preheader. The problem was that the gather load code didn't copy the DR_STEP before gimplifying it, meaning that the epilogue loop tried to reuse a result from the (non-dominating) main loop preheader. It looks at first glance like there could be other instances of this too, but this patch just deals with the gather/scatter case. 2019-12-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-stmts.c (vect_get_strided_load_store_ops): Copy DR_STEP before gimplifying it. gcc/testsuite/ * gcc.dg/vect/vect-strided-epilogue-1.c: New test. From-SVN: r279753
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-strided-epilogue-1.c8
-rw-r--r--gcc/tree-vect-stmts.c4
4 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fc7af987cdf..1630efd1ac0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2019-12-29 Richard Sandiford <richard.sandiford@arm.com>
+ * tree-vect-stmts.c (vect_get_strided_load_store_ops): Copy
+ DR_STEP before gimplifying it.
+
+2019-12-29 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-vect-stmts.c (vectorizable_condition): For extract-last
reductions, check that the target supports the required comparison
operation.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2e0f36410df..d3079d30304 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2019-12-29 Richard Sandiford <richard.sandiford@arm.com>
+ * gcc.dg/vect/vect-strided-epilogue-1.c: New test.
+
+2019-12-29 Richard Sandiford <richard.sandiford@arm.com>
+
* gcc.dg/vect/vect-cond-12.c: New test.
2019-12-27 Richard Sandiford <richard.sandiford@arm.com>
diff --git a/gcc/testsuite/gcc.dg/vect/vect-strided-epilogue-1.c b/gcc/testsuite/gcc.dg/vect/vect-strided-epilogue-1.c
new file mode 100644
index 00000000000..e316706204f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-strided-epilogue-1.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+void
+f (int *x, short *y, int z)
+{
+ for (int i = 0; i < 0x82; ++i)
+ x[-i] += x[z * i];
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index feb0b7eb7b3..d4468083cd0 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2993,7 +2993,7 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info,
gimple_seq stmts;
tree bump = size_binop (MULT_EXPR,
- fold_convert (sizetype, DR_STEP (dr)),
+ fold_convert (sizetype, unshare_expr (DR_STEP (dr))),
size_int (TYPE_VECTOR_SUBPARTS (vectype)));
*dataref_bump = force_gimple_operand (bump, &stmts, true, NULL_TREE);
if (stmts)
@@ -3005,7 +3005,7 @@ vect_get_strided_load_store_ops (stmt_vec_info stmt_info,
offset_type = TREE_TYPE (gs_info->offset_vectype);
/* Calculate X = DR_STEP / SCALE and convert it to the appropriate type. */
- tree step = size_binop (EXACT_DIV_EXPR, DR_STEP (dr),
+ tree step = size_binop (EXACT_DIV_EXPR, unshare_expr (DR_STEP (dr)),
ssize_int (gs_info->scale));
step = fold_convert (offset_type, step);
step = force_gimple_operand (step, &stmts, true, NULL_TREE);