diff mbox series

tree-optimization/127190 - ICE in vectorizable_lane_reducing

Message ID 929p9q19-37pp-sp3r-qsq6-qs43885o631p@fhfr.qr
State New
Headers show
Series tree-optimization/127190 - ICE in vectorizable_lane_reducing | expand

Commit Message

Richard Biener Sept. 2, 2026, 11:20 a.m. UTC
The following properly fails analyzing a lane-reducing reduction
when vect_get_num_copies_for_invariant fails instead of asserting
it does not.  While analysis later verifies we can create the
constant we use the info here for costing, so we have to fail
early.

Bootstrapped and tested on aarch64-linux-gnu, pushed.

	PR tree-optimization/127190
	* tree-vect-loop.cc (vectorizable_lane_reducing): Fail
	when vect_get_num_copies_for_invariant does.
---
 gcc/tree-vect-loop.cc | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index cb961440656..19e7a6fa884 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6855,10 +6855,16 @@  vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
   /* Compute number of effective vector statements for costing from the
      number of input lanes allow for excess lanes in the last input vector.  */
   unsigned int ncopies_for_cost, excess_elts;
-  bool res = vect_get_num_copies_for_invariant (loop_vinfo, node_in,
-						&ncopies_for_cost,
-						&excess_elts);
-  gcc_assert (res && ncopies_for_cost >= 1);
+  if (!vect_get_num_copies_for_invariant (loop_vinfo, node_in,
+					  &ncopies_for_cost,
+					  &excess_elts))
+    {
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "incompatible vector types for invariants\n");
+      return false;
+    }
+  gcc_assert (ncopies_for_cost >= 1);
 
   if (vect_is_emulated_mixed_dot_prod (slp_node))
     {