https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65533
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #4) > Created attachment 35120 [details] > gcc5-pr65533.patch > > Untested fix. Hmm, looks basically ok, though doing vect_free_slp_tree (child); from the cleanup before /* If the SLP build for operand zero failed and operand zero and one can be commutated try that for the scalar stmts that failed the match. */ if (i == 0 ... and simply re-allocating child with child = vect_create_new_slp_node (oprnd_info->def_stmts); if (!child) { vect_free_oprnd_info (oprnds_info); return false; } might be "simpler". Your patch is ok if it is already tested.