http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60382
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- The issue is that in vectorizable_reduction we compute double_reduc in a wrong way: if (nested_cycle) { def_bb = gimple_bb (reduc_def_stmt); def_stmt_loop = def_bb->loop_father; def_arg = PHI_ARG_DEF_FROM_EDGE (reduc_def_stmt, loop_preheader_edge (def_stmt_loop)); if (TREE_CODE (def_arg) == SSA_NAME && (def_arg_stmt = SSA_NAME_DEF_STMT (def_arg)) && gimple_code (def_arg_stmt) == GIMPLE_PHI && flow_bb_inside_loop_p (outer_loop, gimple_bb (def_arg_stmt)) && vinfo_for_stmt (def_arg_stmt) && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def_arg_stmt)) == vect_double_reduction_def) double_reduc = true; } that is because def_arg is a constant (and the outer loop reduction PHI is dead). Easiest is to not detect this as a valid reduction with sth like Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 208269) +++ gcc/tree-vect-loop.c (working copy) @@ -2193,6 +2193,12 @@ vect_is_simple_reduction_1 (loop_vec_inf || (!check_reduction && flow_loop_nested_p (vect_loop, loop))); name = PHI_RESULT (phi); + /* ??? If there are no uses of the PHI result the inner loop reduction + won't be detected as possibly double-reduction by vectorizable_reduction + because that tries to walk the PHI arg from the preheader edge which + can be constant. See PR60382. */ + if (has_zero_uses (name)) + return NULL; nloop_uses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) {