tree-optimization/97753 - fix SLP induction vect
authorRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 13:03:14 +0000 (14:03 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 13:57:10 +0000 (14:57 +0100)
This fixes updating of the step vectors when filling up to group_size.

2020-11-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97753
* tree-vect-loop.c (vectorizable_induction): Fill vec_steps
when CSEing inside the group.

* gcc.dg/vect/pr97753.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr97753.c [new file with mode: 0644]
gcc/tree-vect-loop.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr97753.c b/gcc/testsuite/gcc.dg/vect/pr97753.c
new file mode 100644 (file)
index 0000000..e49a848
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+long a[6];
+void d(int c)
+{
+  for (; c; c++)
+    for (int b = 0; b < 8; b++)
+      ((char *)&a[c])[b] = c;
+}
index 0ba37540d5d1e1347fd63bdd56e2fb9dd5d539fa..977633a3ce347411e012c519ec24f0d3919e405a 100644 (file)
@@ -8068,8 +8068,11 @@ vectorizable_induction (loop_vec_info loop_vinfo,
          nivs = least_common_multiple (group_size,
                                        const_nunits) / const_nunits;
          for (; ivn < nivs; ++ivn)
-           SLP_TREE_VEC_STMTS (slp_node)
-             .quick_push (SLP_TREE_VEC_STMTS (slp_node)[0]);
+           {
+             SLP_TREE_VEC_STMTS (slp_node)
+               .quick_push (SLP_TREE_VEC_STMTS (slp_node)[0]);
+             vec_steps.safe_push (vec_steps[0]);
+           }
        }
 
       /* Re-use IVs when we can.  We are generating further vector