aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-06 12:29:47 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-06 12:29:47 +0000
commit8ec5b16a9a3dbd6d825596c22f1bc32646de28fe (patch)
treebe1152f63c2f69541e90e1c894d5b1089a6adbac
parent72d6aeecd95ec49fff1d258e4631167a03351cbb (diff)
downloadgcc-8ec5b16a9a3dbd6d825596c22f1bc32646de28fe.zip
gcc-8ec5b16a9a3dbd6d825596c22f1bc32646de28fe.tar.gz
gcc-8ec5b16a9a3dbd6d825596c22f1bc32646de28fe.tar.bz2
Check the VF is small enough for an epilogue loop
The number of iterations of an epilogue loop is always smaller than the VF of the main loop. vect_analyze_loop_costing was taking this into account when deciding whether the loop is cheap enough to vectorise, but that has no effect with the unlimited cost model. We need to use a separate check for correctness as well. This can happen if the sizes returned by autovectorize_vector_sizes happen to be out of order, e.g. because the target prefers smaller vectors. It can also happen with later patches if two vectorisation attempts happen to end up with the same VF. 2019-11-06 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-loop.c (vect_analyze_loop_2): When vectorizing an epilogue loop, make sure that the VF is small enough or that the epilogue loop can be fully-masked. From-SVN: r277880
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-vect-loop.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a8a8968..d04b6be 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2019-11-06 Richard Sandiford <richard.sandiford@arm.com>
+ * tree-vect-loop.c (vect_analyze_loop_2): When vectorizing an
+ epilogue loop, make sure that the VF is small enough or that
+ the epilogue loop can be fully-masked.
+
+2019-11-06 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-vect-loop.c (vect_analyze_loop): Break out of the main
loop when we've finished, rather than returning directly from
the loop. Use a local variable to track whether we're still
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f804904..ec0bd2c 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2143,6 +2143,16 @@ start_over:
" support peeling for gaps.\n");
}
+ /* If we're vectorizing an epilogue loop, we either need a fully-masked
+ loop or a loop that has a lower VF than the main loop. */
+ if (LOOP_VINFO_EPILOGUE_P (loop_vinfo)
+ && !LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)
+ && maybe_ge (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
+ LOOP_VINFO_VECT_FACTOR (orig_loop_vinfo)))
+ return opt_result::failure_at (vect_location,
+ "Vectorization factor too high for"
+ " epilogue loop.\n");
+
/* Check the costings of the loop make vectorizing worthwhile. */
res = vect_analyze_loop_costing (loop_vinfo);
if (res < 0)