https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121349
Bug ID: 121349 Summary: scalar_cond_masked_set optimization fails to consider all SLP lanes Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- We record a scalar operand in vect_record_loop_mask: void vect_record_loop_mask (loop_vec_info loop_vinfo, vec_loop_masks *masks, unsigned int nvectors, tree vectype, tree scalar_mask) { gcc_assert (nvectors != 0); if (scalar_mask) { scalar_cond_masked_key cond (scalar_mask, nvectors); loop_vinfo->scalar_cond_masked_set.add (cond); but with SLP and more than one lanes (and a non-uniform lane config) this fails to properly key on the appropriate mask. Likewise the use in vectorizable_opertation only queries for lane zero (or rather the def of the SLP node representative): if (loop_vinfo->scalar_cond_masked_set.contains ({ op0, vec_num })) { We probably want to key off the SLP node itself? But there's users of the same type in scalar tree-if-conv.cc It might be possible to construct a wrong-code testcase from the above?