On Mon, 21 Jan 2019, Richard Sandiford wrote: > Richard Biener <rguent...@suse.de> writes: > > @@ -5742,8 +5740,14 @@ vectorize_fold_left_reduction (stmt_vec_info > > stmt_info, > > auto_vec<tree> vec_oprnds0; > > if (slp_node) > > { > > - vect_get_vec_defs (op0, NULL_TREE, stmt_info, &vec_oprnds0, NULL, > > - slp_node); > > + auto_vec<vec<tree> > vec_defs (2); > > + auto_vec<tree> sops(2); > > + sops.quick_push (ops[0]); > > + sops.quick_push (ops[1]); > > + vect_get_slp_defs (sops, slp_node, &vec_defs); > > + vec_oprnds0.safe_splice (vec_defs[1 - reduc_index]); > > + vec_defs[0].release (); > > + vec_defs[1].release (); > > group_size = SLP_TREE_SCALAR_STMTS (slp_node).length (); > > scalar_dest_def_info = SLP_TREE_SCALAR_STMTS (slp_node)[group_size - > > 1]; > > } > > Ewww. :-) Would be nice if it was easier to do the right thing.
Working on that ;) > But are you sure we want this for fold-left reductions? The other > operand isn't supposed to be vectorised -- it stays a scalar even > in the vector loop. It seems to "work" for me. The issue appears with MINUS_EXPR fold-left reductions (you may have guessed that). I guess it's possible to create a SLP testcase even without patched trunk (I have group_size == 1 SLP instances "enabled"). In the end vect_get_slp_defs will, if no actual vectorized stmts are recorded, not push any to the defs vector which means vec_defs[0] will remain empty. Richard.