https://gcc.gnu.org/g:c7cfde26c9669cec341b4856bb6640035236ff66

commit r17-3817-gc7cfde26c9669cec341b4856bb6640035236ff66
Author: Christopher Bazley <[email protected]>
Date:   Thu Jul 30 14:56:44 2026 +0000

    vect: Guard against infinite loop in vect_create_constant_vectors
    
    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.

Diff:
---
 gcc/tree-vect-slp.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 59148daebfe9..63c8731fa2b2 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -11089,6 +11089,8 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree 
op_node)
   /* Since the vectors are created in the reverse order, we should invert
      them.  */
   vec_num = voprnds.length ();
+  gcc_checking_assert (vec_num > 0);
+
   for (j = vec_num; j != 0; j--)
     {
       vop = voprnds[j - 1];

Reply via email to