public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8736] tree-optimization/101445 - fix negative stride SLP vect with gaps
@ 2021-07-14 11:09 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-07-14 11:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1eee5fa556432fb6eab3a479c95609c5f3791ccb
commit r11-8736-g1eee5fa556432fb6eab3a479c95609c5f3791ccb
Author: Richard Biener <rguenther@suse.de>
Date: Wed Jul 14 11:06:58 2021 +0200
tree-optimization/101445 - fix negative stride SLP vect with gaps
The following fixes the IV adjustment for the gap in a negative
stride SLP vectorization. The adjustment was in the wrong direction,
now fixes as in the patch.
2021-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/101445
* tree-vect-stmts.c (vectorizable_load): Do the gap adjustment
of the IV in the correct direction for negative stride
accesses.
* gcc.dg/vect/pr101445.c: New testcase.
(cherry picked from commit a967a3efd39280fe3f5774e45490e991f8e99059)
Diff:
---
gcc/testsuite/gcc.dg/vect/pr101445.c | 28 ++++++++++++++++++++++++++++
gcc/tree-vect-stmts.c | 6 ++++++
2 files changed, 34 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/vect/pr101445.c b/gcc/testsuite/gcc.dg/vect/pr101445.c
new file mode 100644
index 00000000000..f8a6e9ce6f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr101445.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+int a[35] = { 1, 1, 3 };
+
+void __attribute__((noipa))
+foo ()
+{
+ for (int b = 4; b >= 0; b--)
+ {
+ int tem = a[b * 5 + 3 + 1];
+ a[b * 5 + 3] = tem;
+ a[b * 5 + 2] = tem;
+ a[b * 5 + 1] = tem;
+ a[b * 5 + 0] = tem;
+ }
+}
+
+int main()
+{
+ check_vect ();
+ foo ();
+ for (int d = 0; d < 25; d++)
+ if (a[d] != 0)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index bd2a1c89e67..2c86f06a57b 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -9737,6 +9737,9 @@ vectorizable_load (vec_info *vinfo,
poly_wide_int bump_val
= (wi::to_wide (TYPE_SIZE_UNIT (elem_type))
* group_gap_adj);
+ if (tree_int_cst_sgn
+ (vect_dr_behavior (vinfo, dr_info)->step) == -1)
+ bump_val = -bump_val;
tree bump = wide_int_to_tree (sizetype, bump_val);
dataref_ptr = bump_vector_ptr (vinfo, dataref_ptr, ptr_incr,
gsi, stmt_info, bump);
@@ -9750,6 +9753,9 @@ vectorizable_load (vec_info *vinfo,
poly_wide_int bump_val
= (wi::to_wide (TYPE_SIZE_UNIT (elem_type))
* group_gap_adj);
+ if (tree_int_cst_sgn
+ (vect_dr_behavior (vinfo, dr_info)->step) == -1)
+ bump_val = -bump_val;
tree bump = wide_int_to_tree (sizetype, bump_val);
dataref_ptr = bump_vector_ptr (vinfo, dataref_ptr, ptr_incr, gsi,
stmt_info, bump);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-14 11:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 11:09 [gcc r11-8736] tree-optimization/101445 - fix negative stride SLP vect with gaps Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).