https://gcc.gnu.org/g:40f7fbeddb1333e2787f0edd522d1dcd07ff5b0a
commit r17-3806-g40f7fbeddb1333e2787f0edd522d1dcd07ff5b0a Author: Richard Biener <[email protected]> Date: Tue Sep 1 09:48:57 2026 +0200 Avoid uninitialized diagnostic in vect_get_num_copies_for_invariant The following avoids storing garbage to *excess_elts when returning false from vect_get_num_copies_for_invariant. * tree-vect-slp.cc (vect_get_num_copies_for_invariant): Refactor to avoid accessing rem when we will return false. Diff: --- gcc/tree-vect-slp.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 06db2f288367..59148daebfe9 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -8944,12 +8944,14 @@ vect_get_num_copies_for_invariant (vec_info *vinfo, slp_tree node, tree vectype = SLP_TREE_VECTYPE (node); uint64_t rem; - bool res = (can_div_away_from_zero_p (vf, TYPE_VECTOR_SUBPARTS (vectype), - nvectors) - && ((TYPE_VECTOR_SUBPARTS (vectype) * *nvectors - vf) - .is_constant (&rem))); - *excess_elts = rem; - return res; + if (can_div_away_from_zero_p (vf, TYPE_VECTOR_SUBPARTS (vectype), + nvectors) + && (TYPE_VECTOR_SUBPARTS (vectype) * *nvectors - vf) .is_constant (&rem)) + { + *excess_elts = rem; + return true; + } + return false; } /* Compute the prologue cost for invariant or constant operands represented
