https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69848
--- Comment #3 from alahay01 at gcc dot gnu.org --- The standard way of dealing with condition reductions like this is to ignore the contents of the "if" statement and produce a lot of code to deal with the general case (it creates two vectors - one full of indexes and one full of results). In the code, this is where STMT_VINFO_VEC_REDUCTION_TYPE is set to COND_REDUCTION in tree-vect-loop.c. We have an optimisation of this for when the code is "if (a[b]) c=b" which bypasses most of the code produced by the general case. In the code, this is where STMT_VINFO_VEC_REDUCTION_TYPE is set to INTEGER_INDUC_COND_REDUCTION tree-vect-loop.c. I haven't figured out what the generated asm should look like for this issue, but I think we'll need a further vect_reduction_type case (CONST_COND_REDUCTION ??) which is checked for at the same point as INTEGER_INDUC_COND_REDUCTION (just after the "If we have a condition reduction, see if we can simplify it further." comment).