This avoids (again) the C++ pitfall of pushing a reference to
sth being reallocated.
2021-04-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/99947
* tree-vect-loop.c (vectorizable_induction): Pre-allocate
steps vector to avoid pushing elements from the reallocated
vector.
* gcc.dg/torture/pr99947.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+
+int a, b, d, e;
+short c;
+void f() {
+ for (; e; e++) {
+ int g = 6;
+ for (; g > 2; g--) {
+ int i = -8;
+ while (i < 20) {
+ i += 5;
+ a += b;
+ }
+ c *= d;
+ }
+ b--;
+ }
+}
/* Fill up to the number of vectors we need for the whole group. */
nivs = least_common_multiple (group_size,
const_nunits) / const_nunits;
+ vec_steps.reserve (nivs-ivn);
for (; ivn < nivs; ++ivn)
{
SLP_TREE_VEC_STMTS (slp_node)
.quick_push (SLP_TREE_VEC_STMTS (slp_node)[0]);
- vec_steps.safe_push (vec_steps[0]);
+ vec_steps.quick_push (vec_steps[0]);
}
}