https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112359
--- Comment #3 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 6 Nov 2023, rdapp at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112359 > > --- Comment #2 from Robin Dapp <rdapp at gcc dot gnu.org> --- > Would something like > > + bool allow_cond_op = flag_tree_loop_vectorize > + && !gimple_bb (phi)->loop_father->dont_vectorize; > > in convert_scalar_cond_reduction be sufficient or are the more conditions to > check still? Testing with the above and the reduced testcase worked FWIW. You want, in tree_if_conversion (), remember whether we versioned the loop as part of if (need_to_lower_bitfields || need_to_predicate || any_complicated_phi || flag_tree_loop_if_convert != 1) { ... and pass that as flag to combine_blocks and down to predicate_all_scalar_phis (or add a new global flag). Ideally we'd do the convert_scalar_cond_reduction analysis beforehand and force versioning for the case we'd generate a .COND_* instead of deciding at code-generation only (when it's too late to do the required versioning).