https://gcc.gnu.org/g:c28fb298ab9abae7f7501411c2003e834ae568ef
commit r17-5965-gc28fb298ab9abae7f7501411c2003e834ae568ef Author: Richard Biener <[email protected]> Date: Wed Nov 4 15:52:09 2026 +0100 Fill match[] on can_duplicate_and_interleave_p failure When during SLP discovery we fail to create a constant/invariant def due to the can_duplicate_and_interleave_p check we possibly inherit a clobbered matches[] from an earlier operand. We also fail to indicate all relevant not matching lanes while not raising a fatal match failure. The following ensures to populate a valid matches[] for the failure. * tree-vect-slp.cc (vect_build_slp_tree_2): When can_duplicate_and_interleave_p fails, fully populate matches[]. Diff: --- gcc/tree-vect-slp.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index ee05e1767ccb..91e0a62f6fb0 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3028,7 +3028,15 @@ out: oprnd_info->ops.length (), TREE_TYPE (op0))) { + for (unsigned k = 0; k < j; ++k) + matches[k] = 0; matches[j] = -1; + for (unsigned k = j + 1; k < oprnd_info->ops.length (); ++k) + if (oprnd_info->ops[k] + && !operand_equal_p (op0, oprnd_info->ops[k])) + matches[k] = -1; + else + matches[k] = 0; if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "Build SLP failed: invalid type of def "
