diff mbox series

Fill match[] on can_duplicate_and_interleave_p failure

Message ID q8r5q621-s675-041p-qo1s-n0q7o9719n2p@fhfr.qr
State New
Headers show
Series Fill match[] on can_duplicate_and_interleave_p failure | expand

Commit Message

Richard Biener Nov. 4, 2026, 3:13 p.m. UTC
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.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Prompted by Sashiko review of
Optimize SLP reduction group discovery with new matches[]
I'll push this as prerequesite.

	* tree-vect-slp.cc (vect_build_slp_tree_2): When
	can_duplicate_and_interleave_p fails, fully populate matches[].
---
 gcc/tree-vect-slp.cc | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 24f4657ac74..8c8f3a6d9b7 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3026,7 +3026,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 "