https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69166
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- I'm not sure why this check_reduction business exists - but certainly unconditionally doing if (code == COND_EXPR) *v_reduc_type = COND_REDUCTION; ICEs in the cond-reduction testcases (huh). So ... Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 232315) +++ gcc/tree-vect-loop.c (working copy) @@ -2747,7 +2750,7 @@ vect_is_simple_reduction (loop_vec_info && SSA_NAME_DEF_STMT (op1) == phi) code = PLUS_EXPR; - if (check_reduction) + if (code != COND_EXPR || check_reduction) { if (code == COND_EXPR) *v_reduc_type = COND_REDUCTION; "works" (testing vect.exp sofar). So does Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 232315) +++ gcc/tree-vect-loop.c (working copy) @@ -2604,10 +2604,12 @@ vect_is_simple_reduction (loop_vec_info *double_reduc = false; *v_reduc_type = TREE_CODE_REDUCTION; +#if 0 /* If CHECK_REDUCTION is true, we assume inner-most loop vectorization, otherwise, we assume outer loop vectorization. */ gcc_assert ((check_reduction && loop == vect_loop) || (!check_reduction && flow_loop_nested_p (vect_loop, loop))); +#endif name = PHI_RESULT (phi); /* ??? If there are no uses of the PHI result the inner loop reduction @@ -3016,7 +3021,7 @@ vect_force_simple_reduction (loop_vec_in bool need_wrapping_integral_overflow) { enum vect_reduction_type v_reduc_type; - return vect_is_simple_reduction (loop_info, phi, check_reduction, + return vect_is_simple_reduction (loop_info, phi, true, double_reduc, need_wrapping_integral_overflow, &v_reduc_type); which I believe is "better" (it makes sure we verify the reduction when initially classifying it as such). That makes outer loop vect / nested cycle testcases fail though. Oh well. Need to sit down and understand this stuff some more :/