aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr101445.c28
-rw-r--r--gcc/tree-vect-stmts.c6
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr101445.c b/gcc/testsuite/gcc.dg/vect/pr101445.c
new file mode 100644
index 0000000..f8a6e9c
--- /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 e590f34..3980f09 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -9759,6 +9759,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);
@@ -9772,6 +9775,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);