If we need to replicate the vectors but vec_num ends up with a
value of 0 because of alterations elsewhere in this function
then the final loop never terminates because no SLP_TREE_VEC_DEFS
are pushed by its inner loop. This change eases debugging.
gcc/ChangeLog:
* tree-vect-slp.cc (vect_create_constant_vectors):
Add an assertion to guard against the outer loop never
terminating because the inner loop is never entered.
---
gcc/tree-vect-slp.cc | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 10913576bd4..b0f83f7ca7e 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -11287,9 +11287,15 @@ vect_create_constant_vectors (vec_info *vinfo,
slp_tree op_node)
NUMBER_OF_SCALARS/NUNITS or NUNITS/NUMBER_OF_SCALARS, and hence we have
to replicate the vectors. */
while (number_of_vectors > SLP_TREE_VEC_DEFS (op_node).length ())
- for (i = 0; SLP_TREE_VEC_DEFS (op_node).iterate (i, &vop) && i < vec_num;
- i++)
- SLP_TREE_VEC_DEFS (op_node).quick_push (vop);
+ {
+ /* Guard against the outer loop never terminating because the
+ inner loop is never entered. */
+ gcc_checking_assert (vec_num > 0);
+
+ for (i = 0; SLP_TREE_VEC_DEFS (op_node).iterate (i, &vop) && i < vec_num;
+ i++)
+ SLP_TREE_VEC_DEFS (op_node).quick_push (vop);
+ }
}
/* Get the scalar definition of the Nth lane from SLP_NODE or NULL_TREE
--
2.43.0